-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-agent.js
More file actions
46 lines (37 loc) · 958 Bytes
/
Copy pathtest-agent.js
File metadata and controls
46 lines (37 loc) · 958 Bytes
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
const http = require('http');
const data = JSON.stringify({
prompt: "Can I bring my service dog to the library?"
});
const options = {
hostname: 'localhost',
port: 8000,
path: '/api/query',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
};
console.log('Testing agent with query: "Can I bring my service dog to the library?"\n');
const req = http.request(options, (res) => {
console.log(`Status: ${res.statusCode}\n`);
let buffer = '';
res.on('data', (chunk) => {
buffer += chunk.toString();
// Print as we receive data
process.stdout.write(chunk.toString());
});
res.on('end', () => {
console.log('\n\nStream ended.');
});
});
req.on('error', (error) => {
console.error('Request error:', error);
});
req.write(data);
req.end();
// Timeout after 2 minutes
setTimeout(() => {
console.log('\n\nTimeout - ending test');
process.exit(0);
}, 120000);