Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion tools/image_generation_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,21 @@ def check_image_generation_requirements() -> bool:
}


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():
"""Return the value of ``image_gen.provider`` from config.yaml, or None.

Expand Down Expand Up @@ -915,6 +930,9 @@ def _dispatch_to_plugin_provider(prompt: str, aspect_ratio: str):
if not configured or configured == "fal":
return None

# Also read configured model so we can pass it to the plugin
configured_model = _read_configured_image_model()

try:
# Import locally so plugin discovery isn't triggered just by
# importing this module (tests rely on that).
Expand Down Expand Up @@ -950,7 +968,10 @@ def _dispatch_to_plugin_provider(prompt: str, aspect_ratio: str):
})

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:
logger.warning(
"Image gen provider '%s' raised: %s",
Expand Down