
    &iO9              (          d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
mZmZ ddlmZmZ  ed	
          Z ed
          Zee ej        d
          f         Zeedz   ej        d
          f         Zeedz   ej        d
          f         Ze                    dddg          dej        dfdede	de
ddfd            Ze                    ddg          ddej        ddddddd	dedee ej        d
          f         dee ej        d
          f         d ee ej        d!
          f         d"ee ej        d#
          f         d$ee ej        d%
          f         d&ee ej        d'
          f         d(ee ej        d)
          f         ded*eedz   ej        d+
          f         de	de
d,ee ej        d-
          f         d.ee ej        d/
          f         d0eedz   ej        d1
          f         d2eedz   ej        d3
          f         d4eedz   ej        d5
          f         ddf$d6            Ze                    dd7g          dddej        dfdee ej        d
          f         ded eedz   ej        d8
          f         dede	de
ddfd9            Zej        dfde	de
ddfd:Z e                    dd;g          e            e                    d<d=>          e           e                     ed?@           e                    dAg          dej        dfdedede	de
ddf
dB            Z!e                    dCg          dddddddddddddej        dfdededeedz   ej        d
          f         d eedz   ej        d!
          f         d"eedz   ej        d#
          f         d$eedz   ej        d%
          f         deedz   ej        dD
          f         dEeedz   ej        dF
          f         d*eedz   ej        d+
          f         d,eedz   ej        d-
          f         d.eedz   ej        d/
          f         d0eedz   ej        d1
          f         d2eedz   ej        d3
          f         d4eedz   ej        d5
          f         de	de
ddf"dG            Z"e                    dHg          ddIej        dfdededJee# ej        dKdL
          f         de	de
ddfdM            Z$e                    dNg          dej        dfdedede	de
ddf
dO            Z%e                    dPg          ddIej        dfdededQee# ej        dRdS
          f         de	de
ddfdT            Z&e                    dUg          dej        dfdedede	de
ddf
dV            Z'dS )Wz2CLI commands for Hugging Face Inference Endpoints.    )	AnnotatedN)InferenceEndpointScalingMetric)HfHubHTTPError   )FormatWithAutoOptTokenOpt
get_hf_apityper_factory)OutputFormatWithAutooutz(Manage Hugging Face Inference Endpoints.)helpz.Interact with the Inference Endpoints catalog.zEndpoint name.z_The namespace associated with the Inference Endpoint. Defaults to the current user's namespace.z	list | lszhf endpoints lsz"hf endpoints ls --namespace my-org)examples	namespaceformattokenreturnc                    t          |          }	 |                    | |          }nI# t          $ r<}t          j        d|            t          j        |j        j                  |d}~ww xY wg }|D ]}|j	        }|
                    di           }	|
                    di           }
|
                    di           }|
                    d	i           }|                    |
                    d
d          t          |
t                    r|

                    dd          ndt          |	t                    r|	
                    dd          ndt          |
t                    r|

                    dd          ndt          |
t                    r|

                    dd          ndt          |t                    r|
                    dd          ndt          |t                    r|
                    dd          ndt          |t                    r|
                    dd          ndd           t          j        |d
           dS )z6Lists all Inference Endpoints for the given namespace.r   )r   r   zListing failed: codeNstatusmodelcomputeprovidername 
repositorystatetask	frameworkinstanceTypevendorregion)r   r   r   r   r    instancer"   r#   )id_key)r	   list_inference_endpointsr   r   errortyperExitresponsestatus_coderawgetappend
isinstancedicttable)r   r   r   api	endpointsr'   resultsendpointr,   r   r   r   r   s                p/home/longshao/.hermes/hermes-agent/venv/lib/python3.11/site-packages/huggingface_hub/cli/inference_endpoints.pylsr7   $   sP    5
!
!
!CE009E0RR		 E E E	,U,,---jen8999uDE G 
 
