
    [j                        d Z ddlmZ ddlZddlmZmZmZ ddlm	Z	  ej
        e          Z G d de	          Zdd
ZdS )uI  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``).
    )annotationsN)AnyDictList) OpenAICompatibleVideoGenProviderc                  N    e Zd ZdZdZdZdZedd            Zdd	Z	ddZ
ddZdS )DeepInfraVideoGenProviderzGText-to-video and image-to-video via DeepInfra's OpenAI-compatible API.	deepinfraDEEPINFRA_API_KEYz#https://api.deepinfra.com/v1/openaireturnstrc                    dS )N	DeepInfra selfs    F/home/ice/.hermes/hermes-agent/plugins/video_gen/deepinfra/__init__.pydisplay_namez&DeepInfraVideoGenProvider.display_name    s    {    List[Dict[str, Any]]c                   	 ddl m} n4# t          $ r'}t                              d|           g cY d}~S d}~ww xY w |d          pg }g }|D ]}|                    d          }|st          |t                    r|                    di           ni }|                    ||	                    d          d	         |                    d
          pddd         d           |S )u   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.
        r   )_fetch_deepinfra_models_by_tagz0Cannot import _fetch_deepinfra_models_by_tag: %sNz	video-genidmetadata/description P   )r   display	strengths)
hermes_cli.modelsr   	Exceptionloggerdebugget
isinstancedictappendsplit)r   r   excitemsoutitemmidmetas           r   list_modelsz%DeepInfraVideoGenProvider.list_models$   s)   	HHHHHHH 	 	 	LLKSQQQIIIIII	 /.{;;Ar$& 		 		D((4..C /9$/E/EM488J+++2DJJ99S>>"-"hh}55;SbSA     
 
s   	 
:5::Dict[str, Any]c           	     $    ddgg dg dddddd	d
S )Ntextimage)z16:9z9:16z1:1)480p720p1080p
      FTr   )
modalitiesaspect_ratiosresolutionsmax_durationmin_durationsupports_audiosupports_negative_promptmax_reference_imagesr   r   s    r   capabilitiesz&DeepInfraVideoGenProvider.capabilities=   s:    !7+444444#(,$%	
 	
 		
r   c                    dddddddgdS )	Nr   paiduY   Wan, p-video, … — live catalog from api.deepinfra.com; text-to-video & image-to-videor   zDeepInfra API keyz#https://deepinfra.com/dash/api_keys)keyprompturl)namebadgetagenv_varsr   r   s    r   get_setup_schemaz*DeepInfraVideoGenProvider.get_setup_schemaI   s4    n /1@ 	
 
 	
r   N)r   r   )r   r   )r   r2   )__name__
__module____qualname____doc__rI   _env_key_default_base_urlpropertyr   r1   rC   rM   r   r   r   r	   r	      s        QQD"H=   X   2

 

 

 


 
 
 
 
 
r   r	   r   Nonec                H    |                      t                                 dS )uL   Plugin entry point — wire ``DeepInfraVideoGenProvider`` into the registry.N)register_video_gen_providerr	   )ctxs    r   registerrY   X   s#    ##$=$?$?@@@@@r   )r   rU   )rQ   
__future__r   loggingtypingr   r   r   agent.video_gen_providerr   	getLoggerrN   r$   r	   rY   r   r   r   <module>r_      s     # " " " " "  " " " " " " " " " " E E E E E E		8	$	$<
 <
 <
 <
 <
 @ <
 <
 <
~A A A A A Ar   