-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[fix] handle OpenAI thinking parameter compatibility #40
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| from app.models.llm import Model, ModelCategoryKey, ModelSettings, Provider | ||
| from app.services.common import entity_not_found | ||
| from app.services.llm.provider_resolver import resolve_effective_base_url | ||
| from app.services.llm.provider_registry import resolve_provider_key_from_name | ||
|
|
||
|
|
||
| def _settings_model_id(settings_row: ModelSettings | None, category: ModelCategoryKey) -> str | None: | ||
|
|
@@ -178,8 +179,13 @@ def _build_chat_openai_model( | |
| kwargs.setdefault("base_url", base_url) | ||
|
|
||
| if not thinking: | ||
| extra_body = dict(kwargs.get("extra_body") or {}) | ||
| extra_body["enable_thinking"] = False | ||
| kwargs["extra_body"] = extra_body | ||
| provider_key = resolve_provider_key_from_name(provider.name) | ||
|
|
||
| if provider_key == "openai": | ||
| kwargs.setdefault("reasoning_effort", "none") | ||
|
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.
When an OpenAI model's configurable Useful? React with 👍 / 👎. |
||
| else: | ||
| extra_body = dict(kwargs.get("extra_body") or {}) | ||
| extra_body["enable_thinking"] = False | ||
| kwargs["extra_body"] = extra_body | ||
|
|
||
| return ChatOpenAI(**kwargs) | ||
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.
This adds non-obvious, provider-specific parameter behavior to
_build_chat_openai_model, but the function still has no documentation explaining what it constructs or why this compatibility branch exists; the changed sync constructor is likewise undocumented. Add synchronized function documentation for both builders so the required provider behavior and its rationale remain maintainable.AGENTS.md reference: AGENTS.md:L11-L14
Useful? React with 👍 / 👎.