-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-chat.js
More file actions
58 lines (46 loc) Β· 2.12 KB
/
test-chat.js
File metadata and controls
58 lines (46 loc) Β· 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env node
/**
* Test script for the AI Chat endpoint
* Usage: node test-chat.js
*/
import axios from 'axios';
const BASE_URL = 'http://localhost:3000/api/v1/chat';
async function testChat() {
console.log('π€ Testing AI Chat Endpoint\n');
const testMessages = [
{ message: "Hello!", description: "Greeting" },
{ message: "What's the prediction for Bitcoin?", description: "Prediction request" },
{ message: "Analyze the current market for ETH", description: "Analysis request" },
{ message: "Should I buy BTC now?", description: "Trading advice" },
{ message: "What's the current price of Bitcoin?", description: "Market data" },
{ message: "Help me understand what you can do", description: "Help request" }
];
for (const test of testMessages) {
try {
console.log(`π Testing: ${test.description}`);
console.log(`π¬ Message: "${test.message}"`);
const response = await axios.post(BASE_URL, {
message: test.message
});
console.log(`π€ AI Response: ${response.data.response}`);
console.log(`π― Intent: ${response.data.intent} (confidence: ${response.data.confidence})`);
console.log('β'.repeat(80) + '\n');
// Wait a bit between requests
await new Promise(resolve => setTimeout(resolve, 1000));
} catch (error) {
console.error(`β Error testing "${test.message}":`, error.response?.data || error.message);
console.log('β'.repeat(80) + '\n');
}
}
// Test chat history
try {
console.log('π Testing chat history...');
const historyResponse = await axios.get(`${BASE_URL}/history`);
console.log(`π Total messages in history: ${historyResponse.data.totalMessages}`);
console.log('β
Chat history test completed\n');
} catch (error) {
console.error('β Error getting chat history:', error.response?.data || error.message);
}
}
// Run the test
testChat().catch(console.error);