Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions app/client/platforms/deepseek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ export class DeepSeekApi implements LLMApi {
}

extractMessage(res: any) {
return res.choices?.at(0)?.message?.content ?? "";
const reasoning = res.choices?.at(0)?.message?.reasoning;
const content = res.choices?.at(0)?.message?.content ?? "";
if (reasoning) {
return `<think>\n${reasoning}\n</think>\n${content}`;
}
return content;
}

speech(options: SpeechOptions): Promise<ArrayBuffer> {
Expand Down Expand Up @@ -111,6 +116,7 @@ export class DeepSeekApi implements LLMApi {
presence_penalty: modelConfig.presence_penalty,
frequency_penalty: modelConfig.frequency_penalty,
top_p: modelConfig.top_p,
include_reasoning: true,
// 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.
};
Expand Down Expand Up @@ -158,6 +164,7 @@ export class DeepSeekApi implements LLMApi {
content: string | null;
tool_calls: ChatMessageTool[];
reasoning_content: string | null;
reasoning: string | null;
};
}>;
const tool_calls = choices[0]?.delta?.tool_calls;
Expand All @@ -179,10 +186,12 @@ export class DeepSeekApi implements LLMApi {
runTools[index]["function"]["arguments"] += args;
}
}
const reasoning = choices[0]?.delta?.reasoning_content;
const reasoning =
choices[0]?.delta?.reasoning_content ??
choices[0]?.delta?.reasoning;
const content = choices[0]?.delta?.content;

// Skip if both content and reasoning_content are empty or null
// Skip if both content and reasoning are empty or null
if (
(!reasoning || reasoning.length === 0) &&
(!content || content.length === 0)
Expand Down
13 changes: 7 additions & 6 deletions app/client/platforms/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface RequestPayload {
top_p: number;
max_tokens?: number;
max_completion_tokens?: number;
include_reasoning?: boolean;
}

export interface DalleRequestPayload {
Expand Down Expand Up @@ -200,7 +201,7 @@ export class ChatGPTApi implements LLMApi {
options.config.model.startsWith("o1") ||
options.config.model.startsWith("o3") ||
options.config.model.startsWith("o4-mini");
const isGpt5 = options.config.model.startsWith("gpt-5");
const isGpt5 = options.config.model.startsWith("gpt-5");
if (isDalle3) {
const prompt = getMessageTextContent(
options.messages.slice(-1)?.pop() as any,
Expand Down Expand Up @@ -240,10 +241,10 @@ export class ChatGPTApi implements LLMApi {
};

if (isGpt5) {
// Remove max_tokens if present
delete requestPayload.max_tokens;
// Add max_completion_tokens (or max_completion_tokens if that's what you meant)
requestPayload["max_completion_tokens"] = modelConfig.max_tokens;
// Remove max_tokens if present
delete requestPayload.max_tokens;
// Add max_completion_tokens (or max_completion_tokens if that's what you meant)
requestPayload["max_completion_tokens"] = modelConfig.max_tokens;

} else if (isO1OrO3) {
// by default the o1/o3 models will not attempt to produce output that includes markdown formatting
Expand All @@ -260,7 +261,7 @@ export class ChatGPTApi implements LLMApi {


// add max_tokens to vision model
if (visionModel && !isO1OrO3 && ! isGpt5) {
if (visionModel && !isO1OrO3 && !isGpt5) {
requestPayload["max_tokens"] = Math.max(modelConfig.max_tokens, 4000);
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ export const VISION_MODEL_REGEXES = [
/o3/,
/o4-mini/,
/grok-4/i,
/gpt-5/
/gpt-5/,
/deepseek/
];

export const EXCLUDE_VISION_MODEL_REGEXES = [/claude-3-5-haiku-20241022/];
Expand Down
Loading