-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-gpt35.html
More file actions
82 lines (78 loc) · 3.68 KB
/
test-gpt35.html
File metadata and controls
82 lines (78 loc) · 3.68 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
<!DOCTYPE html>
<html>
<head>
<title>Test GPT-3.5 Turbo</title>
</head>
<body>
<h1>Test GPT-3.5 Turbo</h1>
<button onclick="testGPT35()">Test GPT-3.5 Turbo</button>
<div id="result"></div>
<script>
async function testGPT35() {
const result = document.getElementById('result');
result.innerHTML = 'Testing GPT-3.5 Turbo...';
try {
const response = await fetch('https://openrouter.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer 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',
'Content-Type': 'application/json',
'HTTP-Referer': 'https://localhost:5173',
'X-Title': 'Chatbot Test'
},
body: JSON.stringify({
model: "openai/gpt-3.5-turbo",
messages: [
{
role: "system",
content: "You are a helpful AI assistant. Be concise and friendly in your responses."
},
{
role: "user",
content: "Hello! Say hi back in one sentence."
}
],
max_tokens: 150,
temperature: 0.7
})
});
const data = await response.json();
console.log('GPT-3.5 response:', data);
if (response.ok && data.choices && data.choices[0]) {
result.innerHTML = `
<div style="color: green; border: 2px solid green; padding: 20px; margin: 10px 0;">
<h3>🎉 GPT-3.5 TURBO WORKS!</h3>
<p><strong>Response:</strong> ${data.choices[0].message.content}</p>
<p><strong>Model:</strong> ${data.model}</p>
<p><strong>Usage:</strong> ${JSON.stringify(data.usage || 'No usage info')}</p>
<div style="background: #f0f8f0; padding: 10px; margin: 10px 0;">
<strong>✅ Your chatbot should now work with GPT-3.5 Turbo!</strong><br>
<strong>Next step:</strong> Update your n8n workflow and test your chatbot.
</div>
</div>
`;
} else {
result.innerHTML = `
<div style="color: red; border: 2px solid red; padding: 20px; margin: 10px 0;">
<h3>❌ GPT-3.5 TURBO FAILED</h3>
<p><strong>Status:</strong> ${response.status}</p>
<p><strong>Error:</strong> ${data.error?.message || JSON.stringify(data)}</p>
<details>
<summary>Full Error Response</summary>
<pre>${JSON.stringify(data, null, 2)}</pre>
</details>
</div>
`;
}
} catch (error) {
result.innerHTML = `
<div style="color: red; border: 2px solid red; padding: 20px; margin: 10px 0;">
<h3>❌ REQUEST FAILED</h3>
<p>${error.message}</p>
</div>
`;
}
}
</script>
</body>
</html>