-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_all.js
More file actions
64 lines (55 loc) · 2.7 KB
/
test_all.js
File metadata and controls
64 lines (55 loc) · 2.7 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
async function testModel(modelName, prompt) {
console.log(`\n\x1b[36m--- Testing [${modelName}] with STREAMING ---\x1b[0m`);
const res = await fetch('http://localhost:3000/v1/chat/completions', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: modelName,
stream: true,
messages: [{ role: "user", content: prompt }]
})
});
// Process the active event stream text chunks
const reader = res.body.getReader();
const decoder = new TextDecoder("utf-8");
// Print raw SSE chunks directly to the console so the user can verify the formatting
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunkStr = decoder.decode(value);
const lines = chunkStr.split('\n');
for (const line of lines) {
if (line.startsWith('data: ') && line !== 'data: [DONE]') {
const dataStr = line.substring(6);
try {
const data = JSON.parse(dataStr);
if (data.choices[0].delta.content) {
// Print the delta content in YELLOW so it's super visible
process.stdout.write("\x1b[33m" + data.choices[0].delta.content + "\x1b[0m");
}
} catch(e) {}
}
}
}
console.log("\n\x1b[32m--- Stream Complete ---\x1b[0m");
}
async function runAll() {
console.log("=========================================");
console.log("🧪 V3 COMPREHENSIVE PROXY TEST");
console.log("=========================================\n");
console.log("1. Fetching Proxy Models (/v1/models)...");
const modelsRes = await fetch('http://localhost:3000/v1/models');
const modelsData = await modelsRes.json();
console.log("Available Sub-Models:", modelsData.data.map(m => m.id).join(', '));
console.log("\nWAITING 2 SECONDS FOR HEADLESS PROXY BOOT...\n");
await new Promise(r => setTimeout(r, 2000));
// Test 1: Deepseek
await testModel("deepseek-web", "Write a 10-paragraph detailed essay on the comprehensive history of the Internet, from ARPANET to Web3.");
await new Promise(r => setTimeout(r, 5000));
// Test 2: ChatGPT
await testModel("chatgpt-web", "Write a 10-paragraph detailed essay on the evolution of modern architecture from the industrial revolution to today.");
await new Promise(r => setTimeout(r, 5000));
// Test 3: Claude
await testModel("claude-web", "Write a 10-paragraph detailed essay on the philosophical implications of quantum mechanics.");
}
runAll().catch(e => console.error("Test Error:", e));