feat(providers): add extra_query config for OpenAI-compatible providers

Adds ProviderConfig.extra_query, threaded into AsyncOpenAI(default_query)
so that Azure-style gateways requiring query params like api-version can
be configured without URL hacks.

Also updates provider_signature to track extra_query changes so per-turn
refresh rebuilds the provider when the value changes.

Addresses the extra_query portion of #4204. The max_completion_tokens
model-awareness enhancement is intentionally left separate.
This commit is contained in:
axelray-dev
2026-06-09 03:18:14 +08:00
committed by Xubin Ren
parent 9c81280300
commit 28f3a20d64
5 changed files with 109 additions and 1 deletions
@@ -331,6 +331,7 @@ class OpenAICompatProvider(LLMProvider):
spec: ProviderSpec | None = None,
extra_body: dict[str, Any] | None = None,
api_type: str = "auto",
extra_query: dict[str, str] | None = None,
):
super().__init__(api_key, api_base)
self.default_model = default_model
@@ -338,6 +339,7 @@ class OpenAICompatProvider(LLMProvider):
self._spec = spec
self._extra_body = extra_body or {}
self._api_type = api_type if spec and spec.name == "openai" else "auto"
self._extra_query = extra_query or {}
if api_key and spec and spec.env_key:
self._setup_env(api_key, api_base)
@@ -386,6 +388,7 @@ class OpenAICompatProvider(LLMProvider):
api_key=self._api_key_for_client,
base_url=self._effective_base,
default_headers=self._default_headers,
default_query=self._extra_query or None,
max_retries=0,
timeout=timeout_s,
http_client=http_client,