
    i                      6   d Z ddlZddlZddlmZmZmZ ddlZddl	Zddl
ZddlZddl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 d	d
lmZ d	dlmZmZmZmZ d	dl m!Z! d	dl"m#Z#m$Z$ d	dl%m&Z& ddddZ'de(de)e(e(f   fdZ* G d de      Z+ G d de      Z,y)zACode generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.    N)AnyOptionalcast)models)BeforeRequestHookSDKHooks)Chat)Fim)UNSETOptionalNullable   )BaseSDK)AsyncHttpClientClientOwner
HttpClientclose_clients)SDKConfiguration)Loggerget_default_logger)RetryConfigzcodestral@2405zmistral-large@2407zmistral-nemo@2407)zcodestral-2405zmistral-large-2407zmistral-nemo-2407modelreturnc                 r    | t         v r,dj                  | j                  d      d d       t         |    fS | | fS )N-)LEGACY_MODEL_ID_FORMATjoinsplit)r   s    O/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/mistralai_gcp/sdk.pyget_model_infor        s?    &&xxC("-.0Fu0MMM%<    c                       e Zd ZU dZeed<   	 eed<   	 dddddeddfdede	e   de	e   d	e	e
   d
e	e   dee   de	e   de	e   ddfdZd Zd Zd Zd Zd Zy)MistralGoogleCloudzMistral AI API: Our Chat Completion and Embeddings APIs specification. Create your account on [La Plateforme](https://console.mistral.ai) to get access and read the [docs](https://docs.mistral.ai) to learn how to use it.chatfimzeurope-west4Nregion
project_idaccess_tokenclientasync_clientretry_config
timeout_msdebug_loggerr   c	                    st         j                  j                  dg      \  }	j                  t         j                  j                  j
                  j                                t        t         j                  j                  j                        st        j                  d      |xs |	}|t        j                  d      dt        ffdd}
|t        j                         }d	}
t        t!        |      t"              sJ d
       d}|t        j$                         }d	}|
t'               }t        t!        |      t(              sJ d       d}t+              rfd}nt        j,                        }t/        j0                  | t3        ||
|||d| dd|||
             t5               }t7        ||      }|j9                  |       | j:                  j=                         ^}}|j?                  ||      \  }| j:                  _         ||k7  r|| j:                  _!        || j:                  jD                  d<   tG        jH                  | tJ        tM        tN        | j:                        | j:                  j@                  | j:                  jP                  | j:                  jR                  | j:                  jT                         | jW                          y)a  Instantiates the SDK configuring it with the provided parameters.

        :param api_key: The api_key required for authentication
        :param server: The server by name to use for all methods
        :param server_url: The server URL to use for all methods
        :param url_params: Parameters to optionally template the server URL with
        :param client: The HTTP client to use for all synchronous methods
        :param async_client: The Async HTTP client to use for all asynchronous methods
        :param retry_config: The retry configuration to use for all supported methods
        :param timeout_ms: Optional request timeout applied to each operation in milliseconds
        z.https://www.googleapis.com/auth/cloud-platform)scopeszFcredentials must be an instance of google.auth.credentials.CredentialsNzproject_id must be providedr   c                      rS j                  t        j                  j                  j                  j                                j                  } | st        j                  d      | S )Nz$Failed to get token from credentials)	refreshgoogleauth	transportrequestsRequesttokenr   SDKError)r7   r(   credentialss    r   
auth_tokenz/MistralGoogleCloud.__init__.<locals>.auth_tokenV   sV    ## 5 5 > > F F HI%%Eoo&LMMLr!   TFz;The provided client must implement the HttpClient protocol.zFThe provided async_client must implement the AsyncHttpClient protocol.c                  :    t        j                                 S )Napi_key)r   Security)r:   s   r   <lambda>z-MistralGoogleCloud.__init__.<locals>.<lambda>w   s    v"  r!   r<   zhttps://z-aiplatform.googleapis.com)
r)   client_suppliedr*   async_client_suppliedsecurity
server_urlserverr+   r,   r-   _hooks),r2   r3   defaultr1   r4   r5   r6   
isinstancer9   Credentialsr   r8   strhttpxClient
issubclasstyper   AsyncClientr   r   callabler>   r   __init__r   r   GoogleCloudBeforeRequestHookregister_before_request_hooksdk_configurationget_server_detailssdk_initr)   rC   __dict__weakreffinalizer   r   r   r@   r*   rA   
_init_sdks)selfr&   r'   r(   r)   r*   r+   r,   r-   loaded_project_idr@   rA   rB   hookshookcurrent_server_url_rC   r:   r9   s      `              @@r   rP   zMistralGoogleCloud.__init__/   s   . -3[[-@-@HI .A .*K*  5 5 > > F F HIk6;;+B+B+N+NOoo\  $8'8J//"?@@	C 	 >\\^F#OL*
 	IH	I 
 !% ,,.L$)!-/L
 	TS	T 
 JH z:H /)&;!%fX-GH)%)	
  
