Files
cim_summary/backend/create-document-ai-processor.js
Jon 185c780486
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
🚀 Update to Claude 3.7 latest and fix LLM processing issues
- 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
2025-08-17 17:31:56 -04:00

66 lines
2.2 KiB
JavaScript

#!/usr/bin/env node
// Create a Document AI processor for the testing environment
const { DocumentProcessorServiceClient } = require('@google-cloud/documentai');
async function createProcessor() {
console.log('🏗️ Creating Document AI Processor for Testing...');
console.log('===============================================');
try {
// Set up client
process.env.GOOGLE_APPLICATION_CREDENTIALS = './serviceAccountKey-testing.json';
const client = new DocumentProcessorServiceClient();
const projectId = 'cim-summarizer-testing';
const location = 'us';
const parent = `projects/${projectId}/locations/${location}`;
console.log('📋 Configuration:');
console.log(' - Project:', projectId);
console.log(' - Location:', location);
console.log(' - Parent:', parent);
// Create processor
const request = {
parent: parent,
processor: {
displayName: 'CIM Document Processor (Testing)',
type: 'OCR_PROCESSOR' // General OCR processor
}
};
console.log('\n🚀 Creating processor...');
const [processor] = await client.createProcessor(request);
console.log('✅ Processor created successfully!');
console.log('📋 Processor Details:');
console.log(' - Name:', processor.name);
console.log(' - Display Name:', processor.displayName);
console.log(' - Type:', processor.type);
console.log(' - State:', processor.state);
// Extract processor ID for environment configuration
const processorId = processor.name.split('/').pop();
console.log(' - Processor ID:', processorId);
console.log('\n📝 Update your .env file with:');
console.log(`DOCUMENT_AI_PROCESSOR_ID=${processorId}`);
return processor;
} catch (error) {
console.error('❌ Failed to create processor:', error);
console.error('Error details:', error.details || 'No additional details');
if (error.code === 7) {
console.log('\n💡 This might be a permission issue. Check that the service account has:');
console.log(' - roles/documentai.editor');
console.log(' - Document AI API is enabled');
}
throw error;
}
}
createProcessor();