o
    0i                     @   s  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j!dd	d
 e D e"dZ#eee" ej$dd%e deedf Z&eddZ'e'j(dg dddddddddej)ddf
dedededeee" ej$ddf deee# ej$ddf dede&d ed!ed"ed#dfd$d%Z*e'j(d&d'd(gd			d.d)ee"ej+d*df d+ede&d"ed#df
d,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)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ModelSortEnumc                 C   s   i | ]}||qS  r   ).0sr   r   T/home/kim/smarthome/.venv/lib/python3.10/site-packages/huggingface_hub/cli/models.py
<dictcomp>8   s    r   )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)Z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
              
   C   sL   t |	d}
|r
|jnd}dd |
j||| ||||dD }t|||d dS )zList models on the Hub.r-   Nc                 S   s   g | ]}t |qS r   )r   )r   
model_infor   r   r   
<listcomp>d   s    zmodels_ls.<locals>.<listcomp>)r&   r%   r$   r'   r(   r)   r*   )r+   r,   )r   valueZlist_modelsr   )r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   apisort_keyresultsr   r   r   	models_lsG   s   
r6   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              
   C   s   t |d}z
|j| ||d}W n, ty$ } z	td|  d|d}~w ty; } ztd| d|  d|d}~ww ttjt|d	d
 dS )z<Get info about a model on the Hub. Output is in JSON format.r/   )Zrepo_idr9   r*   zModel 'z' not found.Nz
Revision 'z' not found on 'z'.   )indent)	r   r0   r   r   r   printjsondumpsr   )r8   r9   r*   r-   r3   r7   er   r   r   models_infos   s   
r@   )NNN)-__doc__enumr=   typingr   r   r   ZtyperZhuggingface_hub.errorsr   r   r   Zhuggingface_hub.hf_apir   r	   Z
_cli_utilsr   r   r   r   r   r   r   r   r   r   r   r   r   r   sortedZ_EXPAND_PROPERTIESZ_SORT_OPTIONSEnumstrr   OptionjoinZ	ExpandOptZ
models_clicommandtabler6   ZArgumentr@   r   r   r   r   <module>   s   @
		

$	