-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-agent-execution.js
More file actions
152 lines (129 loc) · 4.61 KB
/
test-agent-execution.js
File metadata and controls
152 lines (129 loc) · 4.61 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/**
* Test OnDemand.io agent execution
*/
const config = {
organizationId: '696e5c1c994f1554f9f957fa',
agentId: '696ae690c7d6dfdf7e337e7e'
};
async function testAgentExecution() {
console.log('Testing OnDemand.io agent execution...');
// Test different execution patterns
const executeEndpoints = [
`https://app.on-demand.io/api/agents/${config.agentId}/execute`,
`https://app.on-demand.io/api/v1/agents/${config.agentId}/execute`,
`https://app.on-demand.io/agents/${config.agentId}/execute`,
`https://app.on-demand.io/api/agents/${config.agentId}/run`,
`https://app.on-demand.io/api/agents/${config.agentId}/invoke`,
`https://app.on-demand.io/rag-agents/${config.agentId}/execute`
];
const testInputs = [
// Simple test
{
input: "test video analysis",
perspectives_requested: 1
},
// Video analysis format
{
video_data: "test_video_data",
filename: "test.mp4",
perspectives_requested: 3,
analysis_type: "deepfake_detection_perspectives"
},
// Minimal format
{
prompt: "Analyze this video for deepfake detection from 3 perspectives",
data: "test_data"
}
];
for (const endpoint of executeEndpoints) {
console.log(`\n🔍 Testing endpoint: ${endpoint}`);
for (let i = 0; i < testInputs.length; i++) {
const testInput = testInputs[i];
console.log(` Input format ${i + 1}:`, JSON.stringify(testInput, null, 2));
try {
const headers = {
'X-Organization-ID': config.organizationId,
'Organization-ID': config.organizationId,
'Content-Type': 'application/json'
};
const response = await fetch(endpoint, {
method: 'POST',
headers,
body: JSON.stringify(testInput)
});
console.log(` Status: ${response.status} ${response.statusText}`);
if (response.ok) {
const data = await response.text();
console.log(' ✅ SUCCESS! Response:', data.substring(0, 300) + '...');
return {
endpoint,
success: true,
inputFormat: testInput,
response: data
};
} else if (response.status === 400) {
const errorData = await response.text();
console.log(' 🟡 Bad Request (endpoint exists):', errorData.substring(0, 200));
} else if (response.status === 401 || response.status === 403) {
console.log(' 🔐 Authentication issue');
} else if (response.status === 404) {
console.log(' ❌ Not found');
} else {
const errorData = await response.text();
console.log(` ❌ Error: ${response.status}`, errorData.substring(0, 200));
}
} catch (error) {
console.log(' ❌ Network Error:', error.message);
}
}
}
console.log('\n❌ No successful agent execution found');
return { success: false };
}
// Also test getting agent info
async function testAgentInfo() {
console.log('\n🔍 Testing agent info endpoints...');
const infoEndpoints = [
`https://app.on-demand.io/api/agents/${config.agentId}`,
`https://app.on-demand.io/agents/${config.agentId}`,
`https://app.on-demand.io/rag-agents/${config.agentId}`
];
for (const endpoint of infoEndpoints) {
try {
console.log(`Testing: ${endpoint}`);
const headers = {
'X-Organization-ID': config.organizationId,
'Organization-ID': config.organizationId
};
const response = await fetch(endpoint, {
method: 'GET',
headers
});
console.log(`Status: ${response.status} ${response.statusText}`);
if (response.ok) {
const data = await response.text();
console.log('✅ Agent info found:', data.substring(0, 300) + '...');
return { endpoint, success: true, data };
}
} catch (error) {
console.log('❌ Error:', error.message);
}
}
}
// Run tests
async function runAllTests() {
console.log('=== OnDemand.io Agent Testing ===\n');
const agentInfo = await testAgentInfo();
const execution = await testAgentExecution();
console.log('\n=== FINAL RESULTS ===');
console.log('Agent Info:', agentInfo);
console.log('Agent Execution:', execution);
if (execution.success) {
console.log('\n🎉 SUCCESS! We can execute OnDemand agents!');
console.log('Working endpoint:', execution.endpoint);
console.log('Working input format:', execution.inputFormat);
} else {
console.log('\n⚠️ Could not execute agents. May need different authentication or input format.');
}
}
runAllTests().catch(console.error);