-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick-chat-test.mjs
More file actions
48 lines (41 loc) · 1.03 KB
/
quick-chat-test.mjs
File metadata and controls
48 lines (41 loc) · 1.03 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
import http from 'http';
const projectId = '3cf4bce6-b6d0-40d4-9e09-91b60a34d4e3';
const query = 'What is a generic framework?';
const data = JSON.stringify({
projectId,
query,
conversationHistory: []
});
console.log('Sending chat request to /api/chat...');
console.log('Project ID:', projectId);
console.log('Query:', query);
const options = {
hostname: 'localhost',
port: 3000,
path: '/api/chat',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
};
const req = http.request(options, (res) => {
let body = '';
res.on('data', chunk => body += chunk);
res.on('end', () => {
console.log('\n=== Response ===');
console.log('Status:', res.statusCode);
try {
const json = JSON.parse(body);
console.log('Response JSON:');
console.log(JSON.stringify(json, null, 2));
} catch (e) {
console.log('Raw body:', body);
}
});
});
req.on('error', (e) => {
console.error('Request error:', e.message);
});
req.write(data);
req.end();