fix(llm): make custom provider temperature configurable#849
Merged
Conversation
Allow custom OpenAI-compatible LLM providers to omit or override the temperature parameter instead of always sending the default 0.3. - Send temperature only when configured in OpenAI-compatible chat bodies - Keep built-in OpenAI-compatible providers on the existing 0.3 default - Store active custom LLM temperature via ark.temperature - Expose a Temperature field for custom LLM providers in Settings - Reuse the same temperature config for provider validation and real polish - Add tests for omitted/configured temperature and input validation
Contributor
PR Reviewer Guide 🔍(Review updated until commit 00d3b4c)Here are some key observations to aid the review process:
|
Contributor
|
Persistent review updated to latest commit 5df1a95 |
Contributor
|
Persistent review updated to latest commit 00d3b4c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
This PR re-submits the change from #818 to the active
betabranch.#818 was already merged, but it targeted
main. Since current development and release work is happening onbeta, this PR reapplies the same custom LLM temperature fix on top of the latestbeta.Summary
The change makes
temperatureconfigurable for custom OpenAI-compatible LLM providers.Previously, the OpenAI-compatible chat completion path always sent
temperature: 0.3. Some custom gateways or Azure/OpenAI-compatible proxies reject that field for certain models, which causes provider validation and polish requests to fail with HTTP 400.Instead of inferring this behavior from model names or provider-specific assumptions, this PR makes it explicitly configurable for custom providers.
For custom providers:
Temperatureempty omits thetemperaturefield entirely0..=2Built-in OpenAI-compatible providers keep the existing behavior and still send the default
0.3.Changes
OpenAICompatibleConfig.temperaturetoOption<f32>temperatureonly when configuredark.temperaturecredential storage for the active LLM providerTemperaturefield in Settings for custom LLM providersWhy
The original failure surfaced with a custom provider backed by an Azure OpenAI-compatible gateway:
This appears to be gateway/model-specific behavior rather than something the app should infer from model names.
Making custom provider
temperatureexplicit lets users work with gateways that require the field to be omitted, while preserving current behavior for built-in providers.PR Type
Bug fix, Enhancement
Description
Make temperature configurable for custom LLM providers
Omit temperature from API request when unset (fixes HTTP 400)
Keep default 0.3 for built-in OpenAI-compatible providers
Add UI field and credential storage for custom temperature
Diagram Walkthrough
flowchart LR A[CredentialVault::get_active_llm_temperature] --> B{provider_id == "custom"?} B -- yes --> C[openai_compatible_temperature_for_provider returns custom value or None] B -- no --> D[returns Some(DEFAULT_TEMPERATURE)] C --> E[OpenAICompatibleConfig.temperature] D --> E E --> F[chat_body: omit or include temperature field]File Walkthrough
7 files
Add ark.temperature credential accountExport temperature helper; add temperature to ProviderConfigIntegrate temperature into provider configPass temperature when building active LLM providerAdd temperature storage, parsing, and validationChange temperature to Option; add with_temperature and policy funcAdd temperature input field for custom providers5 files
Add English temperature labelsAdd Japanese temperature labelsAdd Korean temperature labelsAdd Chinese (Simplified) temperature labelsAdd Chinese (Traditional) temperature labels