refactor: use includes() for DeepSeek V3.1 Terminus model check to support variants

This commit is contained in:
Roo Code 2025-11-08 18:34:01 +00:00
parent ddfccde098
commit b7bb92f53f
2 changed files with 50 additions and 1 deletions

View file

@ -62,6 +62,17 @@ vitest.mock("../fetchers/modelCache", () => ({
supportsReasoningEffort: true,
supportedReasoningEfforts: ["low", "medium", "high"],
},
"deepseek/deepseek-v3.1-terminus:exacto": {
maxTokens: 8192,
contextWindow: 128000,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 0.3,
outputPrice: 1.2,
description: "DeepSeek V3.1 Terminus Exacto",
supportsReasoningEffort: true,
supportedReasoningEfforts: ["low", "medium", "high"],
},
})
}),
}))
@ -480,5 +491,43 @@ describe("OpenRouterHandler", () => {
}),
)
})
it("should handle DeepSeek V3.1 Terminus exacto variant with chat_template_kwargs", async () => {
const handler = new OpenRouterHandler({
openRouterApiKey: "test-key",
openRouterModelId: "deepseek/deepseek-v3.1-terminus:exacto",
reasoningEffort: "medium",
})
const mockStream = {
async *[Symbol.asyncIterator]() {
yield {
id: "test-id",
choices: [{ delta: { content: "test response" } }],
}
},
}
const mockCreate = vitest.fn().mockResolvedValue(mockStream)
;(OpenAI as any).prototype.chat = {
completions: { create: mockCreate },
} as any
await handler.createMessage("test", []).next()
// Should include chat_template_kwargs with thinking:true for exacto variant
expect(mockCreate).toHaveBeenCalledWith(
expect.objectContaining({
model: "deepseek/deepseek-v3.1-terminus:exacto",
chat_template_kwargs: { thinking: true },
}),
)
// Ensure reasoning parameter is NOT included
expect(mockCreate).not.toHaveBeenCalledWith(
expect.objectContaining({
reasoning: expect.anything(),
}),
)
})
})
})

View file

@ -113,7 +113,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
chatTemplateKwargs: { thinking?: boolean } | undefined
finalReasoning: OpenRouterReasoningParams | undefined
} {
if (!modelId.startsWith("deepseek/deepseek-v3.1-terminus")) {
if (!modelId.includes("deepseek-v3.1-terminus")) {
return { chatTemplateKwargs: undefined, finalReasoning: reasoning }
}