
    -iM                        d Z ddlZddlZddlmZmZmZ ddlZddlm	Z	m
Z
 ddlmZmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZmZ  e ee                    Z ee          Z ej        d	d
 eD             e          Z eee          ej!        dd"                    e           d ee                    f         Z# ed          Z$e$%                    d          	 	 	 	 	 	 	 d#dedededeee           ej!        d          f         dede#deddfd            Z&e$%                    d          	 	 	 d$dee ej'        d           f         d!ede#deddf
d"            Z(dS )%a  Contains commands to interact with models on the Hugging Face Hub.

Usage:
    # list models on the Hub
    hf models ls

    # list models with a search query
    hf models ls --search "llama"

    # get info about a model
    hf models info Lightricks/LTX-2
    N)	AnnotatedOptionalget_args)RepositoryNotFoundErrorRevisionNotFoundError)ExpandModelProperty_TModelSort_T)ANSI   )
	AuthorOpt	FilterOptLimitOptRevisionOpt	SearchOptTokenOpt
get_hf_apimake_expand_properties_parserrepo_info_to_dicttyper_factoryModelSortEnumc                     i | ]}||S  r   ).0ss     X/var/www/html/speakWrite/venv/lib/python3.11/site-packages/huggingface_hub/cli/models.py
<dictcomp>r   5   s    +H+H+HQAq+H+H+H    )typezWComma-separated properties to expand. Example: '--expand=downloads,likes,tags'. Valid: z, .)helpcallbackz Interact with models on the Hub.)r    ls
   searchauthorfiltersortzSort results.limitexpandtokenreturnc           	          t          |          }|r|j        nd}d |                    ||| |||          D             }	t          t	          j        |	d                     dS )zList models on the Hub.r*   Nc                 ,    g | ]}t          |          S r   )r   )r   
model_infos     r   
<listcomp>zmodels_ls.<locals>.<listcomp>T   s0        	*%%  r   )r&   r%   r$   r'   r(   r)      indent)r   valuelist_modelsprintjsondumps)
r$   r%   r&   r'   r(   r)   r*   apisort_keyresultss
             r   	models_lsr<   D   s     5
!
!
!C!+tzztH //&he\b * 
 
  G 
$*WQ
'
'
'(((((r   infomodel_idz)The model ID (e.g. `username/repo-name`).revisionc           	         t          |          }	 |                    | ||          }n# t          $ r; t          dt	          j        |            d           t          j        d          t          $ r] t          dt	          j        t          |                     dt	          j        |            d	           t          j        d          w xY wt          t          j        t          |          d
                     dS )z"Get info about a model on the Hub.r-   )repo_idr?   r)   zModel z not found.r   )codez	Revision z not found on r   r1   r2   N)r   r/   r   r6   r
   boldtyperExitr   strr7   r8   r   )r>   r?   r)   r*   r9   r=   s         r   models_inforG   ]   s    5
!
!
!C!~~h&~QQ" ! ! !7ty**777888ja      ! ! !X$)CMM22XX$)HBUBUXXXYYYja    ! 
$*&t,,Q
7
7
788888s
   + B*C)NNNNr#   NN)NNN))__doc__enumr7   typingr   r   r   rD   huggingface_hub.errorsr   r   huggingface_hub.hf_apir   r	   huggingface_hub.utilsr
   
_cli_utilsr   r   r   r   r   r   r   r   r   r   sorted_EXPAND_PROPERTIES_SORT_OPTIONSEnumrF   r   Optionjoin	ExpandOpt
models_clicommandr<   ArgumentrG   r   r   r   <module>rY      s+      0 0 0 0 0 0 0 0 0 0  Q Q Q Q Q Q Q Q E E E E E E E E & & & & & &                        VHH%:;;<< %%	/+H+H-+H+H+HsSSS SMEL Hgkgpgp  rD  hE  hE  H  H  H../ABB  	 ] BCCC
 D 	) ))) ) /***	,	) ) ) ) 
) ) ) )0 F !	9 9^U^1\]]]]^99 9 	9
 
9 9 9 9 9 9r   