-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-agent.js
More file actions
47 lines (40 loc) · 1.29 KB
/
test-agent.js
File metadata and controls
47 lines (40 loc) · 1.29 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
// Simple test to verify the agent is working
// Run this with: node test-agent.js
async function testAgent() {
try {
console.log('🧪 Testing Aelys Agent...');
const response = await fetch('http://localhost:3000/api/agent', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: 'What is an NFT?',
history: []
})
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log('✅ Agent Response:');
console.log('Answer:', data.answer);
console.log('Metadata:', data.metadata);
} catch (error) {
console.error('❌ Test failed:', error.message);
}
}
// If running Node.js 18+ or with node --experimental-fetch
if (typeof fetch === 'undefined') {
console.log('❌ This test requires Node.js 18+ or a fetch polyfill');
console.log('Run the app with `npm run dev` and test in browser console instead:');
console.log(`
fetch('/api/agent', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: 'What is an NFT?', history: [] })
}).then(r => r.json()).then(console.log)
`);
} else {
testAgent();
}