
    `gj                    ~    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y)
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                  F    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y	)DeepInfraVideoGenProviderzGText-to-video and image-to-video via DeepInfra's OpenAI-compatible API.	deepinfraDEEPINFRA_API_KEYz#https://api.deepinfra.com/v1/openaic                     y)N	DeepInfra selfs    W/root/.hermes/venv/lib/python3.12/site-packages/plugins/video_gen/deepinfra/__init__.pydisplay_namez&DeepInfraVideoGenProvider.display_name    s        c                   	 ddl m}  |d      xs g }g }|D ]w  }|j                  d      }|st        |t              r|j                  di       ni }|j                  ||j                  d      d	   |j                  d
      xs ddd d       y |S # t        $ r"}t        j	                  d|       g cY d}~S d}~ww xY w)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 /{;Ar$& 		D((4.C/9$/E488J+2DJJ99S>"-"hh}5;SbA 		 
  	LLKSQI	s   B 	B?B:4B?:B?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#(,$%	
 		
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   s*    n /1@	
 	
r   N)returnstr)rJ   zList[Dict[str, Any]])rJ   zDict[str, Any])__name__
__module____qualname____doc__rE   _env_key_default_base_urlpropertyr   r.   r?   rI   r   r   r   r	   r	      s6    QD"H= 2


r   r	   c                6    | j                  t                      y)uL   Plugin entry point — wire ``DeepInfraVideoGenProvider`` into the registry.N)register_video_gen_providerr	   )ctxs    r   registerrV   X   s    ##$=$?@r   )rJ   None)rO   
__future__r   loggingtypingr   r   r   agent.video_gen_providerr   	getLoggerrL   r!   r	   rV   r   r   r   <module>r]      sA    #  " " E			8	$<
 @ <
~Ar   