+FJ?**40!%!7!7!J!J!LQ49NN5
1
D**1 +0:D""- 5:''1d445""))""22""//""88	
 	r!   c                 l    t        | j                        | _        t        | j                        | _        y N)r	   rS   r$   r
   r%   rZ   s    r   rY   zMistralGoogleCloud._init_sdks   s&    //0	t--.r!   c                     | S ra    rb   s    r   	__enter__zMistralGoogleCloud.__enter__   s    r!   c                    K   | S wra   rd   rb   s    r   
__aenter__zMistralGoogleCloud.__aenter__   s     s   c                     | j                   j                  :| j                   j                  s$| j                   j                  j                          d | j                   _        y ra   )rS   r)   r@   closerZ   exc_typeexc_valexc_tbs       r   __exit__zMistralGoogleCloud.__exit__   sI    ""))5**::""))//1(,%r!   c                    K   | j                   j                  B| j                   j                  s,| j                   j                  j                          d {    d | j                   _        y 7 wra   )rS   r*   rA   acloserj   s       r   	__aexit__zMistralGoogleCloud.__aexit__   sX     ""//;**@@((55<<>>>.2+ ?s   AA/A-A/)__name__
__module____qualname____doc__r	   __annotations__r
   r   rI   r   r   r   r   r   intr   rP   rY   re   rg   rn   rq   rd   r!   r   r#   r#   '   s     h
J	H" %$(&*'+266;$()-uu SMu sm	u
 $u /u '{3u SMu v&u 
un/-3r!   r#   c                   Z    e Zd ZdedefdZdej                  dej                  ez  fdZy)rQ   r&   r'   c                      || _         || _        y ra   )r&   r'   )rZ   r&   r'   s      r   rP   z%GoogleCloudBeforeRequestHook.__init__   s    $r!   requestr   c                    d }d }|j                   rvt        j                  |j                   j                  d            }|j	                  d      }t        |      \  }}||d<   t        j                  |      j                  d      }|dk(  rt        j                  d      d|j                  j                  v }|rdnd}	d| j                   d| j                   d	| d
|	 }
t        |j                        }|j!                  dd        t#        j$                  |j&                  |j                  j)                  |
      ||d       }|S )Nzutf-8r    zmodel must be providedstreamRawPredict
rawPredictz/v1/projects/z/locations/z/publishers/mistralai/models/:zcontent-length)path)methodurlheaderscontentstream)r   jsonloadsdecodegetr    dumpsencoder   r8   r   r   r'   r&   dictr   poprJ   r6   r   	copy_with)rZ   hook_ctxrz   model_idnew_contentparsed	model_raw
model_namer   	specifierr   r   next_requests                r   before_requestz+GoogleCloudBeforeRequestHook.before_request   s+   
 ??ZZ 6 6w ?@F

7+I#1)#< J(F7O**V,33G<Kr>//":;;#w{{'7'77*0&l	doo.k$++Fcdlcmmnoxnyzw'$d+}}>>%%3%/
 r!   N)	rr   rs   rt   rI   rP   rJ   r6   	Exceptionr   rd   r!   r   rQ   rQ      s7    %s % %!!&!		"!r!   rQ   )-ru   r   rW   typingr   r   r   google.authr2   google.auth.credentialsgoogle.auth.transportgoogle.auth.transport.requestsrJ   mistralai_gcpr   mistralai_gcp._hooksr   r   mistralai_gcp.chatr	   mistralai_gcp.fimr
   mistralai_gcp.typesr   r   basesdkr   
httpclientr   r   r   r   sdkconfigurationr   utils.loggerr   r   utils.retriesr   r   rI   tupler    r#   rQ   rd   r!   r   <module>r      s    G   & &    %    < # ! 7  O O . 4 & '., # %S/ W3 W3t&#4 &r!   