
    i                         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mZ ddlmZ dd	lmZmZmZmZmZ dd
lmZ ddlmZmZmZmZ  G d de      Zy)zACode generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.   )BaseSDK    )modelsutils)HookContext)OptionalNullableUNSET)eventstreamingget_security_from_env)unmarshal_json_response)AnyListMappingOptionalUnion)Type)*convert_to_parsed_chat_completion_response#response_format_from_pydantic_modelCustomPydanticModelParsedChatCompletionResponsec            0       P   e Zd ZdZdee   dedee   fdZdee   dee   fdZ	dee   de
j                  ej                     fdZdee   de
j                  ej                     fdZed	ed
d	ed	ed	d	d	ed	d	ed	ed	d	d	ddedeeej*                     eej,                     f   dee   dee   dee   dee   deeej8                  ej:                  f      dee   deeej<                  ej>                  f      deeeej@                     eejB                     f      deeejD                  ejF                  f      dee   dee   dee   deeejH                  ejJ                  f      dee   deejL                     dee   dee'jP                     dee   dee   d ee)eef      dejT                  f.d!Z+ed	ed
d	ed	ed	d	d	ed	d	ed	ed	d	d	ddedeeej*                     eej,                     f   dee   dee   dee   dee   deeej8                  ej:                  f      dee   deeej<                  ej>                  f      deeeej@                     eejB                     f      deeejD                  ejF                  f      dee   dee   dee   deeejH                  ejJ                  f      dee   deejL                     dee   dee'jP                     dee   dee   d ee)eef      dejT                  f.d"Z,ed	ed#d	ed	ed	d	d	ed	d	ed	ed	d	d	ddedeeejZ                     eej\                     f   dee   dee   dee   dee   deeej^                  ej`                  f      dee   deeej<                  ej>                  f      deeeej@                     eejB                     f      deeejb                  ejd                  f      dee   dee   dee   deeejH                  ejJ                  f      dee   deejL                     dee   dee'jP                     dee   dee   d ee)eef      de
j                  ej                     f.d$Z3ed	ed#d	ed	ed	d	d	ed	d	ed	ed	d	d	ddedeeejZ                     eej\                     f   dee   dee   dee   dee   deeej^                  ej`                  f      dee   deeej<                  ej>                  f      deeeej@                     eejB                     f      deeejb                  ejd                  f      dee   dee   dee   deeejH                  ejJ                  f      dee   deejL                     dee   dee'jP                     dee   dee   d ee)eef      de
j                  ej                     f.d%Z4y	)&ChatzChat Completion API.response_formatkwargsreturnc                 `    t        |      } | j                  di |d|i}t        ||      }|S )a.  
        Parse the response using the provided response format.
        :param Type[CustomPydanticModel] response_format: The Pydantic model to parse the response into
        :param Any **kwargs Additional keyword arguments to pass to the .complete method
        :return: The parsed response
        r    )r   completer   selfr   r   json_response_formatresponseparsed_responses         L/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/mistralai/chat.pyparsez
Chat.parse   s@      C?S 4==P6P;OPDo
     c                 |   K   t        |      } | j                  di |d|i d{   }t        ||      }|S 7 w)a=  
        Asynchronously parse the response using the provided response format.
        :param Type[CustomPydanticModel] response_format: The Pydantic model to parse the response into
        :param Any **kwargs Additional keyword arguments to pass to the .complete method
        :return: The parsed response
        r   Nr   )r   complete_asyncr   r   s         r$   parse_asynczChat.parse_async/   sZ       C?S,,, 

&:
 
 Eo
 
s   %<:<c                 H    t        |      } | j                  di |d|i}|S )a  
        Parse the response using the provided response format.
        For now the response will be in JSON format not in the input Pydantic model.
        :param Type[CustomPydanticModel] response_format: The Pydantic model to parse the response into
        :param Any **kwargs Additional keyword arguments to pass to the .stream method
        :return: The JSON parsed response
        r   r   )r   streamr    r   r   r!   r"   s        r$   parse_streamzChat.parse_streamA   s.      C?S4;;NN9MNr&   c                 d   K   t        |      } | j                  di |d|i d{   }|S 7 w)a  
        Asynchronously parse the response using the provided response format.
        For now the response will be in JSON format not in the input Pydantic model.
        :param Type[CustomPydanticModel] response_format: The Pydantic model to parse the response into
        :param Any **kwargs Additional keyword arguments to pass to the .stream method
        :return: The JSON parsed response
        r   Nr   )r   stream_asyncr,   s        r$   parse_stream_asynczChat.parse_stream_asyncO   sG       C?S*** 

&:
 
 
s   %0.0NF)temperaturetop_p
max_tokensr+   stoprandom_seedr   toolstool_choicepresence_penaltyfrequency_penaltyn
predictionparallel_tool_callsprompt_modesafe_promptretries
server_url
timeout_mshttp_headersmodelmessagesr1   r2   r3   r+   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   c                   d}d}|| j                   j                  }||}n| j                  ||      }t        j                  d)i d|d|d|d|d|d|d|d	t        j                  |t        t        j                           d
t        j                  |	t        t        j                           dt        j                  |
t        t        t        j                              dt        j                  |t        t        j                           d|d|d|dt        j                  |t        t        j                           d|d|d|| j                  dd||ddddd|| j                   j                   fd|      }|t"        k(  r2| j                   j$                  t"        ur| j                   j$                  }d}t'        |t
        j(                        r|g df}| j+                  t-        | j                   |xs ddg t/        | j                   j                   t        j0                              |g d |!      }d}t        j2                  |d"d      rt5        t        j6                  |      S t        j2                  |d#d      r0t5        t        j8                  |      }t        j:                  ||      t        j2                  |d$d%      r,t        j<                  |      }t        j>                  d&||      t        j2                  |d'd%      r,t        j<                  |      }t        j>                  d&||      t        j>                  d(|      )*  Chat Completion

        :param model: ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions.
        :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
        :param temperature: What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. The default value varies depending on the model you are targeting. Call the `/models` endpoint to retrieve the appropriate value.
        :param top_p: Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both.
        :param max_tokens: The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length.
        :param stream: Whether to stream back partial progress. If set, tokens will be sent as data-only server-side events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
        :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
        :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
        :param response_format:
        :param tools:
        :param tool_choice:
        :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
        :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
        :param n: Number of completions to return for each request, input tokens are only billed once.
        :param prediction:
        :param parallel_tool_calls:
        :param prompt_mode: Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used.
        :param safe_prompt: Whether to inject a safety prompt before all conversations.
        :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.
        NrC   r1   r2   r3   r+   r4   r5   rD   r   r6   r7   r8   r9   r:   r;   r<   r=   r>   POST/v1/chat/completionsTF
user-agentapplication/jsonc                  R    t        j                   dddt        j                        S NFjsonr   serialize_request_bodyr   ChatCompletionRequestrequests   r$   <lambda>zChat.complete.<locals>.<lambda>   #    (D(Dvv/K/K) r&   methodpathbase_urlurl_variablesrR   request_body_requiredrequest_has_path_paramsrequest_has_query_paramsuser_agent_headeraccept_header_valuerB   securityget_serialized_bodyrA   429500502503504 (chat_completion_v1_chat_completions_postconfigrX   operation_idoauth2_scopessecurity_source4224XX5XXhook_ctxrR   error_status_codesretry_config200ro   rp   *API error occurredrq   Unexpected response receivedr   ) sdk_configurationrA   _get_urlr   rP   r   get_pydantic_modelr   Messagesr   ResponseFormatr   ToolChatCompletionRequestToolChoice
Prediction_build_requestr_   r	   ru   
isinstanceRetryConfig
do_requestr   r   Securitymatch_responser   ChatCompletionResponseHTTPValidationErrorDataHTTPValidationErrorstream_to_textSDKErrorr    rC   rD   r1   r2   r3   r+   r4   r5   r   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rX   rY   reqru   http_resresponse_datahttp_res_textrR   s                                 @r$   r   zChat.completea   sf   | //::J!!H}}X}=H.. 

#
 
 "	

 
 
 $
 --hV__8MN
 "44&*?*?!@
 **52B4CT2UV
 00Xf&L&LM
  .!
" 0#
$ %
& //HV%6%67'
, !4-
. $/
0 $1
6 !!''"&$)%)* 2%++44! "! " 
& e%%22%?00==gu001#%HIL?? --!RG  5**33V__! 4% # 
 "%1CD*6+H+H(SS%1CD3..M ,,]HEE%5!00:M//"6-PP%5!00:M//"6-PPoo<hGGr&   c                  K   d}d}|| j                   j                  }||}n| j                  ||      }t        j                  d)i d|d|d|d|d|d|d|d	t        j                  |t        t        j                           d
t        j                  |	t        t        j                           dt        j                  |
t        t        t        j                              dt        j                  |t        t        j                           d|d|d|dt        j                  |t        t        j                           d|d|d|| j                  dd||ddddd|| j                   j                   fd|      }|t"        k(  r2| j                   j$                  t"        ur| j                   j$                  }d}t'        |t
        j(                        r|g df}| j+                  t-        | j                   |xs ddg t/        | j                   j                   t        j0                              |g d |!       d{   }d}t        j2                  |d"d      rt5        t        j6                  |      S t        j2                  |d#d      r0t5        t        j8                  |      }t        j:                  ||      t        j2                  |d$d%      r4t        j<                  |       d{   }t        j>                  d&||      t        j2                  |d'd%      r4t        j<                  |       d{   }t        j>                  d&||      t        j>                  d(|      7 +7 7 6w)*rF   NrC   r1   r2   r3   r+   r4   r5   rD   r   r6   r7   r8   r9   r:   r;   r<   r=   r>   rG   rH   TFrI   rJ   c                  R    t        j                   dddt        j                        S rL   rN   rQ   s   r$   rS   z%Chat.complete_async.<locals>.<lambda>o  rT   r&   rU   ra   rg   rh   ri   rn   rr   rv   ro   rp   rw   rx   rq   ry   r   ) rz   rA   r{   r   rP   r   r|   r   r}   r   r~   r   r   r   r   _build_request_asyncr_   r	   ru   r   r   do_request_asyncr   r   r   r   r   r   r   r   stream_to_text_asyncr   r   s                                 @r$   r(   zChat.complete_async   s    | //::J!!H}}X}=H.. 

#
 
 "	

 
 
 $
 --hV__8MN
 "44&*?*?!@
 **52B4CT2UV
 00Xf&L&LM
  .!
" 0#
$ %
& //HV%6%67'
, !4-
. $/
0 $1
6 ''''"&$)%)* 2%++44! "! ( 
& e%%22%?00==gu001#%HIL.. --!RG  5**33V__! 4% / 
 
 "%1CD*6+H+H(SS%1CD3..M ,,]HEE%5"'"<"<X"FFM//"6-PP%5"'"<"<X"FFM//"6-PPoo<hGG=
0 G Gs8   IM;	M4
B-M;7M78A
M;M92M;7M;9M;Tc                   d}d}|| j                   j                  }||}n| j                  ||      }t        j                  d-i d|d|d|d|d|d|d|d	t        j                  |t        t        j                           d
t        j                  |	t        t        j                           dt        j                  |
t        t        t        j                              dt        j                  |t        t        j                           d|d|d|dt        j                  |t        t        j                           d|d|d|| j                  dd||ddddd|| j                   j                   fd|      }|t"        k(  r2| j                   j$                  t"        ur| j                   j$                  }d}t'        |t
        j(                        r|g df}| j+                  t-        | j                   |xs ddg t/        | j                   j                   t        j0                              |g d d|!      }d}t        j2                  |d"d      rt5        j6                  |d# d$| %      S t        j2                  |d&d'      rGt        j8                  |      }t;        t        j<                  ||      }t        j>                  |||      t        j2                  |d(d)      r,t        j8                  |      }t        j@                  d*||      t        j2                  |d+d)      r,t        j8                  |      }t        j@                  d*||      t        j8                  |      }t        j@                  d,||      )."  Stream chat completion

        Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.

        :param model: ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions.
        :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
        :param temperature: What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. The default value varies depending on the model you are targeting. Call the `/models` endpoint to retrieve the appropriate value.
        :param top_p: Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both.
        :param max_tokens: The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length.
        :param stream:
        :param stop: Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
        :param random_seed: The seed to use for random sampling. If set, different calls will generate deterministic results.
        :param response_format:
        :param tools:
        :param tool_choice:
        :param presence_penalty: presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
        :param frequency_penalty: frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
        :param n: Number of completions to return for each request, input tokens are only billed once.
        :param prediction:
        :param parallel_tool_calls:
        :param prompt_mode: Allows toggling between the reasoning mode and no system prompt. When set to `reasoning` the system prompt for reasoning models will be used.
        :param safe_prompt: Whether to inject a safety prompt before all conversations.
        :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.
        NrC   r1   r2   r3   r+   r4   r5   rD   r   r6   r7   r8   r9   r:   r;   r<   r=   r>   rG   /v1/chat/completions#streamTFrI   text/event-streamc                  R    t        j                   dddt        j                        S rL   r   rO   r   ChatCompletionStreamRequestrQ   s   r$   rS   zChat.stream.<locals>.<lambda>  #    (D(Dvv/Q/Q) r&   rU   ra   rg   stream_chatri   rn   rs   rR   rt   r+   ru   rv   c                 J    t        j                  | t        j                        S Nr   unmarshal_jsonr   CompletionEventraws    r$   rS   zChat.stream.<locals>.<lambda>;      E00f6L6LM r&   [DONE]sentinel
client_refro   rJ   rp   rw   rx   rq   ry   r   )!rz   rA   r{   r   r   r   r|   r   #ChatCompletionStreamRequestMessagesr   r~   r   r   %ChatCompletionStreamRequestToolChoicer   r   r_   r	   ru   r   r   r   r   r   r   r   r
   EventStreamr   r   r   r   r   r   s                                 @r$   r+   zChat.stream  s   P //::J!!H}}X}=H44 

#
 
 "	

 
 
 $
 --$vIIJ
 "44&*?*?!@
 **52B4CT2UV
 00Xf&R&RS
$ .%
& 0'
( )
* //HV%6%67+
0 !41
2 $3
4 $5
: !!.'"&$)%)* 3%++44! "! " 
& e%%22%?00==gu001#%HIL?? --!R*  5**33V__! 4% # 
  "%1DE!--M!	  %1CD!00:M3..-M ,,]HmTT%5!00:M//"6-PP%5!00:M//"6-PP,,X6oo<hVVr&   c                  K   d}d}|| j                   j                  }||}n| j                  ||      }t        j                  d-i d|d|d|d|d|d|d|d	t        j                  |t        t        j                           d
t        j                  |	t        t        j                           dt        j                  |
t        t        t        j                              dt        j                  |t        t        j                           d|d|d|dt        j                  |t        t        j                           d|d|d|| j                  dd||ddddd|| j                   j                   fd|      }|t"        k(  r2| j                   j$                  t"        ur| j                   j$                  }d}t'        |t
        j(                        r|g df}| j+                  t-        | j                   |xs ddg t/        | j                   j                   t        j0                              |g d d|!       d{   }d}t        j2                  |d"d      rt5        j6                  |d# d$| %      S t        j2                  |d&d'      rOt        j8                  |       d{   }t;        t        j<                  ||      }t        j>                  |||      t        j2                  |d(d)      r4t        j8                  |       d{   }t        j@                  d*||      t        j2                  |d+d)      r4t        j8                  |       d{   }t        j@                  d*||      t        j8                  |       d{   }t        j@                  d,||      7 h7 7 7 W7 %w).r   NrC   r1   r2   r3   r+   r4   r5   rD   r   r6   r7   r8   r9   r:   r;   r<   r=   r>   rG   r   TFrI   r   c                  R    t        j                   dddt        j                        S rL   r   rQ   s   r$   rS   z#Chat.stream_async.<locals>.<lambda>  r   r&   rU   ra   rg   r   ri   rn   r   rv   c                 J    t        j                  | t        j                        S r   r   r   s    r$   rS   z#Chat.stream_async.<locals>.<lambda>  r   r&   r   r   ro   rJ   rp   rw   rx   rq   ry   r   )!rz   rA   r{   r   r   r   r|   r   r   r   r~   r   r   r   r   r   r_   r	   ru   r   r   r   r   r   r   r   r
   EventStreamAsyncr   r   r   r   r   r   s                                 @r$   r/   zChat.stream_asyncO  s    P //::J!!H}}X}=H44 

#
 
 "	

 
 
 $
 --$vIIJ
 "44&*?*?!@
 **52B4CT2UV
 00Xf&R&RS
$ .%
& 0'
( )
* //HV%6%67+
0 !41
2 $3
4 $5
: ''.'"&$)%)* 3%++44! "! ( 
& e%%22%?00==gu001#%HIL.. --!R*  5**33V__! 4% / 
 
  "%1DE!22M!	  %1CD"'"<"<X"FFM3..-M ,,]HmTT%5"'"<"<X"FFM//"6-PP%5"'"<"<X"FFM//"6-PP#88BBoo<hVVM
2 G G G Cs]   IN>
N2A&N>1N52A%N>N8A
N>"N:#3N>N<N>5N>8N>:N><N>)5__name__
__module____qualname____doc__r   r   r   r   r%   r)   r
   r   r   r   r-   r   r0   r	   strr   r   r}   MessagesTypedDictr   floatr   intboolStopStopTypedDictr~   ResponseFormatTypedDictr   ToolTypedDictr   (ChatCompletionRequestToolChoiceTypedDictr   PredictionTypedDictMistralPromptModer   r   r   r   r   r(   r   ,ChatCompletionStreamRequestMessagesTypedDictChatCompletionStreamRequestStop(ChatCompletionStreamRequestStopTypedDictr   .ChatCompletionStreamRequestToolChoiceTypedDictr+   r/   r   r&   r$   r   r      s&   
#$78DG	%&9	:&#$78	%&9	:$#$78		#	#F$:$:	;#$78		(	()?)?	@. 05!%,1!&CG-2   ,0-1#( .2BG&*7<$($(48G\H \H V__-tF4L4L/MMN	\H
 &e,\H \H %S)\H \H uV[[&*>*>>?@\H &c*\H "&'')G)GGH
\H  $v{{#T&*>*>%??@
\H" 66??A
#\H. #5//\H0 $E?1\H2 C 3\H4 &##V%?%??@
5\H: &d^;\H< &f&>&>?=\H> d^?\H@ "%"3"34A\HB SMC\HD SME\HF wsCx01G\HH 
	&	&I\HF 05!%,1!&CG-2   ,0-1#( .2BG&*7<$($(48G\H \H V__-tF4L4L/MMN	\H
 &e,\H \H %S)\H \H uV[[&*>*>>?@\H &c*\H "&'')G)GGH
\H  $v{{#T&*>*>%??@
\H" 66??A
#\H. #5//\H0 $E?1\H2 C 3\H4 &##V%?%??@
5\H: &d^;\H< &f&>&>?=\H> d^?\H@ "%"3"34A\HB SMC\HD SME\HF wsCx01G\HH 
	&	&I\HL 05!%,1!% -2   ,0-1#( .2BG&*7<$($(48WpW pW ;;<DDEG
	pW &e,pW pW %S)pW pW 66??A
pW$ &c*%pW& "&'')G)GGH
'pW,  $v{{#T&*>*>%??@
-pW2 <<EEG
3pW> #5/?pW@ $E?ApWB C CpWD &##V%?%??@
EpWJ &d^KpWL &f&>&>?MpWN d^OpWP "%"3"34QpWR SMSpWT SMUpWV wsCx01WpWX 
	#	#F$:$:	;YpWt 05!%,1!% -2   ,0-1#( .2BG&*7<$($(48WpW pW ;;<DDEG
	pW &e,pW pW %S)pW pW 66??A
pW$ &c*%pW& "&'')G)GGH
'pW,  $v{{#T&*>*>%??@
-pW2 <<EEG
3pW> #5/?pW@ $E?ApWB C CpWD &##V%?%??@
EpWJ &d^KpWL &f&>&>?MpWN d^OpWP "%"3"34QpWR SMSpWT SMUpWV wsCx01WpWX 
	(	()?)?	@YpWr&   r   N)r   basesdkr   	mistralair   r   mistralai._hooksr   mistralai.typesr   r	   mistralai.utilsr
   r   'mistralai.utils.unmarshal_json_responser   typingr   r   r   r   r   r   mistralai.extrar   r   r   r   r   r   r&   r$   <module>r      s?    G  # ( 3 A K 6 6  iW7 iWr&   