-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: always include temperature parameter for OpenAI compatible providers #7582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,14 +161,9 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl | |
| stream: true as const, | ||
| ...(isGrokXAI ? {} : { stream_options: { include_usage: true } }), | ||
| ...(reasoning && reasoning), | ||
| } | ||
|
|
||
| // Only include temperature if explicitly set | ||
| if (this.options.modelTemperature !== undefined) { | ||
| requestOptions.temperature = this.options.modelTemperature | ||
| } else if (deepseekReasoner) { | ||
| // DeepSeek Reasoner has a specific default temperature | ||
| requestOptions.temperature = DEEP_SEEK_DEFAULT_TEMPERATURE | ||
| // Always include temperature to prevent TabbyApi/ExLlamaV2 crashes | ||
| // Use explicitly set temperature, or DeepSeek default for reasoner models, or fall back to 0 | ||
| temperature: this.options.modelTemperature ?? (deepseekReasoner ? DEEP_SEEK_DEFAULT_TEMPERATURE : 0), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good fix for the streaming case! This ensures temperature is always included with appropriate defaults. |
||
| } | ||
|
|
||
| // Add max_tokens if needed | ||
|
|
@@ -231,6 +226,9 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl | |
| : enabledLegacyFormat | ||
| ? [systemMessage, ...convertToSimpleMessages(messages)] | ||
| : [systemMessage, ...convertToOpenAiMessages(messages)], | ||
| // Always include temperature to prevent TabbyApi/ExLlamaV2 crashes | ||
| // Use explicitly set temperature, or DeepSeek default for reasoner models, or fall back to 0 | ||
| temperature: this.options.modelTemperature ?? (deepseekReasoner ? DEEP_SEEK_DEFAULT_TEMPERATURE : 0), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent - non-streaming mode also properly includes temperature now. The fallback chain (user setting -> DeepSeek default -> 0) is well thought out. |
||
| } | ||
|
|
||
| // Add max_tokens if needed | ||
|
|
@@ -276,6 +274,8 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl | |
| const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming = { | ||
| model: model.id, | ||
| messages: [{ role: "user", content: prompt }], | ||
| // Always include temperature to prevent TabbyApi/ExLlamaV2 crashes | ||
| temperature: this.options.modelTemperature ?? 0, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch on the |
||
| } | ||
|
|
||
| // Add max_tokens if needed | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good implementation of the temperature fallback chain! The comment clearly explains why this is needed. However, I noticed the
completePromptmethod in this same file (line 117-134) still doesn't include the temperature parameter - this could still cause TabbyApi/ExLlamaV2 crashes when using the completion endpoint.