Files

73 lines
1.8 KiB
TypeScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Simple test to verify dspy.ts integration works at runtime
*/
import { DSPyAgenticSynthTrainer } from './dspy-real-integration.js';
async function test() {
console.log('🧪 Testing DSPy.ts Real Integration\n');
// Simple schema
const schema = {
type: 'object',
properties: {
id: { type: 'string' },
name: { type: 'string' },
value: { type: 'number' }
}
};
// Simple examples
const examples = [
{
input: JSON.stringify(schema),
output: JSON.stringify({ id: '1', name: 'Test', value: 42 }),
quality: 0.9
}
];
try {
// Create trainer
console.log('✓ Creating trainer...');
const trainer = new DSPyAgenticSynthTrainer({
models: ['gpt-3.5-turbo'],
optimizationRounds: 2,
minQualityScore: 0.7,
batchSize: 3
});
console.log('✓ Trainer created');
// Check if API key is set
if (!process.env.OPENAI_API_KEY) {
console.log('\n⚠ OPENAI_API_KEY not set. Skipping initialization test.');
console.log(' Set OPENAI_API_KEY to test full functionality.\n');
console.log('✅ Integration code structure is valid!');
return;
}
// Initialize
console.log('✓ Initializing DSPy.ts...');
await trainer.initialize();
console.log('✓ Initialization complete\n');
// Get stats
const stats = trainer.getStatistics();
console.log('📊 Statistics:');
console.log(` Total Iterations: ${stats.totalIterations}`);
console.log(` Best Score: ${stats.bestScore}`);
console.log(` Training Examples: ${stats.trainingExamples}`);
console.log('\n✅ All tests passed!');
} catch (error: any) {
console.error('\n❌ Test failed:', error.message);
if (error.details) {
console.error('Details:', error.details);
}
process.exit(1);
}
}
test().catch(console.error);