mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
Cycle 2 PR 1 (#14418). Introduces providers/ package with ProviderProfile ABC and auto-discovery registry, then wires ChatCompletionsTransport to delegate to profiles via a clean single-path method. Provider profiles (8 providers): - nvidia: default_max_tokens=16384 - kimi + kimi-cn: OMIT_TEMPERATURE, thinking + top-level reasoning_effort - openrouter: provider_preferences, full reasoning_config passthrough - nous: product tags, reasoning with Nous-specific disabled omission - deepseek: base_url + env_vars - qwen-oauth: vl_high_resolution extra_body, metadata top-level api_kwargs Transport integration: - _build_kwargs_from_profile() replaces the entire legacy flag-based assembly when provider_profile param is passed - Single path: no dual-execution, no overwrites, no legacy fallthrough - build_api_kwargs_extras() returns (extra_body, top_level) tuple to handle Kimi's top-level reasoning_effort vs OpenRouter's extra_body Auth types: api_key | oauth_device_code | oauth_external | copilot | aws (expanded from the lossy 'oauth' to match real Hermes auth modes). 64 new tests: - 30 profile unit tests (registry, all 8 profiles, auth types) - 19 transport parity tests (pin legacy flag-based behavior) - 15 profile wiring tests (verify profile path = legacy path)
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
"""Nous Portal provider profile."""
|
|
|
|
from typing import Any, Dict, Tuple
|
|
|
|
from providers.base import ProviderProfile
|
|
from providers import register_provider
|
|
|
|
|
|
class NousProfile(ProviderProfile):
|
|
"""Nous Portal — product tags, reasoning with Nous-specific omission."""
|
|
|
|
def build_extra_body(self, *, session_id: str = None, **context) -> Dict[str, Any]:
|
|
return {"tags": ["product=hermes-agent"]}
|
|
|
|
def build_api_kwargs_extras(self, *, reasoning_config: dict = None,
|
|
supports_reasoning: bool = False,
|
|
**context) -> Tuple[Dict[str, Any], Dict[str, Any]]:
|
|
"""Nous: passes full reasoning_config, but OMITS when disabled."""
|
|
extra_body = {}
|
|
if supports_reasoning:
|
|
if reasoning_config is not None:
|
|
rc = dict(reasoning_config)
|
|
if rc.get("enabled") is False:
|
|
pass # Nous omits reasoning when disabled
|
|
else:
|
|
extra_body["reasoning"] = rc
|
|
else:
|
|
extra_body["reasoning"] = {"enabled": True, "effort": "medium"}
|
|
return extra_body, {}
|
|
|
|
|
|
nous = NousProfile(
|
|
name="nous",
|
|
aliases=("nous-portal", "nousresearch"),
|
|
env_vars=("NOUS_API_KEY",),
|
|
base_url="https://inference-api.nousresearch.com/v1",
|
|
auth_type="oauth_device_code",
|
|
)
|
|
|
|
register_provider(nous)
|