
    gs                     <   d dl mZ ddlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm Z  d dl!m"Z" ddl#m$Z$ d dl%m&Z& d dl'm(Z( d dl)m*Z* d dl m+Z+  G d d      Z, G d d      Z-y)   )SyncClientWrapper    N)RequestOptions)GetModelResponse)jsonable_encoder)construct_type)BadRequestError)UnauthorizedError)ForbiddenError)NotFoundError)UnprocessableEntityError)TooManyRequestsError)InvalidTokenError)ClientClosedRequestError)InternalServerError)NotImplementedError)ServiceUnavailableError)GatewayTimeoutError)JSONDecodeError)ApiError)CompatibleEndpoint)ListModelsResponse)AsyncClientWrapperc                       e Zd ZdefdZdddedej                  e   de	fdZ
dddddd	d
ej                  e   dej                  e   dej                  e   dej                  e   dej                  e   defdZy)ModelsClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     I/var/www/openai/venv/lib/python3.12/site-packages/cohere/models/client.py__init__zModelsClient.__init__   
    -    Nrequest_optionsmodelr(   returnc          
      ,   | j                   j                  j                  dt        |       d|      }	 d|j                  cxk  rdk  r:n n7t        j                  t        t        t        |j                                     S |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d	k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d
k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt!        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt#        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt%        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt'        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt)        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt+        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt-        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt/        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                         }t3        |j                  |      # t0        $ r" t3        |j                  |j4                        w xY w)a(  
        Returns the details of a model, provided its name.

        Parameters
        ----------
        model : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetModelResponse
            OK

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.models.get(
            model="command-r",
        )
        
