-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-claude.js
More file actions
33 lines (28 loc) · 859 Bytes
/
test-claude.js
File metadata and controls
33 lines (28 loc) · 859 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
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
async function testCodeGeneration() {
const prompt = "Write a Python function to calculate the factorial of a number.";
const language = "python";
const provider = "claude";
try {
const response = await fetch('http://localhost:3000/api/ai/code', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt,
language,
provider,
options: {},
}),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log("Generated code:", data.code);
} catch (error) {
console.error("Error testing code generation:", error);
}
}
testCodeGeneration();