o
    i|                     @   s8  d dl Z d dlmZ ddlmZ ddl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 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 dZ/G dd dZ0dS )    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)BadRequestError)ClientClosedRequestError)ForbiddenError)GatewayTimeoutError)InternalServerError)InvalidTokenError)NotFoundError)NotImplementedError)ServiceUnavailableError)TooManyRequestsError)UnauthorizedError)UnprocessableEntityError)CompatibleEndpoint)GetModelResponse)ListModelsResponsec                   @      e Zd ZdefddZdddedeje de	e
 fd	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	e fddZdS )RawModelsClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r$   ^/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/cohere/models/raw_client.py__init__      
zRawModelsClient.__init__Nrequest_optionsmodelr)   returnc             	   C   s  | j jjdt| d|d}zd|j  krdk r1n ntttt|	 d}t
||dW S |jdkrQtt|jttjtj ttjtj |	 dd	|jd
krqtt|jttjtj ttjtj |	 dd	|jdkrtt|jttjtj ttjtj |	 dd	|jdkrtt|jttjtj ttjtj |	 dd	|jdkrtt|jttjtj ttjtj |	 dd	|jdkrtt|jttjtj ttjtj |	 dd	|jdkrtt|jttjtj ttjtj |	 dd	|jdkr3tt|jttjtj ttjtj |	 dd	|jdkrTtt|jttjtj ttjtj |	 dd	|jdkrutt|jttjtj ttjtj |	 dd	|jdkrtt|jttjtj ttjtj |	 dd	|jdkrtt|jttjtj ttjtj |	 dd	|	 }W n ty   t|jt|j|jdw t|jt|j|d)a=  
        Returns the details of a model, provided its name.

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

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

        Returns
        -------
        HttpResponse[GetModelResponse]
            OK
        
v1/models/GETmethodr)      ,  type_object_responsedata  headersbody                      status_coder:   r;   )r!   httpx_clientrequestr	   rH   typingcastr   r   jsonr   r   dictr:   OptionalAnyr   r   r   r   r   r   r   r   r   r   r   r   r   textr#   r*   r)   	_response_data_response_jsonr$   r$   r%   get!   s0  









































zRawModelsClient.get	page_size
page_tokenendpointdefault_onlyr)   rX   rY   rZ   r[   c          	   	   C   s  | j jjdd||||d|d}zd|j  krdk r2n ntttt| d}t	||dW S |jd	krRt
t|jttjtj ttjtj | dd
|jdkrrtt|jttjtj ttjtj | dd
|jdkrtt|jttjtj ttjtj | dd
|jdkrtt|jttjtj ttjtj | dd
|jdkrtt|jttjtj ttjtj | dd
|jdkrtt|jttjtj ttjtj | dd
|jdkrtt|jttjtj ttjtj | dd
|jdkr4tt|jttjtj ttjtj | dd
|jdkrUtt|jttjtj ttjtj | dd
|jdkrvtt|jttjtj ttjtj | dd
|jdkrtt|jttjtj ttjtj | dd
|jdkrtt|jttjtj ttjtj | dd
| }W n ty   t|jt|j|jdw t|jt|j|d)a  
        Returns a list of models available for use.

        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
        -------
        HttpResponse[ListModelsResponse]
            OK
        	v1/modelsr-   rX   rY   rZ   r[   r/   paramsr)   r0   r1   r2   r5   r8   r9   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   )r!   rI   rJ   rH   rK   rL   r   r   rM   r   r   rN   r:   rO   rP   r   r   r   r   r   r   r   r   r   r   r   r   r   rQ   	r#   rX   rY   rZ   r[   r)   rS   rT   rU   r$   r$   r%   list   s:  #









































zRawModelsClient.list)__name__
__module____qualname__r   r&   strrK   rO   r
   r   r   rV   floatr   boolr   ra   r$   r$   r$   r%   r      :    
 .r   c                   @   r   )AsyncRawModelsClientr   c                C   r   r   r    r"   r$   r$   r%   r&     r'   zAsyncRawModelsClient.__init__Nr(   r*   r)   r+   c             	      s  | j jjdt| d|dI dH }zd|j  kr dk r5n ntttt|	 d}t
||dW S |jd	krUtt|jttjtj ttjtj |	 dd
|jdkrutt|jttjtj ttjtj |	 dd
|jdkrtt|jttjtj ttjtj |	 dd
|jdkrtt|jttjtj ttjtj |	 dd
|jdkrtt|jttjtj ttjtj |	 dd
|jdkrtt|jttjtj ttjtj |	 dd
|jdkrtt|jttjtj ttjtj |	 dd
|jdkr7tt|jttjtj ttjtj |	 dd
|jdkrXtt|jttjtj ttjtj |	 dd
|jdkrytt|jttjtj ttjtj |	 dd
|jdkrtt|jttjtj ttjtj |	 dd
|jdkrtt|jttjtj ttjtj |	 dd
|	 }W n ty   t|jt|j|jdw t|jt|j|d)aB  
        Returns the details of a model, provided its name.

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

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

        Returns
        -------
        AsyncHttpResponse[GetModelResponse]
            OK
        r,   r-   r.   Nr0   r1   r2   r5   r8   r9   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   )r!   rI   rJ   r	   rH   rK   rL   r   r   rM   r   r   rN   r:   rO   rP   r   r   r   r   r   r   r   r   r   r   r   r   r   rQ   rR   r$   r$   r%   rV     s2  









































zAsyncRawModelsClient.getrW   rX   rY   rZ   r[   c          	   	      s  | j jjdd||||d|dI dH }zd|j  kr!dk r6n ntttt| d}t	||d	W S |jd
krVt
t|jttjtj ttjtj | dd|jdkrvtt|jttjtj ttjtj | dd|jdkrtt|jttjtj ttjtj | dd|jdkrtt|jttjtj ttjtj | dd|jdkrtt|jttjtj ttjtj | dd|jdkrtt|jttjtj ttjtj | dd|jdkrtt|jttjtj ttjtj | dd|jdkr8tt|jttjtj ttjtj | dd|jdkrYtt|jttjtj ttjtj | dd|jdkrztt|jttjtj ttjtj | dd|jdkrtt|jttjtj ttjtj | dd|jdkrtt|jttjtj ttjtj | dd| }W n ty   t|jt|j|jdw t|jt|j|d)a  
        Returns a list of models available for use.

        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
        -------
        AsyncHttpResponse[ListModelsResponse]
            OK
        r\   r-   r]   r^   Nr0   r1   r2   r5   r8   r9   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   )r!   rI   rJ   rH   rK   rL   r   r   rM   r   r   rN   r:   rO   rP   r   r   r   r   r   r   r   r   r   r   r   r   r   rQ   r`   r$   r$   r%   ra   ;  s<  #









































zAsyncRawModelsClient.list)rb   rc   rd   r   r&   re   rK   rO   r
   r   r   rV   rf   r   rg   r   ra   r$   r$   r$   r%   ri     rh   ri   )1rK   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r   core.jsonable_encoderr	   core.request_optionsr
   core.unchecked_base_modelr   errors.bad_request_errorr   "errors.client_closed_request_errorr   errors.forbidden_errorr   errors.gateway_timeout_errorr   errors.internal_server_errorr   errors.invalid_token_errorr   errors.not_found_errorr   errors.not_implemented_errorr    errors.service_unavailable_errorr   errors.too_many_requests_errorr   errors.unauthorized_errorr   !errors.unprocessable_entity_errorr   types.compatible_endpointr   types.get_model_responser   types.list_models_responser   r   ri   r$   r$   r$   r%   <module>   s6     r