v1/models/GETmethodr(      ,  type_object_                        status_codebodyr    httpx_clientrequestr   rB   typingcastr   r   jsonr	   OptionalAnyr
   r   r   r   r   r   r   r   r   r   r   r   r   textr"   r)   r(   	_response_response_jsons        r#   getzModelsClient.get    s   8 ((55==)%012+ > 
	
C	Si++1c1{{$". ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

3&"(//&**"=$-NN$4  $$+#KK

3&"(//&**"=$-NN$4  $$+.KK

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+.KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   A[( Y[( (+\	page_size
page_tokenendpointdefault_onlyr(   rR   rS   rT   rU   c          
          | j                   j                  j                  dd||||d|      }	 d|j                  cxk  rdk  r:n n7t	        j
                  t        t        t        |j                                     S |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  d	k(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  d
k(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt!        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt#        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt%        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt'        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt)        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt+        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt-        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                         }t1        |j                  |      # t.        $ r" t1        |j                  |j2                        w xY w)a  
        Returns a list of models available for use. The list contains models from Cohere as well as your fine-tuned models.

        Parameters
        ----------
        page_size : typing.Optional[float]
            Maximum number of models to include in a page
            Defaults to `20`, min value of `1`, max value of `1000`.

        page_token : typing.Optional[str]
            Page token provided in the `next_page_token` field of a previous response.

        endpoint : typing.Optional[CompatibleEndpoint]
            When provided, filters the list of models to only those that are compatible with the specified endpoint.

        default_only : typing.Optional[bool]
            When provided, filters the list of models to only the default model to the endpoint. This parameter is only valid when `endpoint` is provided.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ListModelsResponse
            OK

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.models.list()
        	v1/modelsr-   rR   rS   rT   rU   r/   paramsr(   r0   r1   r2   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   r    rE   rF   rB   rG   rH   r   r   rI   r	   rJ   rK   r
   r   r   r   r   r   r   r   r   r   r   r   r   rL   r"   rR   rS   rT   rU   r(   rN   rO   s           r#   listzModelsClient.list   s   Z ((55==&($ ,	 , > 

	C	Si++1c1{{&"0 ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

3&"(//&**"=$-NN$4  $$+#KK

3&"(//&**"=$-NN$4  $$+.KK

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+.KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   A[" ?Y[" "+\)__name__
__module____qualname__r   r$   strrG   rJ   r   r   rP   floatr   boolr   r]    r&   r#   r   r      s    .*; . UY eO eO&//.2Q eO]m eOT -1+/8<.2;?|O ??5)|O OOC(	|O
 //"45|O ood+|O  8|O 
|Or&   r   c                       e Zd ZdefdZdddedej                  e   de	fdZ
dddddd	d
ej                  e   dej                  e   dej                  e   dej                  e   dej                  e   defdZy)AsyncModelsClientr   c                    || _         y r   r   r!   s     r#   r$   zAsyncModelsClient.__init__  r%   r&   Nr'   r)   r(   r*   c          
      J  K   | j                   j                  j                  dt        |       d|       d{   }	 d|j                  cxk  rdk  r:n n7t        j                  t        t        t        |j                                     S |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d	k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d
k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt!        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt#        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt%        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt'        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt)        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt+        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt-        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt/        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                         }t3        |j                  |      7 # t0        $ r" t3        |j                  |j4                        w xY ww)a  
        Returns the details of a model, provided its name.

        Parameters
        ----------
        model : str

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetModelResponse
            OK

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.models.get(
                model="command-r",
            )


        asyncio.run(main())
        r,   r-   r.   Nr0   r1   r2   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rD   rM   s        r#   rP   zAsyncModelsClient.get  s!    H ..;;CC)%012+ D 
 
	
C	Si++1c1{{$". ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

3&"(//&**"=$-NN$4  $$+#KK

3&"(//&**"=$-NN$4  $$+.KK

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+.KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NNS
N  	Sy'<'<9>>RR	Ss5   8\#[2\# A[5 \#Y[5 \#5+\  \#rQ   rR   rS   rT   rU   c          
      >  K   | j                   j                  j                  dd||||d|       d{   }	 d|j                  cxk  rdk  r:n n7t	        j
                  t        t        t        |j                                     S |j                  d	k(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  d
k(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt!        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt#        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt%        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt'        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt)        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt+        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt-        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                         }t1        |j                  |      7 # t.        $ r" t1        |j                  |j2                        w xY ww)a@  
        Returns a list of models available for use. The list contains models from Cohere as well as your fine-tuned models.

        Parameters
        ----------
        page_size : typing.Optional[float]
            Maximum number of models to include in a page
            Defaults to `20`, min value of `1`, max value of `1000`.

        page_token : typing.Optional[str]
            Page token provided in the `next_page_token` field of a previous response.

        endpoint : typing.Optional[CompatibleEndpoint]
            When provided, filters the list of models to only those that are compatible with the specified endpoint.

        default_only : typing.Optional[bool]
            When provided, filters the list of models to only the default model to the endpoint. This parameter is only valid when `endpoint` is provided.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ListModelsResponse
            OK

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.models.list()


        asyncio.run(main())
        rW   r-   rX   rY   Nr0   r1   r2   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   r[   r\   s           r#   r]   zAsyncModelsClient.list9  s&    j ..;;CC&($ ,	 , D 

 

	C	Si++1c1{{&"0 ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

3&"(//&**"=$-NN$4  $$+#KK

3&"(//&**"=$-NN$4  $$+.KK

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+.KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NN_

Z  	Sy'<'<9>>RR	Ss4   2\[,\A[/ \	Y[/ \/+\\)r^   r_   r`   r   r$   ra   rG   rJ   r   r   rP   rb   r   rc   r   r]   rd   r&   r#   rf   rf     s    .*< . [_ mOs mO8W mOcs mOd -1+/8<.2;?DO ??5)DO OOC(	DO
 //"45DO ood+DO  8DO 
DOr&   rf   ).core.client_wrapperr   rG   core.request_optionsr   types.get_model_responser   core.jsonable_encoderr   core.unchecked_base_modelr   errors.bad_request_errorr	   errors.unauthorized_errorr
   errors.forbidden_errorr   errors.not_found_errorr   !errors.unprocessable_entity_errorr   errors.too_many_requests_errorr   errors.invalid_token_errorr   "errors.client_closed_request_errorr   errors.internal_server_errorr   errors.not_implemented_errorr    errors.service_unavailable_errorr   errors.gateway_timeout_errorr   json.decoderr   core.api_errorr   types.compatible_endpointr   types.list_models_responser   r   r   rf   rd   r&   r#   <module>r      si    4  1 7 4 6 6 9 3 2 H A : I > > F > ( % : ; 4gO gOTwO wOr&   