
    j6              &       J   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 ddl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          	 	 dVdede	ddfd            Ze                    ddg          dd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e ej        d,
          f         d-ee ej        d.
          f         d/eedz   ej        d0
          f         d1eedz   ej        d2
          f         d3eedz   ej        d4
          f         ddf"d5            Ze                    dd6g          	 	 	 	 dWdee ej        d
          f         dedeedz   ej        d7
          f         dede	ddfd8            Z	 dXde	ddfd9Z e                    dd:g          e            e                    d;d<=          e           e                    ed>?           e                    d@g          	 	 dVdedede	ddfdA            Ze                    dBg          	 	 	 	 	 	 	 	 	 	 	 	 	 	 dYd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        dC
          f         dDeedz   ej        dE
          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        d0
          f         d1eedz   ej        d2
          f         d3eedz   ej        d4
          f         de	ddf dF            Ze                    dGg          	 	 	 dZdededIee  ej        dJdK
          f         de	ddf
dL            Z!e                    dMg          	 	 dVdedede	ddfdN            Z"e                    dOg          	 	 	 dZdededPee  ej        dQdR
          f         de	ddf
dS            Z#e                    dTg          	 	 dVdedede	ddfdU            Z$dS )[z2CLI commands for Hugging Face Inference Endpoints.    )	AnnotatedN)InferenceEndpointScalingMetric)HfHubHTTPError   )TokenOpt
get_hf_apityper_factory)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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   api	endpointsr$   resultsendpointr)   r   r   r   r   s               j/var/www/html/Carbon-Document/venv/lib/python3.11/site-packages/huggingface_hub/cli/inference_endpoints.pylsr4   $   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   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').r6   zVThe minimum number of replicas (instances) to keep running for the Inference Endpoint.r7   zRThe maximum number of replicas (instances) to scale to for the Inference Endpoint.r8   zFThe duration in minutes before an inactive endpoint is scaled to zero.r9   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=   r>   r    r   r   r   r   r6   r7   r9   r:   r8   N)r   create_inference_endpointr
   r-   r)   )r   r;   r   r<   r=   r>   r    r   r   r   r   r6   r7   r8   r9   r:   r/   r2   s                     r3   r5   r5   G   sy    l 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(   r-   r)   )r;   r   r<   r   r   r/   r2   r$   s           r3   deploy_from_catalogrE      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(   r-   )r   r/   rH   r$   s       r3   list_catalogrJ      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(   r-   r)   r   r   r   r/   r2   r$   s         r3   describerR      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   rT   r   r<   r=   r>   r6   r7   r8   r9   r:   r   zUpdate failed: r   N)r   update_inference_endpointr   r
   r$   r%   r&   r'   r(   r-   r)   )r   r   r;   r<   r=   r>   r   rT   r   r6   r7   r8   r9   r:   r   r/   r2   r$   s                     r3   updaterW      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'?)rX   r   rO   zDelete failed: r   Nz	Deleted 'z'.rM   )r
   confirmr   delete_inference_endpointr   r$   r%   r&   r'   r(   result)r   r   rX   r   r/   r$   s         r3   deleter]   d  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   rO   zPause failed: r   N)r   pause_inference_endpointr   r
   r$   r%   r&   r'   r(   r-   r)   rQ   s         r3   pauser`   {  s     5
!
!
!CE//TYV[/\\ E E E	*5**+++jen8999uDE HX\rS   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(   r-   r)   )r   r   ra   r   r/   r2   r$   s          r3   resumere     s     5
!
!
!C	E0022	 1 
 
  E E E	+E++,,,jen8999uDE HX\rF   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   rO   zScale To Zero failed: r   N)r    scale_to_zero_inference_endpointr   r
   r$   r%   r&   r'   r(   r-   r)   rQ   s         r3   scale_to_zerorh     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\rS   )NN)NNNN)N)NNNNNNNNNNNNNN)NFN)%__doc__typingr   r%   $huggingface_hub._inference_endpointsr   huggingface_hub.errorsr   
_cli_utilsr   r   r	   _outputr
   ie_clicatalog_appstrArgumentNameArgOptionNameOptNamespaceOptcommandr4   intfloatr5   rE   rJ   	add_typerrR   rW   boolr]   r`   re   rh    rA   r3   <module>r}      s   8 8        O O O O O O 1 1 1 1 1 1 ; ; ; ; ; ; ; ; ; ;       
F	G	G	Gm!QRRR EN()))+ $JEL&''')
 $JELn   '8:^&_``"& &&& 
& & & a`&D X)n(opp\ # 	 	
 	
 	 	 	eh h h
h
x	
 	
 	
	h S	
 	
 	
	h R	
 	
 	
	h( a	
 	
 	
	)h4 l	
 	
 	
	5h@ g	
 	
 	
	AhL i	
 	
 	
	MhZ [h\ d
V	
 	
 	
	]hh ihj i	
 	
 	
	khv e	
 	
 	
	whB %d
Y	
 	
 	
	ChN &-4	
 	
 	
	OhZ !x	
 	
 	
	[hf 
gh h h qphV (.s-tuu  	" 
x	
 	
 	
	  d
c	
 	
 	
	    
!   vuF ! !!	! ! ! ! L  0I/J  K KL Y Y Y 0N4 0 0 > > >   9  - - - =>?? # 
  
	   @?  KLMM # 	 	 	 	 	 	 	 	 	 	 	 	Wd d
dd d
x	
 	
 	
	d d
R	
 	
 	
	d d
a	
 	
 	
	d* d
l	
 	
 	
	+d6 d
U	
 	
 	
	7dB d
 F	
 	
 	
	CdN d
V	
 	
 	
	OdZ d
i	
 	
 	
	[df d
e	
 	
 	
	gdr %d
Y	
 	
 	
	sd~ &-4	
 	
 	
	dJ !x	
 	
 	
	KdV WdX 
Yd d d NMdN ;<== # 	0 0
00 
W#?@@@	B
0 0 
0 0 0 >=0, :;<< # 
  
	   =<  ;<== # 	 
 ''j	
 	
 	
	  
   >=6 BCDD # 
  
	   ED  rA   