The bundled Xiaomi profile lacks build_api_kwargs_extras, so reasoning_effort was parsed from config but silently dropped. This user plugin overrides the profile with the missing method. Mapping: xhigh->high, high->high, medium->medium, low->low, none->omit
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
"""Xiaomi MiMo provider profile — user override.
|
|
|
|
Extends the bundled Xiaomi profile to send ``reasoning_effort`` as a
|
|
top-level API parameter. The MiMo API accepts ``low``, ``medium``,
|
|
``high`` (``xhigh`` is clamped to ``high``).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from providers import register_provider
|
|
from providers.base import ProviderProfile
|
|
|
|
|
|
class XiaomiProfile(ProviderProfile):
|
|
"""Xiaomi MiMo — top-level reasoning_effort."""
|
|
|
|
def build_api_kwargs_extras(
|
|
self, *, reasoning_config: dict | None = None, model: str | None = None, **context
|
|
) -> tuple[dict[str, Any], dict[str, Any]]:
|
|
extra_body: dict[str, Any] = {}
|
|
top_level: dict[str, Any] = {}
|
|
|
|
if isinstance(reasoning_config, dict):
|
|
effort = (reasoning_config.get("effort") or "").strip().lower()
|
|
if effort in ("xhigh",):
|
|
top_level["reasoning_effort"] = "high"
|
|
elif effort in ("low", "medium", "high"):
|
|
top_level["reasoning_effort"] = effort
|
|
|
|
return extra_body, top_level
|
|
|
|
|
|
xiaomi = XiaomiProfile(
|
|
name="xiaomi",
|
|
aliases=("mimo", "xiaomi-mimo"),
|
|
env_vars=("XIAOMI_API_KEY",),
|
|
base_url="https://api.xiaomimimo.com/v1",
|
|
supports_health_check=False,
|
|
)
|
|
|
|
register_provider(xiaomi)
|