mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-14 04:02:26 +00:00
feat(image-gen): honor image_gen.model from config.yaml in plugin dispatch
Image generation plugins were dispatched without a model name, leaving
the plugin to pick its default. Users on OpenRouter, ComfyUI, or custom
backends had no way to select a specific model through config — they
had to fork the plugin or patch the tool.
Add _read_configured_image_model() that reads image_gen.model from the
active profile's config.yaml and forwards it into
_dispatch_to_plugin_provider(). When model is set, the plugin call
gains a 'model' kwarg; when unset, the plugin falls back to its own
default, so single-model users see no behavior change.
Example config:
image_gen:
provider: openrouter
model: flux-pro
Tests: all 170 image tool tests pass. The new code path is opt-in via
config and no existing test exercises it, so the change is strictly
additive.
This commit is contained in:
parent
b739fcdfce
commit
a9c7bdaea6
1 changed files with 22 additions and 1 deletions
|
|
@ -879,6 +879,21 @@ IMAGE_GENERATE_SCHEMA = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _read_configured_image_model():
|
||||||
|
"""Return the value of ``image_gen.model`` from config.yaml, or None."""
|
||||||
|
try:
|
||||||
|
from hermes_cli.config import load_config
|
||||||
|
cfg = load_config()
|
||||||
|
section = cfg.get("image_gen") if isinstance(cfg, dict) else None
|
||||||
|
if isinstance(section, dict):
|
||||||
|
value = section.get("model")
|
||||||
|
if isinstance(value, str) and value.strip():
|
||||||
|
return value.strip()
|
||||||
|
except Exception as exc:
|
||||||
|
logger.debug("Could not read image_gen.model: %s", exc)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _read_configured_image_provider():
|
def _read_configured_image_provider():
|
||||||
"""Return the value of ``image_gen.provider`` from config.yaml, or None.
|
"""Return the value of ``image_gen.provider`` from config.yaml, or None.
|
||||||
|
|
||||||
|
|
@ -915,6 +930,9 @@ def _dispatch_to_plugin_provider(prompt: str, aspect_ratio: str):
|
||||||
if not configured or configured == "fal":
|
if not configured or configured == "fal":
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Also read configured model so we can pass it to the plugin
|
||||||
|
configured_model = _read_configured_image_model()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Import locally so plugin discovery isn't triggered just by
|
# Import locally so plugin discovery isn't triggered just by
|
||||||
# importing this module (tests rely on that).
|
# importing this module (tests rely on that).
|
||||||
|
|
@ -950,7 +968,10 @@ def _dispatch_to_plugin_provider(prompt: str, aspect_ratio: str):
|
||||||
})
|
})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = provider.generate(prompt=prompt, aspect_ratio=aspect_ratio)
|
kwargs = {"prompt": prompt, "aspect_ratio": aspect_ratio}
|
||||||
|
if configured_model:
|
||||||
|
kwargs["model"] = configured_model
|
||||||
|
result = provider.generate(**kwargs)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Image gen provider '%s' raised: %s",
|
"Image gen provider '%s' raised: %s",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue