From 48c042fad69fbbbe1093d234cfbcca551c9232a9 Mon Sep 17 00:00:00 2001 From: MonesyH Date: Tue, 18 Feb 2025 16:57:03 +0800 Subject: [PATCH 1/2] Update deepseek.ts --- app/api/deepseek.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/deepseek.ts b/app/api/deepseek.ts index a9879eced..40e5753ea 100644 --- a/app/api/deepseek.ts +++ b/app/api/deepseek.ts @@ -85,7 +85,7 @@ async function request(req: NextRequest) { fetchOptions.body = clonedBody; const jsonBody = JSON.parse(clonedBody) as { model?: string }; - + console.log(jsonBody); // not undefined and is false if ( isModelNotavailableInServer( From 552437fec4faee64f7aeddef2f7090f7a799a000 Mon Sep 17 00:00:00 2001 From: MonesyH Date: Tue, 18 Feb 2025 17:13:35 +0800 Subject: [PATCH 2/2] Update deepseek.ts --- app/client/platforms/deepseek.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/app/client/platforms/deepseek.ts b/app/client/platforms/deepseek.ts index b21d24cef..9dc0ffa87 100644 --- a/app/client/platforms/deepseek.ts +++ b/app/client/platforms/deepseek.ts @@ -65,13 +65,24 @@ export class DeepSeekApi implements LLMApi { async chat(options: ChatOptions) { const messages: ChatOptions["messages"] = []; - for (const v of options.messages) { - if (v.role === "assistant") { - const content = getMessageTextContentWithoutThinking(v); - messages.push({ role: v.role, content }); - } else { - const content = getMessageTextContent(v); - messages.push({ role: v.role, content }); + if (options.config.model === "deepseek-reasoner") { + // Only take the last message + const lastMessage = options.messages[options.messages.length - 1]; + const content = + lastMessage.role === "assistant" + ? getMessageTextContentWithoutThinking(lastMessage) + : getMessageTextContent(lastMessage); + messages.push({ role: lastMessage.role, content }); + } else { + // Process all messages + for (const v of options.messages) { + if (v.role === "assistant") { + const content = getMessageTextContentWithoutThinking(v); + messages.push({ role: v.role, content }); + } else { + const content = getMessageTextContent(v); + messages.push({ role: v.role, content }); + } } }