From 36836ad4d689a12e253dccdfb27eb505c0dc3978 Mon Sep 17 00:00:00 2001 From: k-inoway <40589931+k-inoway@users.noreply.github.com> Date: Thu, 13 Mar 2025 03:33:12 +0900 Subject: [PATCH] Fix temperature param for o3mini and o1mini when using LiteLLM (#2203) * fix: prevent invalid temperature 0 param when using o3mini model * fix: handle temperature param properly for o1-mini and o3-mini models --- src/api/providers/litellm.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/api/providers/litellm.ts b/src/api/providers/litellm.ts index 2e69c438..be17f8b9 100644 --- a/src/api/providers/litellm.ts +++ b/src/api/providers/litellm.ts @@ -23,11 +23,18 @@ export class LiteLlmHandler implements ApiHandler { role: "system", content: systemPrompt, } + const modelId = this.options.liteLlmModelId || liteLlmDefaultModelId + const isOminiModel = modelId.includes("o1-mini") || modelId.includes("o3-mini") + let temperature: number | undefined = 0 + + if (isOminiModel) { + temperature = undefined // does not support temperature + } const stream = await this.client.chat.completions.create({ model: this.options.liteLlmModelId || liteLlmDefaultModelId, messages: [systemMessage, ...formattedMessages], - temperature: 0, + temperature, stream: true, stream_options: { include_usage: true }, })