fix: trim DeepInfra reasoning salvage to the invariant and document it
Follow-up to the cherry-picked #111876 (@KoNit-K), which shares the design of the earlier #111875 by the issue author (@ats3v): emit DeepInfra's top-level ``reasoning_effort`` from the provider profile, ungated on ``supports_reasoning``, ``none`` as the only off switch, ``xhigh`` native, ``ultra`` clamped to ``max`` via the shared vocabulary, unset/unknown omitted. - drop the constructor/blank-line reformat churn (byte-identical to main) - replace the 14-case test file with two invariant tests: the profile's config -> top-level field table, and the transport main-turn path with ``supports_reasoning=False`` (the gate the core allowlist actually passes) - docs: DeepInfra subsection in integrations/providers.md describing the two-directional reasoning control Offline kwargs probe: before every reasoning_config -> ({}, {}) and the main turn carried no reasoning field; after ``high`` -> ``reasoning_effort: high``, ``{'enabled': False}`` -> ``none``, ``ultra`` -> ``max``, unset and unknown levels omitted, aux calls stop emitting the generic ``extra_body.reasoning`` for this provider. Co-authored-by: Georgi Atsev <georgi@deepinfra.com>
This commit is contained in:
@@ -3,11 +3,7 @@ their own plugin subsystems)."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from agent.reasoning_effort import (
|
||||
OPENAI_COMPAT_WIRE_EFFORTS,
|
||||
clamp_effort,
|
||||
requested_effort,
|
||||
)
|
||||
from agent.reasoning_effort import OPENAI_COMPAT_WIRE_EFFORTS, clamp_effort, requested_effort
|
||||
from providers import register_provider
|
||||
from providers.base import ProviderProfile
|
||||
|
||||
@@ -19,25 +15,19 @@ class _DeepInfraProfile(ProviderProfile):
|
||||
def build_api_kwargs_extras(
|
||||
self, *, reasoning_config: dict | None = None, **context: Any
|
||||
) -> tuple[dict[str, Any], dict[str, Any]]:
|
||||
"""Map Hermes reasoning controls to DeepInfra's top-level wire field.
|
||||
"""Map Hermes reasoning controls to DeepInfra's top-level ``reasoning_effort``.
|
||||
|
||||
DeepInfra applies a per-model default when the field is absent, while
|
||||
``none`` is its explicit off switch. This route does not advertise a
|
||||
reasoning capability to the shared transport, so it must not be gated
|
||||
on ``supports_reasoning``.
|
||||
DeepInfra applies a per-model default when the field is absent (DeepSeek-V4.x off,
|
||||
GLM/Qwen-Thinking on), so ``none`` is the only working off switch and an unset effort
|
||||
is omitted rather than guessed. The core ``_supports_reasoning_extra_body`` allowlist
|
||||
does not know this host, so the transport always passes ``supports_reasoning=False``
|
||||
here — gating on it would make the method a permanent no-op (#111872).
|
||||
"""
|
||||
if (
|
||||
isinstance(reasoning_config, dict)
|
||||
and reasoning_config.get("enabled") is False
|
||||
):
|
||||
if isinstance(reasoning_config, dict) and reasoning_config.get("enabled") is False:
|
||||
return {}, {"reasoning_effort": "none"}
|
||||
effort = requested_effort(reasoning_config)
|
||||
clamped = clamp_effort(effort, OPENAI_COMPAT_WIRE_EFFORTS)
|
||||
return (
|
||||
({}, {"reasoning_effort": clamped})
|
||||
if clamped in OPENAI_COMPAT_WIRE_EFFORTS
|
||||
else ({}, {})
|
||||
)
|
||||
return ({}, {"reasoning_effort": clamped}) if clamped in OPENAI_COMPAT_WIRE_EFFORTS else ({}, {})
|
||||
|
||||
def default_vision_model(self): # type: ignore[override]
|
||||
"""First vision-capable *chat* model from the live catalog, or None. Key-gated so a box
|
||||
@@ -49,7 +39,6 @@ class _DeepInfraProfile(ProviderProfile):
|
||||
return None
|
||||
try:
|
||||
from hermes_cli.models import _fetch_deepinfra_models_by_tag
|
||||
|
||||
items = _fetch_deepinfra_models_by_tag("chat")
|
||||
except Exception:
|
||||
return None
|
||||
@@ -62,13 +51,9 @@ class _DeepInfraProfile(ProviderProfile):
|
||||
|
||||
|
||||
deepinfra = _DeepInfraProfile(
|
||||
name="deepinfra",
|
||||
aliases=("deep-infra", "deepinfra-ai"),
|
||||
display_name="DeepInfra",
|
||||
description="DeepInfra — 100+ open models, pay-per-use",
|
||||
signup_url="https://deepinfra.com/dash/api_keys",
|
||||
env_vars=("DEEPINFRA_API_KEY", "DEEPINFRA_BASE_URL"),
|
||||
base_url="https://api.deepinfra.com/v1/openai",
|
||||
name="deepinfra", aliases=("deep-infra", "deepinfra-ai"), display_name="DeepInfra",
|
||||
description="DeepInfra — 100+ open models, pay-per-use", signup_url="https://deepinfra.com/dash/api_keys",
|
||||
env_vars=("DEEPINFRA_API_KEY", "DEEPINFRA_BASE_URL"), base_url="https://api.deepinfra.com/v1/openai",
|
||||
auth_type="api_key",
|
||||
default_max_tokens=None, # DeepInfra applies its documented per-model limit
|
||||
# The only hardcoded DeepInfra model: aux resolution is synchronous, so it
|
||||
|
||||
Reference in New Issue
Block a user