The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(providers): bundle Meta Model API (Muse Spark) provider plugin
Beto de Paola833f0e2ac1be
diff --git a/plugins/model-providers/meta-ai/__init__.py b/plugins/model-providers/meta-ai/__init__.pynew file mode 100644index 00000000000..00515f7fefb--- /dev/null+++ b/plugins/model-providers/meta-ai/__init__.py@@ -0,0 +1,113 @@+"""Meta Model API (Muse Spark) provider plugin for Hermes Agent.++Self-contained, out-of-tree provider profile for Meta Superintelligence Labs'+Muse Spark family, served via the OpenAI-compatible Meta Model API at+``https://api.meta.ai/v1``.++Install by copying this directory to+``$HERMES_HOME/plugins/model-providers/meta-ai/`` (see ``install.sh``). Hermes'+provider discovery (``providers/__init__.py``) imports it on first+``get_provider_profile()`` / ``list_providers()`` call, and the module-level+``register_provider()`` below wires it into the registry.++Design notes+------------+* **Zero core edits.** Everything rides on ``ProviderProfile`` hooks. No changes+ to hermes' ``model_metadata.py`` / ``models.py`` / ``run_agent.py`` are needed:+ - Context window (1M), reasoning and vision capabilities already resolve from+ models.dev for the muse-spark family, so no static ctx table entry is required.+ - The reasoning dial is emitted as a **top-level ``reasoning_effort``** kwarg+ (returned in the ``top_level`` slot of ``build_api_kwargs_extras``), which the+ chat-completions transport merges unconditionally. This deliberately avoids+ the ``extra_body.reasoning`` path, whose emission is gated by a hardcoded+ host allowlist in core (``AIAgent._supports_reasoning_extra_body``) that a+ third-party plugin must not edit.+* **Meta 400 on ``reasoning_effort: "none"``.** Muse rejects ``none``; disabling+ reasoning maps to ``"minimal"`` instead.+* **``default_max_tokens=16384``.** Muse spends completion budget on hidden+ reasoning tokens first; small caps can finish with empty content.+"""++from __future__ import annotations++import os+from typing import Any++from providers import register_provider+from providers.base import ProviderProfile+++def _resolve_effort(reasoning_config: dict | None) -> str:+ """Map Hermes' reasoning_config to a Meta-safe ``reasoning_effort`` value.++ - reasoning disabled / effort "none" -> "minimal" (Meta 400s on "none")+ - low | medium | high -> passthrough+ - max | xhigh | ultra -> "xhigh"+ - unset / unknown -> "medium"+ """+ rc = reasoning_config or {}+ if rc.get("enabled") is False:+ return "minimal"+ effort = str(rc.get("effort") or "").strip().lower()+ if effort in {"", "none"}:+ return "minimal" if effort == "none" else "medium"+ if effort in {"low", "medium", "high"}:+ return effort+ if effort in {"max", "xhigh", "ultra"}:+ return "xhigh"+ return "medium"+++class MetaAIProfile(ProviderProfile):+ """Meta Model API — top-level reasoning_effort, self-contained."""++ def build_api_kwargs_extras(+ self,+ *,+ reasoning_config: dict | None = None,+ supports_reasoning: bool = False, # noqa: ARG002 — we self-gate below+ **context: Any,+ ) -> tuple[dict[str, Any], dict[str, Any]]:+ """Emit ``reasoning_effort`` as a top-level api kwarg.++ We ignore the core ``supports_reasoning`` gate on purpose: that flag is+ driven by a host allowlist in core we cannot (and should not) edit from+ an out-of-tree plugin. Muse Spark always accepts ``reasoning_effort``,+ so we resolve it from ``reasoning_config`` directly.+ """+ return {}, {"reasoning_effort": _resolve_effort(reasoning_config)}+++def _base_url() -> str:+ """Allow a base-URL override via ``META_BASE_URL`` without editing config."""+ return os.getenv("META_BASE_URL", "").strip() or "https://api.meta.ai/v1"+++meta_ai = MetaAIProfile(+ name="meta-ai",+ aliases=("meta", "muse", "muse-spark", "model-api", "msl"),+ display_name="Meta Model API",+ description="Meta Muse Spark family (Meta Superintelligence Labs)",+ signup_url="https://developer.meta.com/ai/",+ # MODEL_API_KEY is Meta's documented env var; the aliases are conveniences.+ env_vars=("MODEL_API_KEY", "META_API_KEY", "META_MODEL_API_KEY", "META_BASE_URL"),+ base_url=_base_url(),+ auth_type="api_key",+ api_mode="chat_completions",+ # Muse Spark is natively multimodal (image/video/pdf/audio in, text out).+ supports_vision=True,+ # Cheap contributor tier is a good default for auxiliary tasks+ # (compaction, title generation, vision) when this is the main provider.+ default_aux_model="muse-spark-1.2-contributor",+ # Muse spends completion budget on hidden reasoning tokens first; a low cap+ # can finish with empty content. 16k is a safe floor.+ default_max_tokens=16384,+ # Curated safety net shown in the picker when the live /v1/models fetch+ # fails or no credentials are configured yet.+ fallback_models=(+ "muse-spark-1.2",+ "muse-spark-1.2-contributor",+ ),+)++register_provider(meta_ai)diff --git a/plugins/model-providers/meta-ai/plugin.yaml b/plugins/model-providers/meta-ai/plugin.yamlnew file mode 100644index 00000000000..f7da2c3a3f2--- /dev/null+++ b/plugins/model-providers/meta-ai/plugin.yaml@@ -0,0 +1,6 @@+name: meta-ai-provider+kind: model-provider+version: 1.0.0+description: Meta Model API — Muse Spark family (Meta Superintelligence Labs)+author: Beto de Paola+homepage: https://github.com/albertodepaola/hermes-meta-provider