UNPKG

contaigents

Version:

Modular AI Content Ecosystem with Audio Generation

45 lines (44 loc) • 2.52 kB
#!/usr/bin/env node 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);