Skip to content

Commit

Permalink
feat: Add DeepSeek summarize model and expand DeepSeek model support
Browse files Browse the repository at this point in the history
- Added `DEEPSEEK_SUMMARIZE_MODEL` constant for DeepSeek summarization
- Updated `getSummarizeModel` to support DeepSeek models
- Expanded DeepSeek models list to include "deepseek-reasoner"
- Simplified DeepSeek API payload construction by removing conditional temperature logic
  • Loading branch information
kiritoko1029 committed Jan 24, 2025
1 parent 207262c commit 464be71
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
4 changes: 1 addition & 3 deletions app/client/platforms/deepseek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,13 @@ export class DeepSeekApi implements LLMApi {
messages,
stream: options.config.stream,
model: modelConfig.model,
temperature: modelConfig.temperature,
presence_penalty: modelConfig.presence_penalty,
frequency_penalty: modelConfig.frequency_penalty,
top_p: modelConfig.top_p,
// max_tokens: Math.max(modelConfig.max_tokens, 1024),
// Please do not ask me why not send max_tokens, no reason, this param is just shit, I dont want to explain anymore.
};
if (modelConfig.model === "deepseek-reasoner") {
requestPayload.temperature = modelConfig.temperature;
}
console.log("[Request] openai payload: ", requestPayload);

const shouldStream = !!options.config.stream;
Expand Down
29 changes: 9 additions & 20 deletions app/client/platforms/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export interface RequestPayload {
}[];
stream?: boolean;
model: string;
temperature?: number;
presence_penalty?: number;
frequency_penalty?: number;
top_p?: number;
temperature: number;
presence_penalty: number;
frequency_penalty: number;
top_p: number;
max_tokens?: number;
max_completion_tokens?: number;
}
Expand Down Expand Up @@ -196,8 +196,6 @@ export class ChatGPTApi implements LLMApi {

const isDalle3 = _isDalle3(options.config.model);
const isO1 = options.config.model.startsWith("o1");
const isDeepseekReasoner =
options.config.model.startsWith("deepseek-reasoner");
if (isDalle3) {
const prompt = getMessageTextContent(
options.messages.slice(-1)?.pop() as any,
Expand Down Expand Up @@ -228,25 +226,16 @@ export class ChatGPTApi implements LLMApi {
messages,
stream: options.config.stream,
model: modelConfig.model,
temperature:
!isO1 && !isDeepseekReasoner ? modelConfig.temperature : undefined,
presence_penalty: !isDeepseekReasoner
? isO1
? 0
: modelConfig.presence_penalty
: undefined,
frequency_penalty: !isDeepseekReasoner
? isO1
? 0
: modelConfig.frequency_penalty
: undefined,
top_p: !isDeepseekReasoner ? (isO1 ? 1 : modelConfig.top_p) : undefined,
temperature: !isO1 ? modelConfig.temperature : 1,
presence_penalty: !isO1 ? modelConfig.presence_penalty : 0,
frequency_penalty: !isO1 ? modelConfig.frequency_penalty : 0,
top_p: !isO1 ? modelConfig.top_p : 1,
// max_tokens: Math.max(modelConfig.max_tokens, 1024),
// Please do not ask me why not send max_tokens, no reason, this param is just shit, I dont want to explain anymore.
};

// O1 使用 max_completion_tokens 控制token数
if (isO1 || isDeepseekReasoner) {
if (isO1) {
requestPayload["max_completion_tokens"] = modelConfig.max_tokens;
}

Expand Down
5 changes: 3 additions & 2 deletions app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ You are an AI assistant with access to system tools. Your role is to help users
- Use markdown code blocks with format: \`\`\`json:mcp:{clientId}\`\`\`
- Always include:
* method: "tools/call"(Only this method is supported)
* params:
* params:
- name: must match an available primitive name
- arguments: required parameters for the primitive
Expand Down Expand Up @@ -393,6 +393,7 @@ You are an AI assistant with access to system tools. Your role is to help users

export const SUMMARIZE_MODEL = "gpt-4o-mini";
export const GEMINI_SUMMARIZE_MODEL = "gemini-pro";
export const DEEPSEEK_SUMMARIZE_MODEL = "deepseek-chat";

export const KnowledgeCutOffDate: Record<string, string> = {
default: "2021-09",
Expand Down Expand Up @@ -563,7 +564,7 @@ const iflytekModels = [
"4.0Ultra",
];

const deepseekModels = ["deepseek-chat", "deepseek-coder"];
const deepseekModels = ["deepseek-chat", "deepseek-coder", "deepseek-reasoner"];

const xAIModes = ["grok-beta"];

Expand Down
3 changes: 3 additions & 0 deletions app/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
DEFAULT_MODELS,
DEFAULT_SYSTEM_TEMPLATE,
GEMINI_SUMMARIZE_MODEL,
DEEPSEEK_SUMMARIZE_MODEL,
KnowledgeCutOffDate,
MCP_SYSTEM_TEMPLATE,
MCP_TOOLS_TEMPLATE,
Expand Down Expand Up @@ -143,6 +144,8 @@ function getSummarizeModel(
}
if (currentModel.startsWith("gemini")) {
return [GEMINI_SUMMARIZE_MODEL, ServiceProvider.Google];
} else if (currentModel.startsWith("deepseek-")) {
return [DEEPSEEK_SUMMARIZE_MODEL, ServiceProvider.DeepSeek];
}
return [currentModel, providerName];
}
Expand Down

0 comments on commit 464be71

Please sign in to comment.