l2&&$$'')R((77:r**++8B5$8O8OW<444UW5?5M5MU&**Wb111SU1;E41H1HP		&"---b;EeT;R;RZUYY{B777XZ?I'SW?X?X`GKK;;;^`8B8T8R8RZ(,,x444XZ8B8T8R8RZ(,,x444XZ	 		
 	
 	
 	
 Igf%%%%%%s   * 
A07A++A0deployzChf endpoints deploy my-endpoint --repo gpt2 --framework pytorch ...)r   r   )	r   r   r   r   min_replicamax_replicascale_to_zero_timeoutscaling_metricscaling_thresholdr   repozeThe name of the model repository associated with the Inference Endpoint (e.g. 'openai/gpt-oss-120b').r    z@The machine learning framework used for the model (e.g. 'vllm').acceleratorz?The hardware accelerator to be used for inference (e.g. 'cpu').instance_sizezNThe size or type of the instance to be used for hosting the model (e.g. 'x4').instance_typezYThe cloud instance type where the Inference Endpoint will be deployed (e.g. 'intel-icl').r#   zTThe cloud region in which the Inference Endpoint will be created (e.g. 'us-east-1').r"   zVThe cloud provider or vendor where the Inference Endpoint will be hosted (e.g. 'aws').r   zCThe task on which to deploy the model (e.g. 'text-classification').r9   zVThe minimum number of replicas (instances) to keep running for the Inference Endpoint.r:   zRThe maximum number of replicas (instances) to scale to for the Inference Endpoint.r;   zFThe duration in minutes before an inactive endpoint is scaled to zero.r<   z!The metric reference for scaling.r=   zeThe scaling metric threshold used to trigger a scale up. Ignored when scaling metric is not provided.c       	             t          |          }|                    | |||||||||	||||||          }t          j        |j                   dS )z3Deploy an Inference Endpoint from a Hub repository.r   )r   r   r    r?   r@   rA   r#   r"   r   r   r   r9   r:   r<   r=   r;   N)r	   create_inference_endpointr   r0   r,   )r   r>   r    r?   r@   rA   r#   r"   r   r   r   r   r9   r:   r;   r<   r=   r2   r5   s                      r6   r8   r8   H   sy    n 5
!
!
!C,,##%+3! -  H$ HX\    zChf endpoints catalog deploy --repo meta-llama/Llama-3.2-1B-InstructzPThe hardware accelerator to be used for inference (e.g. 'cpu', 'gpu', 'neuron').c                 "   t          |          }	 |                    | ||||          }nI# t          $ r<}t          j        d|            t          j        |j        j                  |d}~ww xY wt          j	        |j
                   dS )z4Deploy an Inference Endpoint from the Model Catalog.r   )repo_idr   r?   r   r   zDeployment failed: r   N)r	   &create_inference_endpoint_from_catalogr   r   r'   r(   r)   r*   r+   r0   r,   )	r>   r   r?   r   r   r   r2   r5   r'   s	            r6   deploy_from_catalogrH      s    ( 5
!
!
!C
E==# > 
 
  E E E	///000jen8999uDE HX\   - 
A37A..A3c                    t          |          }	 |                    |          }nI# t          $ r<}t          j        d|            t          j        |j        j                  |d}~ww xY wt          j	        d|i           dS )zList available Catalog models.r   zCatalog fetch failed: r   Nmodels)
r	   list_inference_catalogr   r   r'   r(   r)   r*   r+   r0   )r   r   r2   rK   r'   s        r6   list_catalogrM      s    
 5
!
!
!CE++%+88 E E E	2522333jen8999uDE Hh     s   ) 
A/7A**A/zhf endpoints catalog lszlist-catalogT)r   hiddencatalogr   z!hf endpoints describe my-endpointc                    t          |          }	 |                    | ||          }nI# t          $ r<}t          j        d|            t          j        |j        j                  |d}~ww xY wt          j	        |j
                   dS )z+Get information about an existing endpoint.r   r   r   r   zFetch failed: r   N)r	   get_inference_endpointr   r   r'   r(   r)   r*   r+   r0   r,   r   r   r   r   r2   r5   r'   s          r6   describerU      s     5
!
!
!CE--49TY-ZZ E E E	*5**+++jen8999uDE HX\   + 
A17A,,A1z/hf endpoints update my-endpoint --min-replica 2zBThe machine learning framework used for the model (e.g. 'custom').revisionzrThe specific model revision to deploy on the Inference Endpoint (e.g. '6c0e6080953db56375760c0471a8c5f2929baf11').c                 6   t          |          }	 |                    | |||||||||	|
||||          }nI# t          $ r<}t          j        d|            t          j        |j        j                  |d}~ww xY wt          j	        |j
                   dS )zUpdate an existing endpoint.r   )r   r   r   r    rW   r   r?   r@   rA   r9   r:   r;   r<   r=   r   zUpdate failed: r   N)r	   update_inference_endpointr   r   r'   r(   r)   r*   r+   r0   r,   )r   r   r>   r?   r@   rA   r    rW   r   r9   r:   r;   r<   r=   r   r   r2   r5   r'   s                      r6   updaterZ     s    ` 5
!
!
!CE00#''##"7)/ 1 
 
"  E E E	+E++,,,jen8999uDE HX\s   $7 
A=7A88A=zhf endpoints delete my-endpointFyesz--yeszSkip confirmation prompts.c                 T   t          j        d|  d|           t          |          }	 |                    | ||           nI# t          $ r<}t          j        d|            t          j        |j        j	                  |d}~ww xY wt          j
        d	|  d
|            dS )z)Delete an Inference Endpoint permanently.zDelete endpoint 'z'?)r[   r   rR   zDelete failed: r   Nz	Deleted 'z'.rP   )r   confirmr	   delete_inference_endpointr   r'   r(   r)   r*   r+   result)r   r   r[   r   r   r2   r'   s          r6   deleter`   j  s     K,D,,,#6666
5
!
!
!CE%%49E%RRRR E E E	+E++,,,jen8999uDE J#4###$//////s   A 
B7BBzhf endpoints pause my-endpointc                    t          |          }	 |                    | ||          }nI# t          $ r<}t          j        d|            t          j        |j        j                  |d}~ww xY wt          j	        |j
                   dS )zPause an Inference Endpoint.r   rR   zPause failed: r   N)r	   pause_inference_endpointr   r   r'   r(   r)   r*   r+   r0   r,   rT   s          r6   pauserc     s     5
