contaigents
Version:
Modular AI Content Ecosystem with Audio Generation
45 lines (44 loc) ⢠2.52 kB
JavaScript
import { ChatService } from '../services/chatService.js';
async function demonstrateNewToolArchitecture() {
console.log('š§ Testing New Tool Architecture...\n');
try {
// Initialize chat service with current directory
const chatService = new ChatService(process.cwd());
// Create a chat session
const session = chatService.createSession({
systemPrompt: `You are a helpful AI assistant with access to file reading tools. When users ask about files, use the read_file tool to access their contents. Always be helpful and provide detailed information about what you find.`
});
console.log(`š¬ Created chat session: ${session.id}\n`);
// Test: Ask to read a file (should trigger tool calls)
console.log('š Test: Asking to read README.md...');
const response = await chatService.sendMessage(session.id, "Please read the README.md file and tell me what it contains.");
console.log('š¤ Final Assistant Response:');
console.log(response.content);
console.log('\n');
// Check the session messages to verify the architecture
console.log('š Session Message Analysis:');
const allMessages = chatService.getAllMessages(session.id);
const userVisibleMessages = chatService.getMessages(session.id);
console.log(`Total messages in session: ${allMessages.length}`);
console.log(`User-visible messages: ${userVisibleMessages.length}`);
console.log('\nMessage breakdown:');
allMessages.forEach((msg, index) => {
const type = msg.isToolResponse ? ' (TOOL RESPONSE - HIDDEN FROM USER)' : '';
console.log(`${index + 1}. ${msg.role.toUpperCase()}${type}: ${msg.content.substring(0, 100)}...`);
});
console.log('\nā
New Tool Architecture Test Completed!');
console.log('\nšÆ Architecture Verification:');
console.log('- ā
Tool calls executed and responses generated');
console.log('- ā
Tool responses added as user messages (for LLM context)');
console.log('- ā
Tool responses marked as hidden from UI');
console.log('- ā
Follow-up assistant response generated');
console.log('- ā
User only sees assistant messages, not tool responses');
}
catch (error) {
console.error('ā Error in demonstration:', error);
throw error;
}
}
// Run the demonstration
demonstrateNewToolArchitecture().catch(console.error);