contaigents
Version:
Modular AI Content Ecosystem with Audio Generation
75 lines (74 loc) ⢠3.03 kB
JavaScript
import { ImageAnalysisTool } from '../services/tools/ImageAnalysisTool.js';
async function testImageAnalysis() {
console.log('š Testing Image Analysis Tool...\n');
const tool = new ImageAnalysisTool(process.cwd());
// Test 1: Basic image analysis
console.log('š Test 1: Basic Image Analysis');
const result1 = await tool.execute({
image_path: '../demo/test_ref_image.jpeg',
question: 'What do you see in this image? Describe the main elements, colors, and overall composition.'
});
if (result1.success) {
console.log('ā
Basic analysis successful!');
console.log('š Result data:', JSON.stringify(result1.data, null, 2));
console.log('š¬ Analysis:', result1.data.analysis);
}
else {
console.log('ā Basic analysis failed:', result1.error);
}
// Test 2: Detailed style analysis
console.log('\nšØ Test 2: Detailed Style Analysis');
const result2 = await tool.execute({
image_path: '../demo/test_ref_image.jpeg',
question: 'Analyze the artistic style of this image in detail. What are the key visual characteristics, color techniques, and compositional elements? How would you describe the mood and atmosphere?',
detail_level: 'high'
});
if (result2.success) {
console.log('ā
Style analysis successful!');
console.log('šØ Style Analysis:', result2.data.analysis);
}
else {
console.log('ā Style analysis failed:', result2.error);
}
// Test 3: Brief analysis
console.log('\nā” Test 3: Brief Analysis');
const result3 = await tool.execute({
image_path: '../demo/test_ref_image.jpeg',
question: 'What is the dominant color scheme in this image?',
detail_level: 'low'
});
if (result3.success) {
console.log('ā
Brief analysis successful!');
console.log('šÆ Brief Analysis:', result3.data.analysis);
}
else {
console.log('ā Brief analysis failed:', result3.error);
}
// Test 4: Parameter validation
console.log('\nš Test 4: Parameter Validation');
const invalidResult1 = await tool.execute({
image_path: '../demo/test_ref_image.jpeg'
// Missing question
});
if (!invalidResult1.success) {
console.log('ā
Missing question correctly handled:', invalidResult1.error);
}
else {
console.log('ā Missing question should have been caught');
}
// Test 5: File validation
console.log('\nš Test 5: File Validation');
const invalidResult2 = await tool.execute({
image_path: 'nonexistent-image.jpg',
question: 'What do you see?'
});
if (!invalidResult2.success) {
console.log('ā
Nonexistent file correctly handled:', invalidResult2.error);
}
else {
console.log('ā Nonexistent file should have been caught');
}
console.log('\nš Image Analysis Tool tests completed!');
}
testImageAnalysis().catch(console.error);