
    i                        d Z ddlZddlmZmZ ddlZddlmZmZm	Z	 ddl
mZ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mZ ddlmZmZ  e ee            Z ee      Z ej>                  d	eD  ci c]  } | |  c} e 
      Z!ee dz   ejD                  ddjG                  e       d ee            f   Z$ ed      Z%e%jM                  dg d      dddddddejN                  df	dedededee dz   ejD                  d      f   dee!dz   ejD                  d      f   dede$deded dfd!       Z(e%jM                  d"d#d$g      ddejN                  dfd%ee  ejR                  d&      f   d'ede$deded dfd(       Z*yc c} w ))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get_args)CLIErrorRepositoryNotFoundErrorRevisionNotFoundError)ExpandModelProperty_TModelSort_T   )	AuthorOpt	FilterOptFormatWithAutoOptLimitOptRevisionOpt	SearchOptTokenOptapi_object_to_dict
get_hf_apimake_expand_properties_parsertyper_factory)OutputFormatWithAutooutModelSortEnum)typezComma-separated properties to return. When used, only the listed properties (and id) are returned. Example: '--expand=downloads,likes,tags'. Valid: z, .)helpcallbackz Interact with models on the Hub.)r   z	list | ls)z(hf models ls --sort downloads --limit 10z1hf models ls --search "llama" --author meta-llamaz:hf models ls --num-parameters min:6B,max:128B --sort likes)examples
   searchauthorfilternum_parametersz2Filter by parameter count, e.g. 'min:6B,max:128B'.sortzSort results.limitexpandformattokenreturnc	           	          t        |      }	|r|j                  nd}
|	j                  ||| ||
||      D cg c]  }t        |       }}t	        j
                  |       yc c}w )zList models on the Hub.r'   N)r!   r    r   r"   r#   r$   r%   )r   valuelist_modelsr   r   table)r   r    r!   r"   r#   r$   r%   r&   r'   apisort_key
model_inforesultss                k/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/huggingface_hub/cli/models.py	models_lsr3   D   su    4 5
!C!tzztH //) * 
 	:&G  IIgs   A!infoz/hf models info meta-llama/Llama-3.2-1B-Instructz<hf models info Qwen/Qwen3.5-9B --expand downloads,likes,tagsmodel_idz)The model ID (e.g. `username/repo-name`).revisionc                     t        |      }	 |j                  | ||      }t        j                  |       y# t        $ r}t        d|  d      |d}~wt        $ r}t        d| d|  d      |d}~ww xY w)	z"Get info about a model on the Hub.r*   )repo_idr6   r%   zModel 'z' not found.Nz
Revision 'z' not found on 'z'.)r   r0   r   r   r   r   dict)r5   r6   r%   r&   r'   r.   r4   es           r2   models_infor;   o   s     5
!CS~~h&~Q
 HHTN	 # @
,78a?  SH:-=hZrJKQRRSs!   8 	A5AA5A00A5)+__doc__enumtypingr   r   typerhuggingface_hub.errorsr   r   r   huggingface_hub.hf_apir   r	   
_cli_utilsr   r   r   r   r   r   r   r   r   r   r   _outputr   r   sorted_EXPAND_PROPERTIES_SORT_OPTIONSEnumstrr   Optionjoin	ExpandOpt
models_clicommandautor3   Argumentr;   )ss   0r2   <module>rQ      s    &  [ [ E    / H%:;< %		/-+HQAqD+HsS $JELL d  ei  en  en  oA  eB  dC  CD  E./AB	  BC
     	 	 4 9 9      d
NO	Q	  /*	,           
!  F 
9F   ! 4 9 9^U^^1\]]^  	
  
C ,Is   .
F
