feat: support extra_body in role configuration#1491
Open
kyochou wants to merge 1 commit intosigoden:mainfrom
Open
feat: support extra_body in role configuration#1491kyochou wants to merge 1 commit intosigoden:mainfrom
kyochou wants to merge 1 commit intosigoden:mainfrom
Conversation
This adds support for passing custom parameters down to the LLM API via `extra_body` in the YAML frontmatter. Supported by OpenAI, Claude, Bedrock, VertexAI/Gemini, and Cohere.
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.
This PR adds support for a new
extra_bodyfield in the Role configuration.It allows users to send arbitrary custom parameters (such as
enable_thinking, vendor specific parameters, etc.) to the underlying LLM API by merging it into the payload just before sending the request.With the proliferation of different LLM providers branching out their models with new experimental parameters, this extra parameter solves the issue by forwarding everything inside
extra_bodydirectly to the request body using a JSON merge patch. This adds forward-compatibility for future API parameters without requiring changes to the rust client implementations.Supported syntax in Role Config YAML:
Changes:
extra_body(Option<Value>) to theRolestruct.extra_bodythroughChatCompletionsData.extra_bodyat the end of the HTTP json body payload construction forOpenAI(and compatible),Claude,Bedrock,Gemini/VertexAI, andCohere(Cohere inherits theopenai_build_chat_completions_bodymacro/function, so it works too).extra_bodyas it shouldn't be forwarded to global states implicitly unless properly synced or customized later.All tests (21/21) passing smoothly.