
    7Mg	,                         d Z ddlmZ ddlZddlmZmZ ddlmZm	Z	m
Z
 ddlmZmZmZ ddlmZmZmZmZ  G d	 d
      Zy)zACode generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.   )SDKConfiguration    N)modelsutils)AfterErrorContextAfterSuccessContextBeforeRequestContext)RetryConfigSerializedRequestBodyget_body_content)CallableListOptionalTuplec            	          e Zd ZU eed<   deddfdZd Z	 	 	 	 	 ddee   dee	g ee
   f      d	ee   dej                  fd
Z	 	 	 	 	 ddee   dee	g ee
   f      d	ee   dej                  fdZ	 	 	 	 	 ddee   dee	g ee
   f      d	ee   dej                  fdZ	 	 ddeeeee   f      dej(                  fdZ	 	 ddeeeee   f      dej(                  fdZy)BaseSDKsdk_configuration
sdk_configreturnNc                     || _         y N)r   )selfr   s     _E:\wamp.anq\www\apps\calme\nutritwin\resources\nutritwin\Lib\site-packages\mistralai/basesdk.py__init__zBaseSDK.__init__   s
    !+    c                 x    | j                   j                         \  }}||}||}t        j                  ||      S r   )r   get_server_detailsr   template_url)r   base_urlurl_variablessdk_urlsdk_variabless        r   get_urlzBaseSDK.get_url   sD    !%!7!7!J!J!LH )M!!(M::r   
timeout_msget_serialized_bodyurl_overridec                 n    | j                   j                  }| j                  ||||||||||	|
|||||      S r   )r   async_clientbuild_request_with_clientr   methodpathr   r    requestrequest_body_requiredrequest_has_path_paramsrequest_has_query_paramsuser_agent_headeraccept_header_value_globalssecurityr$   r%   r&   clients                    r   build_request_asynczBaseSDK.build_request_async    sX    ( ''44--!#$!
 	
r   c                 n    | j                   j                  }| j                  ||||||||||	|
|||||      S r   )r   r5   r)   r*   s                    r   build_requestzBaseSDK.build_requestH   sX    ( ''..--!#$!
 	
r   c           
         i }|}|Nt        j                  | j                  ||      ||r|nd |r|nd       }t        j                  |	r|nd |	r|nd       }t        j                  ||      }||d<   | j
                  j                  ||
<   |t        |      r |       }t        j                  |t        j                        }|$t        j                  |      \  }}i ||}i ||}t        d      }| |       }|r|t        d      ||}|j                  |j                  dvr|j                  |d<   ||dz  nd }|j                  ||||j                   |j"                  |j$                  ||      S )NAcceptzapplication/octet-streamzrequest body is required)zmultipart/form-datazmultipart/mixedzcontent-typei  )paramscontentdatafilesheaderstimeout)r   generate_urlr#   get_query_paramsget_headersr   
user_agentcallableget_security_from_envr   Securityget_securityr   
ValueError
media_typer8   r<   r=   r>   )r   r5   r+   r,   r   r    r-   r.   r/   r0   r1   r2   r3   r4   r$   r%   r&   query_paramsurlr?   security_headerssecurity_query_paramsserialized_request_bodyrbr@   s                            r   r)   z!BaseSDK.build_request_with_clientp   s   * ;$$X}523	C !1134$L
 ##GX6/%)%;%;%F%F!"!#:..xI6;6H6H6R3355$45GDlD.CDL"78R"S*$&B$ !;<<~*,' $..:'22 '>&H&HGN#'1'=*t#4##+33(--)// $ 	
 		
r   retry_configc                    	  j                   j                   j                   j                  		 fd}|1t        j                  |t        j
                  |d   |d               }n |       }t        j                  |j                        s3 j                   j                         j                  t              |      }|S )Nc            	         d } 	 j                   j                         j                  t              
      }	j	                  d|j
                  |j                  |j                  t        |             j                  |      } | &	j	                  d       t        j                  d      	j	                  d| j                  | j                  | j                  rd	n| j                          t#        j$                  | j                        rzj                   j                         j                  t              | d       \  }}|	j	                  dd       |||} | S 	j	                  d
       t        j                  d      | S # t        $ rY}j                   j                         j                  t              d |      \  }}|	j	                  dd       |Y d }~bd }~ww xY wNz0Request:
