-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_brain.js
More file actions
38 lines (32 loc) · 1.05 KB
/
test_brain.js
File metadata and controls
38 lines (32 loc) · 1.05 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
const fetch = require('node-fetch');
async function testApi() {
const apiKey = "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";
const baseUrl = "https://integrate.api.nvidia.com/v1";
const modelId = "minimaxai/minimax-m2.7";
console.log("Testing ChromeCode Brain (NVIDIA API)...");
try {
const response = await fetch(`${baseUrl}/chat/completions`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${apiKey}`
},
body: JSON.stringify({
model: modelId,
messages: [{ role: "user", content: "Hello ChromeCode! Who are you?" }],
max_tokens: 50
})
});
if (!response.ok) {
const err = await response.text();
console.error("API Error:", err);
return;
}
const json = await response.json();
console.log("Response from NVIDIA:", json.choices[0].message.content);
console.log("Test PASSED! The brain is working.");
} catch (err) {
console.error("Fetch Error:", err);
}
}
testApi();