Files
cim_summary/backend/test-llm-direct.js
Jon c67dab22b4 Add comprehensive CIM processing features and UI improvements
- Add new database migrations for analysis data and job tracking
- Implement enhanced document processing service with LLM integration
- Add processing progress and queue status components
- Create testing guides and utility scripts for CIM processing
- Update frontend components for better user experience
- Add environment configuration and backup files
- Implement job queue service and upload progress tracking
2025-07-27 20:25:46 -04:00

66 lines
2.1 KiB
JavaScript

const { Pool } = require('pg');
const fs = require('fs');
const pdfParse = require('pdf-parse');
const pool = new Pool({
connectionString: 'postgresql://postgres:password@localhost:5432/cim_processor'
});
async function testLLMDirect() {
try {
console.log('🔍 Testing LLM processing directly...');
// Find the STAX CIM document
const docResult = await pool.query(`
SELECT id, original_file_name, status, user_id, file_path
FROM documents
WHERE original_file_name = 'stax-cim-test.pdf'
ORDER BY created_at DESC
LIMIT 1
`);
if (docResult.rows.length === 0) {
console.log('❌ No STAX CIM document found');
return;
}
const document = docResult.rows[0];
console.log(`📄 Found document: ${document.original_file_name}`);
console.log(`📁 File path: ${document.file_path}`);
// Check if file exists
if (!fs.existsSync(document.file_path)) {
console.log('❌ File not found at path:', document.file_path);
return;
}
console.log('✅ File found, extracting text...');
// Extract text from PDF
const dataBuffer = fs.readFileSync(document.file_path);
const pdfData = await pdfParse(dataBuffer);
console.log(`📊 Extracted ${pdfData.text.length} characters from ${pdfData.numpages} pages`);
console.log('📝 First 500 characters:');
console.log(pdfData.text.substring(0, 500));
console.log('...');
console.log('');
console.log('🎯 Next Steps:');
console.log('1. The text extraction is working');
console.log('2. The LLM processing should work with your API keys');
console.log('3. The issue is that the job queue worker isn\'t running');
console.log('');
console.log('💡 To fix this:');
console.log('1. The backend needs to be restarted to pick up the processing jobs');
console.log('2. Or we need to manually trigger the LLM processing');
console.log('3. The processing jobs are already created and ready');
} catch (error) {
console.error('❌ Error testing LLM:', error.message);
} finally {
await pool.end();
}
}
testLLMDirect();