Method: %s
URL: %s
Headers: %s
Body: %s)streamzRequest ExceptionT)exc_infozRaising no response SDK errorzNo response receivedz6Response:
Status Code: %s
URL: %s
Headers: %s
Body: %sz<streaming response>zRaising unexpected SDK errorzUnexpected error occurredr   	get_hooksbefore_requestr	   debugr+   rL   r?   r   send	Exceptionafter_errorr   r   SDKErrorstatus_codetextr   match_status_codeshttp_resreqe_resulterrr5   error_status_codeshook_ctxloggerr-   r   rU   s         r   dozBaseSDK.do_request.<locals>.do   s   H,,668GG(2G JJJGGKK$S) ";;s6;: <=oo&<==LLL$$  *0&hmm ''(:H<P<PQ"44>>@LL%h/4 ?LL!4tLDI%%H
 O LL!?@ //*EFFOC  --779EE%h/q1 =LL!4tLDG !	s   BF 	G.AG))G.r   r   )r   r5   debug_loggerr   retryRetriesra   r_   rX   after_successr   
r   rj   r-   ri   rU   rQ   rl   rc   r5   rk   s
   `````   @@r   
do_requestzBaseSDK.do_request   s     ''..''44/	 /	b #{{2u}}\!_lSTo'VWHtH''(:H<P<PQ--779GG#H-xH r   c                    	K    j                   j                   j                   j                  		 fd}|9t        j                  |t        j
                  |d   |d                d {   }n |        d {   }t        j                  |j                        s3 j                   j                         j                  t              |      }|S 7 i7 [w)Nc            	         K   d } 	 j                   j                         j                  t              
      }	j	                  d|j
                  |j                  |j                  t        |             j                  |       d {   } | &	j	                  d       t        j                  d      	j	                  d| j                  | j                  | j                  rd	n| j                          t#        j$                  | j                        rzj                   j                         j                  t              | d       \  }}|	j	                  dd       |||} | S 	j	                  d
       t        j                  d      | S 7 
# t        $ rY}j                   j                         j                  t              d |      \  }}|	j	                  dd       |Y d }~ed }~ww xY wwrT   rW   rb   s         r   rl   z$BaseSDK.do_request_async.<locals>.do  s    H,,668GG(2G JJJGGKK$S) "(S!@@ <=oo&<==LLL$$  *0&hmm ''(:H<P<PQ"44>>@LL%h/4 ?LL!4tLDI%%H
 O LL!?@ //*EFFOE A --779EE%h/q1 =LL!4tLDG !	sC   G>BF FF DG>F 	G;"AG60G>6G;;G>r   r   )r   r(   rm   r   retry_asyncro   ra   r_   rX   rp   r   rq   s
   `````   @@r   do_request_asynczBaseSDK.do_request_async
  s      ''44''44/	 /	b #"..EMM,q/<?C H  TzH''(:H<P<PQ--779GG#H-xH  "s%   A-C$6C 7C$C"AC$"C$)NNNNN)FN)__name__
__module____qualname__r   __annotations__r   r#   r   intr   r   strhttpxRequestr6   r8   r)   r   r
   r   Responserr   rv    r   r   r   r      s   '',#3 , ,	;. $( &*%&
 SM&
 &R"7889
&
$ sm%&
& 
'&
h $( &*%&
 SM&
 &R"7889
&
$ sm%&
& 
'&
j $( &*'P
 SMP
  &R"7889
!P
& sm'P
( 
)P
n @DF u[$s)%;<=F 
FZ @DH u[$s)%;<=H 
Hr   r   )__doc__sdkconfigurationr   r}   	mistralair   r   mistralai._hooksr   r   r	   mistralai.utilsr
   r   r   typingr   r   r   r   r   r   r   r   <module>r      s6    G .  # 
 Q P 2 2C Cr   