Files
teknium1 130284fdcd fix(providers): declare catalog-only aliases on their plugin profiles
Same class as minimax-portal: aliyun, deep-seek, nim/build-nvidia/nemotron
and vertexai resolve in hermes_cli's alias tables but not in
providers.get_provider_profile(), so a profile lookup keyed on the alias
returned None and lost the profile's wire mode/extra_body/headers. qwen is
left out: the catalog maps it to alibaba while the qwen-oauth plugin already
claims it, a pre-existing disagreement outside this fix.
2026-09-13 12:52:43 -07:00

35 lines
1.4 KiB
Python

"""NVIDIA NIM provider profile."""
from typing import Any
from providers import register_provider
from providers.base import ProviderProfile
class NvidiaProviderProfile(ProviderProfile):
"""NVIDIA NIM accepts a stricter ToolMessage schema than most OpenAI-compatible APIs."""
@staticmethod
def _needs_strip(msg: Any) -> bool:
return isinstance(msg, dict) and msg.get("role") == "tool" and ("name" in msg or "tool_name" in msg)
def prepare_messages(self, messages: list[dict[str, Any]]) -> list[dict[str, Any]]:
"""Copy-on-write: only tool messages that lose a field are copied
(no deep copy of large tool outputs); untouched input returned as-is."""
if not any(self._needs_strip(msg) for msg in messages):
return messages
return [
{k: v for k, v in msg.items() if k not in ("name", "tool_name")} if self._needs_strip(msg) else msg
for msg in messages
]
nvidia = NvidiaProviderProfile(
name="nvidia", aliases=("nvidia-nim", "nim", "build-nvidia", "nemotron"), env_vars=("NVIDIA_API_KEY",), display_name="NVIDIA NIM",
description="NVIDIA NIM — accelerated inference", signup_url="https://build.nvidia.com/",
fallback_models=("nvidia/llama-3.1-nemotron-70b-instruct", "nvidia/llama-3.3-70b-instruct"),
base_url="https://integrate.api.nvidia.com/v1", default_max_tokens=16384,
)
register_provider(nvidia)