!
!
!CE//TYV[/\\ E E E	*5**+++jen8999uDE HX\rV   zhf endpoints resume my-endpointfail_if_already_runningz--fail-if-already-runningzWIf `True`, the method will raise an error if the Inference Endpoint is already running.c                 "   t          |          }	 |                    | |||           }nI# t          $ r<}t          j        d|            t          j        |j        j                  |d}~ww xY wt          j	        |j
                   dS )zResume an Inference Endpoint.r   )r   r   r   
running_okzResume failed: r   N)r	   resume_inference_endpointr   r   r'   r(   r)   r*   r+   r0   r,   )r   r   rd   r   r   r2   r5   r'   s           r6   resumerh     s     5
!
!
!C	E0022	 1 
 
  E E E	+E++,,,jen8999uDE HX\rI   z&hf endpoints scale-to-zero my-endpointc                    t          |          }	 |                    | ||          }nI# t          $ r<}t          j        d|            t          j        |j        j                  |d}~ww xY wt          j	        |j
                   dS )z$Scale an Inference Endpoint to zero.r   rR   zScale To Zero failed: r   N)r	    scale_to_zero_inference_endpointr   r   r'   r(   r)   r*   r+   r0   r,   rT   s          r6   scale_to_zerork     s     5
!
!
!CE77TY^c7dd E E E	2522333jen8999uDE HX\rV   )(__doc__typingr   r(   $huggingface_hub._inference_endpointsr   huggingface_hub.errorsr   
_cli_utilsr   r   r	   r
   _outputr   r   ie_clicatalog_appstrArgumentNameArgOptionNameOptNamespaceOptcommandautor7   intfloatr8   rH   rM   	add_typerrU   rZ   boolr`   rc   rh   rk    rD   r6   <module>r      s   8 8        O O O O O O 1 1 1 1 1 1 N N N N N N N N N N N N . . . . . . . . 
F	G	G	Gm!QRRR EN()))+ $JEL&''')
 $JELn   '8:^&_``" 4 9 &  & & &  & 
	 &  &  & a` &F X)n(opp\ # 	 4 9 	
 	
 	 	 	gi i i
i
x	
 	
 	
	i S	
 	
 	
	i R	
 	
 	
	i( a	
 	
 	
	)i4 l	
 	
 	
	5i@ g	
 	
 	
	AiL i	
 	
 	
	MiZ [i\ d
V	
 	
 	
	]ih iij kil i	
 	
 	
	mix e	
 	
 	
	yiD %d
Y	
 	
 	
	EiP &-4	
 	
 	
	Qi\ !x	
 	
 	
	]ih 
ii i i qpiX (.s-tuu  	" 4 9!   
x	
 	
 	
	    d
c	
 	
 	
	       ! " 
#      vu H !5 9! !!! 
! ! ! ! L  0I/J  K KL Y Y Y 0N4 0 0 > > >   9  - - - =>?? # 4 9	 
  	
 
   @?" KLMM # 	 	 	 	 	 	 	 	 	 	 	 	 4 9Ye e
ee d
x	
 	
 	
	e d
R	
 	
 	
	e d
a	
 	
 	
	e* d
l	
 	
 	
	+e6 d
U	
 	
 	
	7eB d
 F	
 	
 	
	CeN d
V	
 	
 	
	OeZ d
i	
 	
 	
	[ef d
e	
 	
 	
	ger %d
Y	
 	
 	
	se~ &-4	
 	
 	
	eJ !x	
 	
 	
	KeV WeX YeZ 
[e e e NMeP ;<== # 	 4 90 0
00 
W#?@@@	B
0 0 0 
0 0 0 >=0. :;<< # 4 9	 
  	
 
   =<" ;<== # 	 4 9 
 ''j	
 	
 	
	   
   >=8 BCDD # 4 9	 
  	
 
   ED  rD   