80 lines
2.8 KiB
JavaScript
80 lines
2.8 KiB
JavaScript
const FormData = require('form-data');
|
|
const fs = require('fs');
|
|
const axios = require('axios');
|
|
|
|
async function testEnhancedPipeline() {
|
|
try {
|
|
console.log('🚀 Testing Enhanced Agentic RAG Pipeline...');
|
|
|
|
// Login
|
|
const loginResponse = await axios.post('http://localhost:5000/api/auth/login', {
|
|
email: 'user1@example.com',
|
|
password: 'user123'
|
|
});
|
|
|
|
const token = loginResponse.data.data.tokens.accessToken;
|
|
console.log('✅ Authenticated successfully');
|
|
|
|
// Upload the same document again to trigger the new enhanced pipeline
|
|
const staxFilePath = '/home/jonathan/Coding/cim_summary/stax-cim-test.pdf';
|
|
const form = new FormData();
|
|
form.append('document', fs.createReadStream(staxFilePath));
|
|
|
|
console.log('📄 Uploading document for enhanced agentic RAG processing...');
|
|
const uploadResponse = await axios.post('http://localhost:5000/api/documents', form, {
|
|
headers: {
|
|
...form.getHeaders(),
|
|
'Authorization': `Bearer ${token}`
|
|
}
|
|
});
|
|
|
|
if (!uploadResponse.data.success) {
|
|
console.error('❌ Upload failed:', uploadResponse.data);
|
|
return;
|
|
}
|
|
|
|
const documentId = uploadResponse.data.data.document.id;
|
|
console.log('✅ Document uploaded! ID:', documentId);
|
|
console.log('🧠 Enhanced agentic RAG with vectorization should now be processing...');
|
|
|
|
// Monitor for the new logs indicating enhanced processing
|
|
console.log('⏳ Monitoring for enhanced processing logs...');
|
|
let attempts = 0;
|
|
const maxAttempts = 10;
|
|
|
|
while (attempts < maxAttempts) {
|
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
attempts++;
|
|
|
|
try {
|
|
const progressResponse = await axios.get(
|
|
`http://localhost:5000/api/documents/${documentId}/progress`,
|
|
{ headers: { 'Authorization': `Bearer ${token}` } }
|
|
);
|
|
|
|
console.log(`📊 Attempt ${attempts}: ${progressResponse.data.progress}% - ${progressResponse.data.step}`);
|
|
|
|
if (progressResponse.data.status === 'completed') {
|
|
console.log('🎉 Enhanced processing completed!');
|
|
break;
|
|
} else if (progressResponse.data.status === 'failed') {
|
|
console.error('❌ Processing failed:', progressResponse.data.error);
|
|
break;
|
|
}
|
|
} catch (error) {
|
|
console.log(`⚠️ Progress check ${attempts}: ${error.response?.status || error.message}`);
|
|
}
|
|
}
|
|
|
|
console.log('✅ Enhanced agentic RAG pipeline test completed!');
|
|
console.log('📋 Check backend logs for vectorization and enhanced search logs.');
|
|
|
|
} catch (error) {
|
|
console.error('❌ Test failed:', error.message);
|
|
if (error.response) {
|
|
console.error('Response:', error.response.data);
|
|
}
|
|
}
|
|
}
|
|
|
|
testEnhancedPipeline(); |