
    ^j'              (       *   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 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mZ dd
lmZ ddlm Z m!Z! ddl"m#Z#m$Z$  e% ee            Z& ee      Z' ejP                  de'D  ci c]  } | |  c} e)      Z* ejP                  d e% ee            D ci c]  }|| c}e)      Z+ee)dz   e!ddjY                  e&       d ee&            f   Z- ed      Z.e.j_                  dg d      dddddddddddeddddddfdee)dz   e d      f   dedededee)dz   e!d d!      f   d"ee0dz   e!d#d$      f   d%ee1e)   dz   e!d&d'      f   d(ee)dz   e!d)      f   d*ee1e)   dz   e!d+ ee+      d,-      f   d.ee0 e!d/d0      f   d1ee*dz   e!d2      f   d3ed4e-d5ee0 e!d6d7d8      f   d9ee0 e!d:d;      f   d<ee0 e!d=d>d?      f   d@edAedBdf&dC       Z2e.j_                  dDdEdFg      	 	 	 dSdGee) e dH      f   d@ed4e-dAedBdf
dI       Z3e.j_                  dJg dK      	 	 	 dTdGee) e dH      f   dLee0 e!dMdN      f   dOee0 e!dPdQ      f   dAedBdf
dR       Z4yc c} w c c}w )UzBContains commands to interact with models on the Hugging Face Hub.    N)	Annotatedget_args)CLIErrorRepositoryNotFoundErrorRevisionNotFoundError)ExpandModelProperty_TModelSort_T)
PROVIDER_T)	ModelCard   )REPO_LIST_DEFAULT_LIMIT	AuthorOpt	FilterOptLimitOptRevisionOpt	SearchOpt
SoftChoiceTokenOpt
get_hf_apimake_expand_properties_parsertyper_factory)list_repo_files_cmd)ArgumentOption)_dataclass_to_dictoutModelSortEnum)typeInferenceProviderEnumzComma-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-llamaz2hf models ls --pipeline-tag text-generation --warmz:hf models ls --num-parameters min:6B,max:128B --sort likesz'hf models ls --no-gated --author googlez)hf models ls --apps llama.cpp --apps vllmz?hf models ls --inference-provider fireworks-ai --sort downloadsz"hf models ls --warm --search llamaz-hf models ls meta-llama/Llama-3.2-1B-Instructz0hf models ls meta-llama/Llama-3.2-1B-Instruct -Rz7hf models ls meta-llama/Llama-3.2-1B-Instruct --tree -h)examplesFrepo_idzRModel ID (e.g. `username/repo-name`) to list files from. If omitted, lists models.searchauthorfilterpipeline_tagz--pipeline-tagz>Filter by pipeline tag (canonical task), e.g. 'summarization'.gatedz--gated/--no-gatedzRFilter by gated status. '--gated' for gated only, '--no-gated' for non-gated only.appsz--appszAFilter by app(s) that can run the model, e.g. 'ollama' or 'vllm'.num_parametersz2Filter by parameter count, e.g. 'min:6B,max:128B'.inference_providerz--inference-providerzGFilter by inference provider(s) serving the model, e.g. 'fireworks-ai'.)
click_typer!   warmz--warmzEOnly list models currently served by at least one inference provider.sortzSort results.limitexpandhuman_readablez--human-readablez-hz=Show sizes in human readable format (only for listing files).as_treez--treez3List files in tree format (only for listing files).	recursivez--recursivez-Rz0List files recursively (only for listing files).revisiontokenreturnc                 b   | -|t        j                  d      |t        j                  d      |t        j                  d      |t        j                  d      |t        j                  d      |t        j                  d      |t        j                  d      |t        j                  d	      |	rt        j                  d
      |
