refactor(plugins/video_gen): fal/xai — shared model tables, submit/poll/download helpers, dedupe validation

This commit is contained in:
Teknium
2026-09-02 11:23:20 -07:00
parent b5b62aa83d
commit 75b7e054a5
3 changed files with 566 additions and 1598 deletions

View File

@@ -1,15 +1,10 @@
"""DeepInfra video generation backend.
DeepInfra serves video over the OpenAI-compatible ``/v1/openai/videos``
endpoint (async job: ``create`` → poll → ``download_content``), so all the
SDK plumbing lives in
:class:`agent.video_gen_provider.OpenAICompatibleVideoGenProvider`. This
plugin only declares DeepInfra's identity, credentials, and live model
discovery — no hardcoded model ids, so retired models drop out of hermes the
next time the catalog is fetched without a patch.
Mirrors ``plugins/image_gen/deepinfra`` (which does the same for
``/v1/openai/images/generations``).
DeepInfra serves video over the OpenAI-compatible ``/v1/openai/videos`` endpoint (async job:
``create`` → poll → ``download_content``), so all SDK plumbing lives in
:class:`agent.video_gen_provider.OpenAICompatibleVideoGenProvider`. This plugin only declares
identity, credentials, and live model discovery — no hardcoded model ids, so retired models drop
out without a patch. Mirrors ``plugins/image_gen/deepinfra``.
"""
from __future__ import annotations
@@ -34,41 +29,27 @@ class DeepInfraVideoGenProvider(OpenAICompatibleVideoGenProvider):
return "DeepInfra"
def list_models(self) -> List[Dict[str, Any]]:
"""Return ``video-gen``-tagged DeepInfra models from the live catalog.
Empty list when the catalog is unreachable — the picker then shows no
options rather than routing to a possibly-retired model.
"""
"""``video-gen``-tagged models from the live catalog; empty when it is
unreachable so the picker shows nothing rather than a retired model."""
try:
from hermes_cli.models import _fetch_deepinfra_models_by_tag
except Exception as exc: # noqa: BLE001 — never break the picker
logger.debug("Cannot import _fetch_deepinfra_models_by_tag: %s", exc)
return []
items = _fetch_deepinfra_models_by_tag("video-gen") or []
out: List[Dict[str, Any]] = []
for item in items:
mid = item.get("id")
if not mid:
continue
meta = item.get("metadata", {}) if isinstance(item, dict) else {}
out.append({
"id": mid,
"display": mid.split("/")[-1],
"strengths": (meta.get("description") or "")[:80],
})
return out
return [
{"id": item["id"], "display": item["id"].split("/")[-1],
"strengths": ((item.get("metadata", {}) or {}).get("description") or "")[:80]}
for item in (_fetch_deepinfra_models_by_tag("video-gen") or []) if item.get("id")
]
def capabilities(self) -> Dict[str, Any]:
return {
"modalities": ["text", "image"],
"aspect_ratios": ["16:9", "9:16", "1:1"],
"resolutions": ["480p", "720p", "1080p"],
"max_duration": 10,
"min_duration": 1,
"supports_audio": False,
"supports_negative_prompt": True,
"supports_seed": True,
"supports_upscale": False,
"max_duration": 10, "min_duration": 1,
"supports_audio": False, "supports_negative_prompt": True,
"supports_seed": True, "supports_upscale": False,
"max_reference_images": 0,
}
@@ -78,11 +59,7 @@ class DeepInfraVideoGenProvider(OpenAICompatibleVideoGenProvider):
"badge": "paid",
"tag": "Wan, p-video, … — live catalog from api.deepinfra.com; text-to-video & image-to-video",
"env_vars": [
{
"key": "DEEPINFRA_API_KEY",
"prompt": "DeepInfra API key",
"url": "https://deepinfra.com/dash/api_keys",
},
{"key": "DEEPINFRA_API_KEY", "prompt": "DeepInfra API key", "url": "https://deepinfra.com/dash/api_keys"},
],
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff