Files
cim_summary/backend/test-rag-processing.js

163 lines
6.4 KiB
JavaScript

const { ragDocumentProcessor } = require('./dist/services/ragDocumentProcessor');
const { unifiedDocumentProcessor } = require('./dist/services/unifiedDocumentProcessor');
// Sample CIM text for testing
const sampleCIMText = `
EXECUTIVE SUMMARY
Company Overview
ABC Manufacturing is a leading provider of precision manufacturing solutions for the aerospace and defense industries. Founded in 1985, the company has grown to become a trusted partner for major OEMs and Tier 1 suppliers.
Financial Performance
The company has demonstrated consistent growth over the past three years:
- FY-3: Revenue $45M, EBITDA $8.2M (18.2% margin)
- FY-2: Revenue $52M, EBITDA $9.8M (18.8% margin)
- FY-1: Revenue $58M, EBITDA $11.2M (19.3% margin)
- LTM: Revenue $62M, EBITDA $12.1M (19.5% margin)
BUSINESS DESCRIPTION
Core Operations
ABC Manufacturing specializes in precision machining, assembly, and testing of critical aerospace components. The company operates from a 150,000 sq ft facility in Cleveland, Ohio, with state-of-the-art CNC equipment and quality control systems.
Key Products & Services
- Precision machined components (60% of revenue)
- Assembly and testing services (25% of revenue)
- Engineering and design support (15% of revenue)
Customer Base
The company serves major aerospace OEMs including Boeing, Lockheed Martin, and Northrop Grumman. Top 5 customers represent 75% of revenue, with Boeing being the largest at 35%.
MARKET ANALYSIS
Market Size & Growth
The global aerospace manufacturing market is estimated at $850B, growing at 4.2% CAGR. The precision manufacturing segment represents approximately $120B of this market.
Competitive Landscape
Key competitors include:
- Precision Castparts (PCC)
- Arconic
- ATI Metals
- Local and regional precision manufacturers
Competitive Advantages
- Long-term relationships with major OEMs
- AS9100 and NADCAP certifications
- Advanced manufacturing capabilities
- Proximity to major aerospace hubs
FINANCIAL SUMMARY
Revenue Growth Drivers
- Increased defense spending
- Commercial aerospace recovery
- New product development programs
- Geographic expansion
Quality of Earnings
The company has strong, recurring revenue streams with long-term contracts. EBITDA margins have improved consistently due to operational efficiencies and automation investments.
Working Capital
Working capital intensity is moderate at 15% of revenue, with 45-day payment terms from customers and 30-day terms with suppliers.
MANAGEMENT TEAM
Key Leadership
- CEO: John Smith (25 years aerospace experience)
- CFO: Sarah Johnson (15 years manufacturing finance)
- COO: Mike Davis (20 years operations leadership)
Management Quality
The management team has deep industry experience and strong relationships with key customers. All executives have committed to remain post-transaction.
INVESTMENT THESIS
Key Attractions
- Strong market position in growing aerospace sector
- Consistent financial performance and margin expansion
- Long-term customer relationships with major OEMs
- Experienced management team committed to growth
- Strategic location in aerospace manufacturing hub
Value Creation Opportunities
- Geographic expansion to capture additional market share
- Technology investments to improve efficiency and capabilities
- Add-on acquisitions to expand product portfolio
- Operational improvements to further enhance margins
Risks & Considerations
- Customer concentration (75% from top 5 customers)
- Dependence on aerospace industry cycles
- Competition from larger, well-capitalized players
- Regulatory compliance requirements
Alignment with BPCP Strategy
The company fits well within BPCP's focus on 5+MM EBITDA companies in industrial markets. The Cleveland location provides proximity to BPCP's headquarters, and the founder-owned nature aligns with BPCP's preferences.
`;
async function testRAGProcessing() {
console.log('🚀 Testing RAG Processing Approach');
console.log('==================================');
try {
// Test RAG processing
console.log('\n📋 Testing RAG Processing...');
const startTime = Date.now();
const ragResult = await ragDocumentProcessor.processDocument(sampleCIMText, 'test-doc-001');
const processingTime = Date.now() - startTime;
console.log('✅ RAG Processing Results:');
console.log(`- Success: ${ragResult.success}`);
console.log(`- Processing Time: ${processingTime}ms`);
console.log(`- API Calls: ${ragResult.apiCalls}`);
console.log(`- Error: ${ragResult.error || 'None'}`);
if (ragResult.success) {
console.log('\n📊 Analysis Summary:');
console.log(`- Company: ${ragResult.analysisData.dealOverview?.targetCompanyName || 'N/A'}`);
console.log(`- Industry: ${ragResult.analysisData.dealOverview?.industrySector || 'N/A'}`);
console.log(`- Revenue: ${ragResult.analysisData.financialSummary?.financials?.ltm?.revenue || 'N/A'}`);
console.log(`- EBITDA: ${ragResult.analysisData.financialSummary?.financials?.ltm?.ebitda || 'N/A'}`);
}
// Test unified processor with comparison
console.log('\n🔄 Testing Unified Processor Comparison...');
const comparisonResult = await unifiedDocumentProcessor.compareProcessingStrategies(
'test-doc-001',
'test-user-001',
sampleCIMText
);
console.log('✅ Comparison Results:');
console.log(`- Winner: ${comparisonResult.winner}`);
console.log(`- Time Difference: ${comparisonResult.performanceMetrics.timeDifference}ms`);
console.log(`- API Call Difference: ${comparisonResult.performanceMetrics.apiCallDifference}`);
console.log(`- Quality Score: ${comparisonResult.performanceMetrics.qualityScore.toFixed(2)}`);
console.log('\n📈 Performance Summary:');
console.log('Chunking:');
console.log(` - Success: ${comparisonResult.chunking.success}`);
console.log(` - Time: ${comparisonResult.chunking.processingTime}ms`);
console.log(` - API Calls: ${comparisonResult.chunking.apiCalls}`);
console.log('RAG:');
console.log(` - Success: ${comparisonResult.rag.success}`);
console.log(` - Time: ${comparisonResult.rag.processingTime}ms`);
console.log(` - API Calls: ${comparisonResult.rag.apiCalls}`);
} catch (error) {
console.error('❌ Test failed:', error);
}
}
// Run the test
testRAGProcessing().then(() => {
console.log('\n🏁 Test completed');
process.exit(0);
}).catch(error => {
console.error('💥 Test failed:', error);
process.exit(1);
});