t        j                  d      |t        k7  rt        j                  d      |t        j                  d      t        | d|||||      S |rt        j                  d      |rt        j                  d      |rt        j                  d      |t        j                  d      |	r|t        j                  d      t	        |      }|
r|
j
                  nd}|j                  ||||||||	rdnd||||      D cg c]  }t        |       }}t        j                  |       ||	r|st        j                  d       yyyc c}w )zList models on the Hub, or files in a model repo.

    When called with no argument, lists models on the Hub.
    When called with a model ID, lists files in that model repo.
    Nz'Cannot use --search when listing files.z'Cannot use --author when listing files.z'Cannot use --filter when listing files.z-Cannot use --pipeline-tag when listing files.z1Cannot use --gated/--no-gated when listing files.z%Cannot use --apps when listing files.z/Cannot use --num-parameters when listing files.z3Cannot use --inference-provider when listing files.z%Cannot use --warm when listing files.z%Cannot use --sort when listing files.z&Cannot use --limit when listing files.z'Cannot use --expand when listing files.model)r$   	repo_typer2   r3   r4   r5   r6   z&Cannot use --tree when listing models.z+Cannot use --recursive when listing models.z0Cannot use --human-readable when listing models.z*Cannot use --revision when listing models.z5Cannot use --warm together with --inference-provider.r6   r.   )r'   r&   r%   r(   r)   r*   r+   	inferencer,   r/   r0   r1   zsUse `--expand inferenceProviderMapping` to see which provider serves each model and the provider-specific model id.)clickBadParameterr   r   r   valuelist_modelsr   r   tablehint)r$   r%   r&   r'   r(   r)   r*   r+   r,   r.   r/   r0   r1   r2   r3   r4   r5   r6   apisort_key
model_inforesultss                         e/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/huggingface_hub/cli/models.py	models_lsrH   @   sh   b $$%NOO$$%NOO$$%NOO#$$%TUU$$%XYY$$%LMM%$$%VWW)$$%Z[[$$%LMM$$%LMM++$$%MNN$$%NOO")
 	
   !IJJ  !NOO  !STT  !MNN".  !XYY
5
!C!tzztH //%) $f$1 * 
 	:&G " IIg&$ B	
 9?$%s   %H,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`).c                     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;   )r$   r5   r1   zModel 'z' not found.Nz
Revision 'z' not found on 'z'.)r   rE   r   r   r   r   dict)rJ   r5   r1   r6   rC   rI   es          rG   models_inforN      s     5
!CS~~h&~Q
 HHTN	 # @
,78a?  SH:-=hZrJKQRRSs!   8 	A5AA5A00A5card)z$hf models card google/gemma-4-31B-itz/hf models card google/gemma-4-31B-it --metadataz=hf models card google/gemma-4-31B-it --metadata --format jsonz+hf models card google/gemma-4-31B-it --textmetadataz
--metadataz'Output only the metadata from the card.textz--textz(Output only the text body (no metadata).c                 d   |r|rt        d      t        j                  | |      }|r.t        j                  |j
                  j                                y|r t        j                  |j                         yt        j                  |j                         t        j                  d|  d       y)z3Get the model card (README) for a model on the Hub.z---metadata and --text are mutually exclusive.r;   zUse `hf models card z/ --metadata` to extract only the card metadata.N)
r   r   loadr   rL   datato_dictrQ   contentrB   )rJ   rP   rQ   r6   rO   s        rG   models_cardrW      s{      DFGG>>(%0D""$%	'z1`ab    )NNN)FFN)5__doc__enumtypingr   r   r=   huggingface_hub.errorsr   r   r   huggingface_hub.hf_apir   r	   $huggingface_hub.inference._providersr
   huggingface_hub.repocardr   
_cli_utilsr   r   r   r   r   r   r   r   r   r   r   _file_listingr   
_frameworkr   r   _outputr   r   sorted_EXPAND_PROPERTIES_SORT_OPTIONSEnumstrr   r   join	ExpandOpt
models_clicommandboollistrH   rN   rW   )sps   00rG   <module>rq      s   I  &  [ [ E ; .    / ( , H%:;< %		/-+HQAqD+HsS!		F8J3G,HIqadIPS 
 $J
 d  ei  en  en  oA  eB  dC  CD  E./AB	  BC
   ( 	 	 	 	 	 	 	 	- 	 	 	 uE
d
jk	mE

 E
 E
 E
 d
&fg	iE
 t e	
	E
& S	Dxab	d'E
. d
HI	K/E
6 "S	D"!"78Z	
	7E
F xef	hGE
N O$	&OE
V WE
X YE
Z !4.mn	p[E
b xST	VcE
j }d)[\	^kE
r sE
t uE
v 
wE
! E
P 
9F   !	X+VWWX  	
 
" 
   gl_d	cX+VWWXcf\8abbcc D&0Z[[
\c 	c
 
ccW ,IIs   
J
8
J
