- Upgrade to Claude Sonnet 4.5 for better accuracy - Simplify and clarify financial extraction prompts - Add flexible period identification (years, FY-X, LTM formats) - Add cross-validation to catch wrong column extraction - Reject values that are too small (<M revenue, <00K EBITDA) - Add monitoring scripts for document processing - Improve validation to catch inconsistent values across periods
84 lines
3.0 KiB
TypeScript
84 lines
3.0 KiB
TypeScript
#!/usr/bin/env ts-node
|
|
|
|
/**
|
|
* Quick check of document status
|
|
*/
|
|
|
|
import axios from 'axios';
|
|
|
|
const API_URL = process.env.API_URL || 'https://api-y56ccs6wva-uc.a.run.app';
|
|
const DOCUMENT_ID = process.argv[2] || '69236a8b-d8a7-4328-87df-8d6da6f34d8a';
|
|
|
|
async function checkDocument() {
|
|
try {
|
|
console.log(`\n🔍 Checking Document: ${DOCUMENT_ID}\n`);
|
|
|
|
const response = await axios.get(`${API_URL}/api/documents/${DOCUMENT_ID}`, {
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
const doc = response.data;
|
|
|
|
console.log('═'.repeat(80));
|
|
console.log(`📄 File: ${doc.original_file_name || 'Unknown'}`);
|
|
console.log(`📊 Status: ${doc.status || 'unknown'}`);
|
|
console.log(`📅 Created: ${doc.created_at || 'Unknown'}`);
|
|
console.log(`🕐 Updated: ${doc.updated_at || 'Unknown'}`);
|
|
|
|
if (doc.error_message) {
|
|
console.log(`❌ Error: ${doc.error_message}`);
|
|
}
|
|
|
|
if (doc.analysis_data) {
|
|
const analysis = doc.analysis_data;
|
|
console.log('\n📈 Analysis Data:');
|
|
console.log(` Company: ${analysis.dealOverview?.targetCompanyName || 'Not extracted'}`);
|
|
console.log(` Industry: ${analysis.dealOverview?.industrySector || 'Not extracted'}`);
|
|
|
|
if (analysis.financialSummary?.financials) {
|
|
const financials = analysis.financialSummary.financials;
|
|
console.log('\n💰 Financial Data:');
|
|
console.log(` LTM Revenue: ${financials.ltm?.revenue || 'Not extracted'}`);
|
|
console.log(` LTM EBITDA: ${financials.ltm?.ebitda || 'Not extracted'}`);
|
|
console.log(` FY-1 Revenue: ${financials.fy1?.revenue || 'Not extracted'}`);
|
|
console.log(` FY-1 EBITDA: ${financials.fy1?.ebitda || 'Not extracted'}`);
|
|
} else {
|
|
console.log('\n💰 Financial Data: ⏳ Not yet extracted');
|
|
}
|
|
} else {
|
|
console.log('\n📈 Analysis Data: ⏳ Processing...');
|
|
}
|
|
|
|
console.log('═'.repeat(80));
|
|
|
|
// Check processing job if available
|
|
if (doc.status === 'processing' || doc.status === 'processing_llm') {
|
|
console.log('\n⏳ Document is still processing...');
|
|
console.log(' Run this script again to check status, or use monitor script:');
|
|
console.log(` npx ts-node src/scripts/monitor-latest-document.ts ${DOCUMENT_ID}`);
|
|
} else if (doc.status === 'completed') {
|
|
console.log('\n✅ Document processing completed!');
|
|
} else if (doc.status === 'failed') {
|
|
console.log('\n❌ Document processing failed!');
|
|
}
|
|
|
|
} catch (error: any) {
|
|
if (error.response) {
|
|
console.error(`❌ Error: ${error.response.status} - ${error.response.statusText}`);
|
|
if (error.response.status === 404) {
|
|
console.error(' Document not found. Check the document ID.');
|
|
} else if (error.response.status === 401) {
|
|
console.error(' Authentication required. Check your API token.');
|
|
}
|
|
} else {
|
|
console.error(`❌ Error: ${error.message}`);
|
|
}
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
checkDocument();
|
|
|