Files
hermes-agent/plugins/model-providers/vertex/__init__.py
T
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.7 KiB
Python

"""Google Vertex AI provider profile: Gemini via Google Cloud's OpenAI-compatible endpoint.
Auth is OAuth2 (service-account JSON or ADC), not a static key: ``agent/vertex_adapter.py``
mints ``(token, base_url)`` and the token is passed as ``api_key``. ``auth_type="vertex"``
keeps it out of the api_key provider path so a credentials-file path is never mistaken for a key.
"""
from typing import Any
from providers import register_provider
from providers.base import ProviderProfile
class VertexProfile(ProviderProfile):
"""Vertex AI — reuse Gemini's thinking_config translation for extra_body."""
def build_extra_body(self, *, session_id: str | None = None, **context: Any) -> dict[str, Any]:
"""Emit ``extra_body.google.thinking_config`` like the ``gemini`` provider's OpenAI-compat subpath."""
from agent.transports.chat_completions import _build_gemini_thinking_config, _snake_case_gemini_thinking_config
raw = _build_gemini_thinking_config(context.get("model") or "", context.get("reasoning_config"))
thinking_config = _snake_case_gemini_thinking_config(raw) if raw else None
return {"extra_body": {"google": {"thinking_config": thinking_config}}} if thinking_config else {}
vertex = VertexProfile(
name="vertex", aliases=("google-vertex", "vertex-ai", "gcp-vertex", "vertexai"), api_mode="chat_completions",
env_vars=(), # OAuth2 via service account / ADC — not a static key env var
base_url="https://aiplatform.googleapis.com", # real base_url computed at runtime
auth_type="vertex", default_aux_model="google/gemini-3.6-flash",
supports_model_listing=False, # no /models route on the OpenAI-compat endpoint; setup ships a curated list
)
register_provider(vertex)