feat: 更新调用grok接口
This commit is contained in:
parent
8cd2cca57a
commit
4aee7f9ffb
2
.env
2
.env
|
|
@ -20,4 +20,4 @@ SILICONFLOW_API_KEY=sk-ojmkkuyrfigcmdlijbirbjaqmuwhhfsddcqdvpvayspqrupc
|
|||
DEEPSEEK_API_KEY=sk-e8941dc2bf1d4d099001b161db6f4317
|
||||
|
||||
# Grok
|
||||
GROK_API_KEY=xai-hKcnlbz5N2AWSdWYvV29G7iBmiI8FFU3lQLDG25Xw6BGjjhkYGGqPSSjiaxnAySViM3AYiYTeJwFFjJK
|
||||
GROK_API_KEY=lichao1314
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
export const PROVIDER_TYPE = {
|
||||
Deep: {
|
||||
name: 'Deep',
|
||||
baseUrl: 'https://api.deepseek.com/chat/completions',
|
||||
baseUrl: 'https://api.deepseek.com',
|
||||
model: 'deepseek-chat',
|
||||
},
|
||||
Flow: {
|
||||
name: 'Flow',
|
||||
baseUrl: 'https://api.siliconflow.cn/v1/chat/completions',
|
||||
baseUrl: 'https://api.siliconflow.cn',
|
||||
model: 'deepseek-ai/DeepSeek-V3',
|
||||
},
|
||||
Grok: {
|
||||
name: 'Grok',
|
||||
baseUrl: 'https://api.x.ai/v1/chat/completions',
|
||||
model: 'grok-2-latest',
|
||||
baseUrl: 'http://141.98.197.39:8000',
|
||||
model: 'grok-4.20-beta',
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,10 +14,14 @@ export class DeepseekService {
|
|||
|
||||
const apiKey = apiKeys[provider];
|
||||
|
||||
// 使用 OpenAI 接口规范
|
||||
const endpoint = `${baseUrl}/v1/chat/completions`;
|
||||
|
||||
try {
|
||||
const response = await axios.post(
|
||||
baseUrl,
|
||||
endpoint,
|
||||
{
|
||||
model,
|
||||
messages: [
|
||||
{
|
||||
role: 'system',
|
||||
|
|
@ -34,18 +38,19 @@ export class DeepseekService {
|
|||
content: message,
|
||||
},
|
||||
],
|
||||
model,
|
||||
stream: false,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${apiKey}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue