
    Li                        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
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mZmZmZ  e ee            Z ee      Z  ejB                  de D  ci c]  } | |  c} e"	      Z#eee"    ejH                  d
djK                  e       d ee            f   Z& ed      Z'e'jQ                  dg d      dddddddejR                  ddf
dedededeee"    ejH                  d      f   deee#    ejH                  d      f   dede&deded ed!dfd"       Z*e'jQ                  d#d$d%g      	 	 	 d*d&ee" ejV                  d'      f   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Optionalget_args)CLIErrorRepositoryNotFoundErrorRevisionNotFoundError)ExpandModelProperty_TModelSort_T   )	AuthorOpt	FilterOpt	FormatOptLimitOptOutputFormatQuietOptRevisionOpt	SearchOptTokenOptapi_object_to_dict
get_hf_apimake_expand_properties_parserprint_list_outputtyper_factory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
   Fsearchauthorfilternum_parametersz2Filter by parameter count, e.g. 'min:6B,max:128B'.sortzSort results.limitexpandformatquiettokenreturnc
           	          t        |	      }
|r|j                  nd}|
j                  ||| ||||      D cg c]  }t        |       }}t	        |||       yc c}w )zList models on the Hub.r*   N)r#   r"   r!   r$   r%   r&   r'   )r(   r)   )r   valuelist_modelsr   r   )r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   apisort_key
model_inforesultss                 `/var/www/html/lcp-python-backend/venv/lib/python3.12/site-packages/huggingface_hub/cli/models.py	models_lsr5   G   su    6 5
!C!tzztH //) * 
 	:&G  gfE: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        t        j                  t        |      d	
             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. Output is in JSON format.r-   )repo_idr8   r'   zModel 'z' not found.Nz
Revision 'z' not found on 'z'.   )indent)	r   r2   r   r   r   printjsondumpsr   )r7   r8   r'   r*   r0   r6   es          r4   models_inforA   s   s     5
!CS~~h&~Q
 
$**'-a
89	 # @
,78a?  SH:-=hZrJKQRRSs#   A 	B	A%%B	1BB	)NNN)-__doc__enumr>   typingr   r   r   typerhuggingface_hub.errorsr   r   r   huggingface_hub.hf_apir	   r
   
_cli_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   sorted_EXPAND_PROPERTIES_SORT_OPTIONSEnumstrr   Optionjoin	ExpandOpt
models_clicommandtabler5   ArgumentrA   )ss   0r4   <module>rV      s{     0 0  [ [ E   $ H%:;< %		/-+HQAqD+HsS SMELL d  ei  en  en  oA  eB  dC  CD  E./AB	  BC
     	 	$**!!;!;!; !; NO	Q	!; /*	,!; !; !; !; !;  !!;" 
#!;!;H 
9F   !	:^U^^1\]]^:: : 	:
 
::E ,Is   2
E=
