fix(llm): stop sending DashScope-only enable_thinking to official OpenAI - #39
Open
Voyagerroc-Lab wants to merge 1 commit into
Open
Voyagerroc-Lab wants to merge 1 commit into
Voyagerroc-Lab wants to merge 1 commit into
Conversation
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 #38
What was wrong
thinking=Falsepaths injectedextra_body["enable_thinking"] = Falseunconditionally.enable_thinkingis a DashScope/Qwen extension — the official OpenAI API rejects it with400 Bad Request: Unknown parameter: 'enable_thinking', so every storyboard/dialogue extraction run againstapi.openai.comfailed (as reproduced in the issue, where the reporter also verified that switching toreasoning_effort="none"unblocks the official endpoint).The same unconditional bind also existed in
AgentBase.__init__, so every agent sentenable_thinkingto the official API regardless of its value.What changed
Three call sites now branch on the target endpoint:
backend/app/services/llm/resolver.py(_build_chat_openai_model)backend/app/services/llm/runtime.py(build_default_text_llm_sync)api.openai.com, or no custom base_url) →kwargs.setdefault("reasoning_effort", "none")extra_body["enable_thinking"] = Falsebackend/app/chains/agents/base.py(AgentBase.__init__) — the unconditionalself._model.bind(extra_body={"enable_thinking": ...})is replaced by_thinking_extra_body(model, self.enable_thinking), which returnsNone(nothing bound) for official-OpenAI targets and the previous body for compatible endpoints, using the model'sopenai_api_base.setdefaultkeeps any user-configuredreasoning_effortfrommodel.paramsintact.How did you verify?
python -m py_compilepasses for all three touched files.api.openai.com): noenable_thinkingkey reaches the wire;reasoning_effort="none"is sent only when the caller did not set one.中文摘要:
enable_thinking是 DashScope 扩展参数,官方 OpenAI API 会返回 400。现在三个调用点都会按端点区分:官方 OpenAI 使用reasoning_effort="none",DashScope 兼容端点保持原有enable_thinking行为。