o
    i,                     @   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
mZ ddlmZ ddlmZ dd	lmZ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)NullableOptionalNullableUNSET)get_security_from_env)unmarshal_json_response)AnyListMappingOptionalUnionc                   @   s  e Zd ZdZdeeeeeeedddddee deej	ej
f dee deee  dee d	ee d
ee deeejejf  de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eeeeeeedddddee deej	ej
f dee deee  dee d	ee d
ee deeejejf  de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 )OcrzOCR APIN)idpagesinclude_image_base64image_limitimage_min_sizebbox_annotation_formatdocument_annotation_formatretries
server_url
timeout_mshttp_headersmodeldocumentr   r   r   r   r   r   r   r   r   r   r   returnc                   s  d}d}|du r| j j}|dur|}n| ||}tj||t|tj||||t|ttj	 t|	ttj	 d	 | j
dd|| ddddd|| j j fd	d
|d}|
tkra| j jtura| j j}
d}t|
tjro|
g df}| jt| j |pwd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|)o  OCR

        :param model:
        :param document: Document to run OCR on
        :param id:
        :param pages: Specific pages user wants to process in various formats: single number, range, or list of both. Starts from 0
        :param include_image_base64: Include image URLs in response
        :param image_limit: Max images to extract
        :param image_min_size: Minimum height and width of image to extract
        :param bbox_annotation_format: Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field
        :param document_annotation_format: Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field
        :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   r   r   r   r   r   r   POST/v1/ocrTF
user-agentapplication/jsonc                         t  dddtjS NFjsonr   serialize_request_bodyr   
OCRRequest requestr,   S/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/mistralai/ocr.py<lambda>[       zOcr.process.<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 ocr_v1_ocr_postconfigr5   operation_idoauth2_scopessecurity_source4224XX5XXhook_ctxr.   error_status_codesretry_config200rL   rM   *API error occurredrN   Unexpected response received)sdk_configurationr   _get_urlr   r+   r   get_pydantic_modelDocumentr   ResponseFormat_build_requestr<   r	   rR   
isinstanceRetryConfig
do_requestr   r
   Securitymatch_responser   OCRResponseHTTPValidationErrorDataHTTPValidationErrorstream_to_textSDKErrorselfr   r   r   r   r   r   r   r   r   r   r   r   r   r5   r6   reqrR   http_resresponse_datahttp_res_textr,   r-   r/   process   s   %



	

zOcr.processc                   s  d}d}|du r| j j}|dur|}n| ||}tj||t|tj||||t|ttj	 t|	ttj	 d	 | j
dd|| ddddd|| j j fd	d
|d}|
tkrb| j jturb| j j}
d}t|
tjrp|
g df}| jt| j |pxd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/   r0      r1   z#Ocr.process_async.<locals>.<lambda>r2   r>   rD   rE   rF   rK   rO   rS   rL   rM   rT   rU   rN   rV   )rW   r   rX   r   r+   r   rY   rZ   r   r[   _build_request_asyncr<   r	   rR   r]   r^   do_request_asyncr   r
   r`   ra   r   rb   rc   rd   stream_to_text_asyncrf   rg   r,   r-   r/   process_async   s   %



	zOcr.process_async)__name__
__module____qualname____doc__r	   r   strr   r   rZ   DocumentTypedDictr   r   r   intboolr[   ResponseFormatTypedDictr   r^   r   rb   rm   rq   r,   r,   r,   r/   r      s    
	


	
r   N)ru   basesdkr   	mistralair   r   mistralai._hooksr   mistralai.typesr   r   r	   mistralai.utilsr
   'mistralai.utils.unmarshal_json_responser   typingr   r   r   r   r   r   r,   r,   r,   r/   <module>   s    