mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-12 13:52:15 +00:00
fix(image-gen): honor top-level image_gen.model for Nous/OpenRouter
hermes tools persists the selected model to image_gen.model, but the OpenRouter-compatible provider only read scoped image_gen.<provider>.model and ignored the dispatch model kwarg — so Nous users always hit the default quality-first chain and fell back to Gemini.
This commit is contained in:
parent
824f2279da
commit
1324add563
1 changed files with 12 additions and 6 deletions
|
|
@ -46,8 +46,9 @@ logger = logging.getLogger(__name__)
|
|||
# image model first, then fall back to Gemini 3 Pro Image if the OpenAI model
|
||||
# is access-gated / unavailable / times out on this endpoint.
|
||||
#
|
||||
# Explicit override (OPENROUTER_IMAGE_MODEL or image_gen.<provider>.model):
|
||||
# use exactly that model (no auto fallback), so power users keep full control.
|
||||
# Explicit override (OPENROUTER_IMAGE_MODEL, image_gen.<provider>.model, or
|
||||
# image_gen.model from ``hermes tools``): use exactly that model (no auto
|
||||
# fallback), so power users keep full control.
|
||||
DEFAULT_MODEL = "openai/gpt-5.4-image-2"
|
||||
_FALLBACK_MODEL = "google/gemini-3-pro-image"
|
||||
_DEFAULT_MODEL_CHAIN = (DEFAULT_MODEL, _FALLBACK_MODEL)
|
||||
|
|
@ -243,16 +244,18 @@ class OpenRouterCompatImageProvider(ImageGenProvider):
|
|||
def get_setup_schema(self) -> Dict[str, Any]:
|
||||
return dict(self._setup_schema)
|
||||
|
||||
def _resolve_model(self) -> str:
|
||||
def _resolve_model(self, explicit: Optional[str] = None) -> str:
|
||||
"""Pick the image model: env override → config → :data:`DEFAULT_MODEL`."""
|
||||
return self._resolve_model_chain()[0]
|
||||
return self._resolve_model_chain(explicit)[0]
|
||||
|
||||
def _resolve_model_chain(self) -> list[str]:
|
||||
def _resolve_model_chain(self, explicit: Optional[str] = None) -> list[str]:
|
||||
"""Ordered model attempts for this request.
|
||||
|
||||
Explicit user/model config means "use this exact model", so no fallback.
|
||||
Without overrides we run the quality-first default chain.
|
||||
"""
|
||||
if isinstance(explicit, str) and explicit.strip():
|
||||
return [explicit.strip()]
|
||||
env_override = os.environ.get(self._model_env_var, "").strip()
|
||||
if env_override:
|
||||
return [env_override]
|
||||
|
|
@ -262,6 +265,9 @@ class OpenRouterCompatImageProvider(ImageGenProvider):
|
|||
value = scoped.get("model")
|
||||
if isinstance(value, str) and value.strip():
|
||||
return [value.strip()]
|
||||
top = cfg.get("model")
|
||||
if isinstance(top, str) and top.strip():
|
||||
return [top.strip()]
|
||||
return _dedupe_models(list(_DEFAULT_MODEL_CHAIN))
|
||||
|
||||
def generate(
|
||||
|
|
@ -297,7 +303,7 @@ class OpenRouterCompatImageProvider(ImageGenProvider):
|
|||
aspect_ratio=aspect_ratio,
|
||||
)
|
||||
|
||||
model_chain = self._resolve_model_chain()
|
||||
model_chain = self._resolve_model_chain(kwargs.get("model"))
|
||||
aspect = resolve_aspect_ratio(aspect_ratio)
|
||||
or_aspect = _ASPECT_RATIOS.get(aspect, "1:1")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue