Some checks failed
CI/CD Pipeline / Backend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Frontend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Build Backend (push) Has been cancelled
CI/CD Pipeline / Build Frontend (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Performance Tests (push) Has been cancelled
CI/CD Pipeline / Dependency Updates (push) Has been cancelled
- Updated Anthropic API to latest version (2024-01-01) - Set Claude 3.7 Sonnet Latest as primary model - Removed deprecated Opus 3.5 references - Fixed LLM response validation and JSON parsing - Improved error handling and logging - Updated model configurations and pricing - Enhanced document processing reliability - Fixed TypeScript type issues - Updated environment configuration
106 lines
3.7 KiB
JavaScript
106 lines
3.7 KiB
JavaScript
// Import the compiled JavaScript version
|
|
const { llmService } = require('./dist/services/llmService');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// Load environment variables
|
|
require('dotenv').config({ path: path.join(__dirname, '.env') });
|
|
|
|
async function debugLLMProcessing() {
|
|
try {
|
|
console.log('🔍 Debugging LLM Processing...\n');
|
|
|
|
// Sample CIM text for testing
|
|
const sampleCIMText = `
|
|
CONFIDENTIAL INFORMATION MEMORANDUM
|
|
|
|
COMPANY: Sample Manufacturing Corp.
|
|
INDUSTRY: Industrial Manufacturing
|
|
LOCATION: Cleveland, OH
|
|
EMPLOYEES: 150
|
|
REVENUE: $25M (2023), $28M (2024)
|
|
EBITDA: $4.2M (2023), $4.8M (2024)
|
|
|
|
BUSINESS DESCRIPTION:
|
|
Sample Manufacturing Corp. is a leading manufacturer of precision industrial components serving the automotive and aerospace industries. The company has been in business for 25 years and operates from a 50,000 sq ft facility in Cleveland, OH.
|
|
|
|
KEY PRODUCTS:
|
|
- Precision machined parts (60% of revenue)
|
|
- Assembly services (25% of revenue)
|
|
- Engineering consulting (15% of revenue)
|
|
|
|
CUSTOMERS:
|
|
- Top 5 customers represent 45% of revenue
|
|
- Long-term contracts with major automotive OEMs
|
|
- Growing aerospace segment
|
|
|
|
FINANCIAL PERFORMANCE:
|
|
FY 2022: Revenue $22M, EBITDA $3.8M
|
|
FY 2023: Revenue $25M, EBITDA $4.2M
|
|
FY 2024: Revenue $28M, EBITDA $4.8M
|
|
|
|
MANAGEMENT:
|
|
CEO: John Smith (15 years experience)
|
|
CFO: Sarah Johnson (10 years experience)
|
|
COO: Mike Davis (12 years experience)
|
|
|
|
REASON FOR SALE:
|
|
Founder looking to retire and seeking strategic partner for growth.
|
|
`;
|
|
|
|
console.log('📄 Sample CIM Text Length:', sampleCIMText.length, 'characters');
|
|
console.log('🔄 Testing LLM processing...\n');
|
|
|
|
// Test the LLM processing
|
|
const result = await llmService.processCIMDocument(sampleCIMText, {
|
|
taskType: 'complex',
|
|
priority: 'quality'
|
|
});
|
|
|
|
console.log('✅ LLM Processing Result:');
|
|
console.log(' Model Used:', result.model);
|
|
console.log(' Tokens Used:', result.tokensUsed);
|
|
console.log(' Cost:', result.cost);
|
|
console.log(' Processing Time:', result.processingTime, 'ms');
|
|
|
|
console.log('\n📋 Raw LLM Response:');
|
|
console.log(' Content Length:', result.content.length, 'characters');
|
|
console.log(' Content Preview:', result.content.substring(0, 500) + '...');
|
|
|
|
console.log('\n🔍 Analysis Data:');
|
|
console.log(' Analysis Data Type:', typeof result.analysisData);
|
|
console.log(' Analysis Data Keys:', Object.keys(result.analysisData));
|
|
|
|
if (result.analysisData && Object.keys(result.analysisData).length > 0) {
|
|
console.log(' Analysis Data Preview:', JSON.stringify(result.analysisData, null, 2).substring(0, 1000) + '...');
|
|
} else {
|
|
console.log(' ❌ Analysis Data is empty or missing!');
|
|
}
|
|
|
|
// Check if the response contains JSON
|
|
const jsonMatch = result.content.match(/\{[\s\S]*\}/);
|
|
if (jsonMatch) {
|
|
console.log('\n🔍 JSON Extraction:');
|
|
console.log(' JSON Found:', 'Yes');
|
|
console.log(' JSON Length:', jsonMatch[0].length);
|
|
console.log(' JSON Preview:', jsonMatch[0].substring(0, 500) + '...');
|
|
|
|
try {
|
|
const parsedJson = JSON.parse(jsonMatch[0]);
|
|
console.log(' ✅ JSON Parsing: Success');
|
|
console.log(' Parsed Keys:', Object.keys(parsedJson));
|
|
} catch (parseError) {
|
|
console.log(' ❌ JSON Parsing: Failed -', parseError.message);
|
|
}
|
|
} else {
|
|
console.log('\n❌ No JSON found in LLM response!');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Debug failed:', error.message);
|
|
console.error(' Error details:', error);
|
|
}
|
|
}
|
|
|
|
debugLLMProcessing();
|