-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-deepseek.js
More file actions
37 lines (32 loc) · 1.1 KB
/
Copy pathtest-deepseek.js
File metadata and controls
37 lines (32 loc) · 1.1 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
const fetch = (...args) => import('node-fetch').then(({default: f}) => f(...args));
const DEEPSEEK_API_KEY = 'sk-e789f2f01936430b843d08ea81c13c6d';
const DEEPSEEK_API_URL = 'https://api.deepseek.com/chat/completions';
async function testDeepSeekAPI() {
try {
const response = await fetch(DEEPSEEK_API_URL, {
method: 'POST',
headers: {
'Authorization': `Bearer ${DEEPSEEK_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'deepseek-chat',
messages: [
{ role: 'system', content: 'You are a helpful assistant for Nigerian constitutional and legal rights.' },
{ role: 'user', content: 'What are my rights as a Nigerian citizen?' }
],
temperature: 0.7
})
});
if (!response.ok) {
const errorData = await response.json();
console.error('API Error:', errorData);
return;
}
const data = await response.json();
console.log('Response:', data.choices[0].message.content);
} catch (error) {
console.error('Error:', error.message);
}
}
testDeepSeekAPI();