o
    iz                     @   s   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ dd	lmZmZmZmZ G d
d deZdS )zACode generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.   )BaseSDK    )modelsutils)HookContext)OptionalNullableUNSET)get_security_from_env)unmarshal_json_response)AnyMappingOptionalUnionc                   @   s  e Zd ZdZedddddedeejej	f de
ej dee dee d	eeeef  d
ejfddZedddddedeejej	f de
ej dee dee d	eeeef  d
ejfddZedddddeejejf dede
ej dee dee d	eeeef  d
ejfddZedddddeejejf dede
ej dee dee d	eeeef  d
ejfddZedddddedeejej	f de
ej dee dee d	eeeef  d
ejfddZedddddedeejej	f de
ej dee dee d	eeeef  d
ejfddZedddddedeejejf de
ej dee dee d	eeeef  d
ejfddZedddddedeejejf de
ej dee dee d	eeeef  d
ejfddZdS )ClassifierszClassifiers API.N)retries
server_url
timeout_mshttp_headersmodelinputsr   r   r   r   returnc                   |  d}d}|du r| j j}|dur|}n| ||}tj||d | jdd|| ddddd|| j j fd	d
|d}	|tkrG| j jturG| j j}d}
t	|t
jrU|g df}
| jt| j |p]ddg t| j jtjd|	g d|
d}d}t
|ddrttj|S t
|ddrttj|}t||t
|ddrt
|}td||t
|ddrt
|}td||td|)  Moderations

        :param model: ID of the model to use.
        :param inputs: Text to classify.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        Nr   r   POST/v1/moderationsTF
user-agentapplication/jsonc                         t  dddtjS NFjsonr   serialize_request_bodyr   ClassificationRequest requestr$   [/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/mistralai/classifiers.py<lambda>A       z&Classifiers.moderate.<locals>.<lambda>methodpathbase_urlurl_variablesr&   request_body_requiredrequest_has_path_paramsrequest_has_query_paramsuser_agent_headeraccept_header_valuer   securityget_serialized_bodyr   429500502503504 moderations_v1_moderations_postconfigr-   operation_idoauth2_scopessecurity_source4224XX5XXhook_ctxr&   error_status_codesretry_config200rD   rE   *API error occurredrF   Unexpected response received)sdk_configurationr   _get_urlr   r#   _build_requestr4   r   rJ   
isinstancer   RetryConfig
do_requestr   r	   Securitymatch_responser
   ModerationResponseHTTPValidationErrorDataHTTPValidationErrorstream_to_textSDKErrorselfr   r   r   r   r   r   r-   r.   reqrJ   http_resresponse_datahttp_res_textr$   r%   r'   moderate   |   

	

zClassifiers.moderatec                     d}d}|du r| j j}|dur|}n| ||}tj||d | jdd|| ddddd|| j j fd	d
|d}	|tkrH| j jturH| j j}d}
t	|t
jrV|g df}
| jt| j |p^ddg t| j jtjd|	g d|
dI dH }d}t
|ddrttj|S t
|ddrttj|}t||t
|ddrt
|I dH }td||t
|ddrt
|I dH }td||td|)r   Nr   r   r   TFr   r   c                      r   r   r!   r$   r%   r$   r'   r(      r)   z,Classifiers.moderate_async.<locals>.<lambda>r*   r6   r<   r=   r>   rC   rG   rK   rD   rE   rL   rM   rF   rN   )rO   r   rP   r   r#   _build_request_asyncr4   r   rJ   rR   r   rS   do_request_asyncr   r	   rU   rV   r
   rW   rX   rY   stream_to_text_asyncr[   r\   r$   r%   r'   moderate_asynco   ~   

	zClassifiers.moderate_asyncc                   s  d}d}|du r| j j}|dur|}n| ||}tjt|tj|d | jdd|| ddddd|| j j	 fd	d
|d}	|t
krL| j jt
urL| j j}d}
t|tjrZ|g df}
| jt| j |pbddg t| j j	tjd|	g d|
d}d}t|ddrttj|S t|ddrttj|}t||t|ddrt|}td||t|ddrt|}td||td|)  Chat Moderations

        :param inputs: Chat to classify
        :param model:
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        Nr   r   r   /v1/chat/moderationsTFr   r   c                      r   r   r   r"   r   ChatModerationRequestr$   r%   r$   r'   r(     r)   z+Classifiers.moderate_chat.<locals>.<lambda>r*   r6   r<   )chat_moderations_v1_chat_moderations_postr>   rC   rG   rK   rD   rE   rL   rM   rF   rN   )rO   r   rP   r   rn   r   get_pydantic_modelChatModerationRequestInputsrQ   r4   r   rJ   rR   rS   rT   r   r	   rU   rV   r
   rW   rX   rY   rZ   r[   r]   r   r   r   r   r   r   r-   r.   r^   rJ   r_   r`   ra   r$   r%   r'   moderate_chat   s|   

	

zClassifiers.moderate_chatc                   s  d}d}|du r| j j}|dur|}n| ||}tjt|tj|d | jdd|| ddddd|| j j	 fd	d
|d}	|t
krM| j jt
urM| j j}d}
t|tjr[|g df}
| jt| j |pcddg t| j j	tjd|	g d|
dI dH }d}t|ddrttj|S t|ddrttj|}t||t|ddrt|I dH }td||t|ddrt|I dH }td||td|)rj   Nrk   r   rl   TFr   r   c                      r   r   rm   r$   r%   r$   r'   r(   a  r)   z1Classifiers.moderate_chat_async.<locals>.<lambda>r*   r6   r<   ro   r>   rC   rG   rK   rD   rE   rL   rM   rF   rN   )rO   r   rP   r   rn   r   rp   rq   re   r4   r   rJ   rR   rS   rf   r   r	   rU   rV   r
   rW   rX   rY   rg   r[   rr   r$   r%   r'   moderate_chat_async/  s~   

	zClassifiers.moderate_chat_asyncc                   r   )  Classifications

        :param model: ID of the model to use.
        :param inputs: Text to classify.
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        Nr   r   /v1/classificationsTFr   r   c                      r   r   r!   r$   r%   r$   r'   r(     r)   z&Classifiers.classify.<locals>.<lambda>r*   r6   r<   'classifications_v1_classifications_postr>   rC   rG   rK   rD   rE   rL   rM   rF   rN   )rO   r   rP   r   r#   rQ   r4   r   rJ   rR   r   rS   rT   r   r	   rU   rV   r
   ClassificationResponserX   rY   rZ   r[   r\   r$   r%   r'   classify  rc   zClassifiers.classifyc                   rd   )ru   Nr   r   rv   TFr   r   c                      r   r   r!   r$   r%   r$   r'   r(   !  r)   z,Classifiers.classify_async.<locals>.<lambda>r*   r6   r<   rw   r>   rC   rG   rK   rD   rE   rL   rM   rF   rN   )rO   r   rP   r   r#   re   r4   r   rJ   rR   r   rS   rf   r   r	   rU   rV   r
   rx   rX   rY   rg   r[   r\   r$   r%   r'   classify_async  ri   zClassifiers.classify_asyncc                   s  d}d}|du r| j j}|dur|}n| ||}tj|t|tjd | jdd|| ddddd|| j j	 fd	d
|d}	|t
krL| j jt
urL| j j}d}
t|tjrZ|g df}
| jt| j |pbddg t| j j	tjd|	g d|
d}d}t|ddrttj|S t|ddrttj|}t||t|ddrt|}td||t|ddrt|}td||td|)  Chat Classifications

        :param model:
        :param inputs: Chat to classify
        :param retries: Override the default retry configuration for this method
        :param server_url: Override the default server URL for this method
        :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
        :param http_headers: Additional headers to set or replace on requests.
        Nr   r   /v1/chat/classificationsTFr   r   c                      r   r   r   r"   r   ChatClassificationRequestr$   r%   r$   r'   r(   ~  r)   z+Classifiers.classify_chat.<locals>.<lambda>r*   r6   r<   1chat_classifications_v1_chat_classifications_postr>   rC   rG   rK   rD   rE   rL   rM   rF   rN   )rO   r   rP   r   r~   r   rp   InputsrQ   r4   r   rJ   rR   rS   rT   r   r	   rU   rV   r
   rx   rX   rY   rZ   r[   r\   r$   r%   r'   classify_chatO  s|   

	

zClassifiers.classify_chatc                   s  d}d}|du r| j j}|dur|}n| ||}tj|t|tjd | jdd|| ddddd|| j j	 fd	d
|d}	|t
krM| j jt
urM| j j}d}
t|tjr[|g df}
| jt| j |pcddg t| j j	tjd|	g d|
dI dH }d}t|ddrttj|S t|ddrttj|}t||t|ddrt|I dH }td||t|ddrt|I dH }td||td|)r{   Nr   r   r|   TFr   r   c                      r   r   r}   r$   r%   r$   r'   r(     r)   z1Classifiers.classify_chat_async.<locals>.<lambda>r*   r6   r<   r   r>   rC   rG   rK   rD   rE   rL   rM   rF   rN   )rO   r   rP   r   r~   r   rp   r   re   r4   r   rJ   rR   rS   rf   r   r	   rU   rV   r
   rx   rX   rY   rg   r[   r\   r$   r%   r'   classify_chat_async  s~   

	zClassifiers.classify_chat_async)__name__
__module____qualname____doc__r   strr   r   ClassificationRequestInputs$ClassificationRequestInputsTypedDictr   r   rS   r   intr   rW   rb   rh   rq   $ChatModerationRequestInputsTypedDictrs   rt   rx   ry   rz   r   InputsTypedDictr   r   r$   r$   r$   r'   r      sd   
	

h	

h	

h	

h	

h	

e	
b	r   N)r   basesdkr   	mistralair   r   mistralai._hooksr   mistralai.typesr   r   mistralai.utilsr	   'mistralai.utils.unmarshal_json_responser
   typingr   r   r   r   r   r$   r$   r$   r'   <module>   s    