Skip to content

Commit

Permalink
💄 style: Add deepseek r1 model (lobehub#5520)
Browse files Browse the repository at this point in the history
* Update deepseek.ts

* Update deepseek.ts

* Update deepseek.ts

* Update index.ts

* Update index.ts

* Update index.ts
  • Loading branch information
sxjeru authored Jan 20, 2025
1 parent dc28615 commit 414477f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
16 changes: 16 additions & 0 deletions src/config/aiModels/deepseek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ const deepseekChatModels: AIChatModelCard[] = [
releasedAt: '2024-12-26',
type: 'chat',
},
{
contextWindowTokens: 65_536,
description:
'DeepSeek 推出的推理模型。在输出最终回答之前,模型会先输出一段思维链内容,以提升最终答案的准确性。',
displayName: 'DeepSeek R1',
enabled: true,
id: 'deepseek-reasoner',
pricing: {
cachedInput: 1,
currency: 'CNY',
input: 4,
output: 16,
},
releasedAt: '2025-01-20',
type: 'chat',
},
];

export const allModels = [...deepseekChatModels];
Expand Down
23 changes: 19 additions & 4 deletions src/config/modelProviders/deepseek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,29 @@ const DeepSeek: ModelProviderCard = {
enabled: true,
functionCall: true,
id: 'deepseek-chat',
pricing: {
cachedInput: 0.5,
pricing: { // 2025.2.9 之后涨价
cachedInput: 0.1,
currency: 'CNY',
input: 2,
output: 8,
input: 1,
output: 2,
},
releasedAt: '2024-12-26',
},
{
contextWindowTokens: 65_536,
description:
'DeepSeek 推出的推理模型。在输出最终回答之前,模型会先输出一段思维链内容,以提升最终答案的准确性。',
displayName: 'DeepSeek R1',
enabled: true,
id: 'deepseek-reasoner',
pricing: {
cachedInput: 1,
currency: 'CNY',
input: 4,
output: 16,
},
releasedAt: '2025-01-20',
},
],
checkModel: 'deepseek-chat',
description:
Expand Down
24 changes: 23 additions & 1 deletion src/libs/agent-runtime/deepseek/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
import { ModelProvider } from '../types';
import OpenAI from 'openai';

import { ChatStreamPayload, ModelProvider } from '../types';
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';

export const LobeDeepSeekAI = LobeOpenAICompatibleFactory({
baseURL: 'https://api.deepseek.com/v1',
chatCompletion: {
handlePayload: ({ frequency_penalty, model, presence_penalty, temperature, top_p, ...payload }: ChatStreamPayload) =>
({
...payload,
model,
...(model === 'deepseek-reasoner'
? {
frequency_penalty: undefined,
presence_penalty: undefined,
temperature: undefined,
top_p: undefined,
}
: {
frequency_penalty,
presence_penalty,
temperature,
top_p,
}),
}) as OpenAI.ChatCompletionCreateParamsStreaming,
},
debug: {
chatCompletion: () => process.env.DEBUG_DEEPSEEK_CHAT_COMPLETION === '1',
},
Expand Down

0 comments on commit 414477f

Please sign in to comment.