-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-chat-issue.js
More file actions
94 lines (79 loc) · 2.34 KB
/
debug-chat-issue.js
File metadata and controls
94 lines (79 loc) · 2.34 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Debug Chat Interface Issue
* Simple test to isolate the problem
*/
require('dotenv').config({ path: '.env.local' });
const APP_URL = 'https://codeex-ai.netlify.app';
async function testSimpleMessage() {
console.log('🔍 Testing simple message with auto model...');
try {
const response = await fetch(`${APP_URL}/api/test-chat`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
},
credentials: 'same-origin',
body: JSON.stringify({
message: "Hello",
history: [],
settings: {
model: 'auto',
tone: 'helpful',
technicalLevel: 'intermediate',
enableSpeech: false,
voice: 'Algenib'
}
})
});
const data = await response.json();
console.log('Response:', data);
if (data.error) {
console.error('❌ Error:', data.error);
} else {
console.log('✅ Success!');
console.log('Content:', data.content);
console.log('Model Used:', data.modelUsed);
}
} catch (error) {
console.error('❌ Request failed:', error.message);
}
}
// Test the smart fallback system directly
async function testSmartFallback() {
console.log('🔍 Testing smart fallback system...');
try {
const response = await fetch(`${APP_URL}/api/ai/solve`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
},
credentials: 'same-origin',
body: JSON.stringify({
problem: "What is 2 + 2?",
tone: 'helpful',
technicalLevel: 'beginner',
preferredModel: 'auto'
})
});
const data = await response.json();
console.log('Solve API Response:', data);
if (data.error) {
console.error('❌ Solve API Error:', data.error);
} else {
console.log('✅ Solve API Success!');
console.log('Solution:', data.solution?.substring(0, 100));
console.log('Model Used:', data.modelUsed);
}
} catch (error) {
console.error('❌ Solve API Request failed:', error.message);
}
}
async function main() {
console.log('🚀 Debugging Chat Interface Issue...\n');
await testSimpleMessage();
console.log('\n' + '='.repeat(50) + '\n');
await testSmartFallback();
}
main();