first commit
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
const groqService = require('../services/groqService');
|
||||
const model1Service = require('../services/model1Service');
|
||||
const queryModelService = require('../services/queryModelService');
|
||||
const logger = require('./logger');
|
||||
|
||||
const testGroqConnection = async () => {
|
||||
console.log('🧪 Testing Groq API Connection...');
|
||||
|
||||
try {
|
||||
const connectionTest = await groqService.testConnection();
|
||||
|
||||
if (connectionTest.success) {
|
||||
console.log('✅ Groq API connection successful');
|
||||
console.log(`Model: ${connectionTest.model}`);
|
||||
console.log(`Response: ${connectionTest.response.content.substring(0, 100)}...`);
|
||||
} else {
|
||||
console.log('❌ Groq API connection failed');
|
||||
console.log(`Error: ${connectionTest.error}`);
|
||||
}
|
||||
|
||||
return connectionTest;
|
||||
} catch (error) {
|
||||
console.log('❌ Groq API test failed:', error.message);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
};
|
||||
|
||||
const testModel1 = async () => {
|
||||
console.log('\n🧪 Testing MODEL1 (Engineering Plan Generation)...');
|
||||
|
||||
try {
|
||||
const testQuery = "How do I design a bridge that can handle heavy traffic loads?";
|
||||
const planData = await model1Service.generatePlan(testQuery, {
|
||||
context: { test: true }
|
||||
});
|
||||
|
||||
console.log('✅ MODEL1 plan generation successful');
|
||||
console.log(`Title: ${planData.title}`);
|
||||
console.log(`Description: ${planData.description.substring(0, 100)}...`);
|
||||
console.log(`Steps: ${planData.steps.length}`);
|
||||
console.log(`Tools Required: ${planData.toolsRequired.length}`);
|
||||
console.log(`Processing Time: ${planData.processingTime}s`);
|
||||
console.log(`Tokens Used: ${planData.tokensUsed}`);
|
||||
|
||||
return planData;
|
||||
} catch (error) {
|
||||
console.log('❌ MODEL1 test failed:', error.message);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
};
|
||||
|
||||
const testQueryModel = async () => {
|
||||
console.log('\n🧪 Testing QUERYMODEL (Plan Execution)...');
|
||||
|
||||
try {
|
||||
const testPlan = "Execute the following engineering plan: Design a bridge for heavy traffic loads. Steps: 1. Calculate load requirements 2. Design structural elements 3. Check safety factors";
|
||||
const executionResult = await queryModelService.executePlan(testPlan, {
|
||||
test: true
|
||||
});
|
||||
|
||||
console.log('✅ QUERYMODEL execution successful');
|
||||
console.log(`Execution Status: ${executionResult.executionResults.executionStatus}`);
|
||||
console.log(`Steps Completed: ${executionResult.executionResults.stepsCompleted.length}`);
|
||||
console.log(`Results: ${executionResult.executionResults.results.length}`);
|
||||
console.log(`Processing Time: ${executionResult.processingTime}s`);
|
||||
console.log(`Tokens Used: ${executionResult.tokensUsed}`);
|
||||
|
||||
return executionResult;
|
||||
} catch (error) {
|
||||
console.log('❌ QUERYMODEL test failed:', error.message);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
};
|
||||
|
||||
const testToolExecution = async () => {
|
||||
console.log('\n🧪 Testing Tool Execution...');
|
||||
|
||||
try {
|
||||
const toolResult = await queryModelService.executeTool(
|
||||
'query_expander',
|
||||
'query_expander',
|
||||
{ query: 'bridge design', context: { test: true } },
|
||||
'test-plan-id'
|
||||
);
|
||||
|
||||
console.log('✅ Tool execution successful');
|
||||
console.log(`Tool: ${toolResult.tool_name}`);
|
||||
console.log(`Status: ${toolResult.status}`);
|
||||
console.log(`Execution Time: ${toolResult.execution_time}s`);
|
||||
|
||||
return toolResult;
|
||||
} catch (error) {
|
||||
console.log('❌ Tool execution test failed:', error.message);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
};
|
||||
|
||||
const runAllTests = async () => {
|
||||
console.log('🚀 Starting Groq Integration Tests...\n');
|
||||
|
||||
const results = {
|
||||
connection: await testGroqConnection(),
|
||||
model1: await testModel1(),
|
||||
queryModel: await testQueryModel(),
|
||||
toolExecution: await testToolExecution()
|
||||
};
|
||||
|
||||
console.log('\n📊 Test Results Summary:');
|
||||
console.log(`Connection: ${results.connection.success ? '✅' : '❌'}`);
|
||||
console.log(`MODEL1: ${results.model1.success !== false ? '✅' : '❌'}`);
|
||||
console.log(`QUERYMODEL: ${results.queryModel.success !== false ? '✅' : '❌'}`);
|
||||
console.log(`Tool Execution: ${results.toolExecution.success !== false ? '✅' : '❌'}`);
|
||||
|
||||
const allPassed = Object.values(results).every(result =>
|
||||
result.success !== false
|
||||
);
|
||||
|
||||
console.log(`\n${allPassed ? '🎉 All tests passed!' : '⚠️ Some tests failed'}`);
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
// Run tests if this file is executed directly
|
||||
if (require.main === module) {
|
||||
runAllTests().catch(console.error);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
testGroqConnection,
|
||||
testModel1,
|
||||
testQueryModel,
|
||||
testToolExecution,
|
||||
runAllTests
|
||||
};
|
||||
Reference in New Issue
Block a user