fix: skip frequency_penalty and presence_penalty for XAI grok reasoning models#399
Open
octo-patch wants to merge 1 commit into
Open
fix: skip frequency_penalty and presence_penalty for XAI grok reasoning models#399octo-patch wants to merge 1 commit into
octo-patch wants to merge 1 commit into
Conversation
…ng models (fixes coaidev#374) XAI's grok reasoning models (e.g. grok-3-mini, grok-3-mini-fast) do not support the frequency_penalty and presence_penalty parameters, and return HTTP 400 when these fields are present in the request body. Detect grok reasoning models by their name prefix ("grok-") and "-mini" suffix, and omit the two unsupported parameters from the request, matching the existing pattern for o1/o3/gpt-5 model compatibility. Co-Authored-By: Octopus <liyuan851277048@icloud.com>
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.
Fixes #374
Problem
XAI's grok reasoning models (e.g.
grok-3-mini,grok-3-mini-fast) do not support thefrequency_penaltyandpresence_penaltyparameters. When users configure an XAI channel using the OpenAI-compatible adapter and select a thinking/reasoning model, the request always includes these parameters, causing the XAI API to return HTTP 400.Solution
Detect grok reasoning models by their naming pattern (
grok-prefix +-minisubstring) and omitfrequency_penaltyandpresence_penaltyfrom the request body for these models. Since both fields are taggedomitemptyinChatRequest, setting them tonilensures they are not serialized.This follows the same pattern already used for
o1/o3/gpt-5models where unsupported parameters are conditionally excluded.Testing
gofmtandgo buildpass with no errors.GetChatBodyinadapter/openai/chat.goand only affects models matching the grok reasoning model pattern.