
    i6                         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  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Unionc            *       	   e Zd ZdZeddededddeddeedddddeeej                     eej                     f   d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j(                     f      deeej*                  ej,                  f      dee   dee   dee   deeej0                  ej2                  f      dee   deej4                     deej8                     dee
   dee   deee
e
f      dej<                  f(dZeddededddeddeedddddeeej                     eej                     f   d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j(                     f      deeej*                  ej,                  f      dee   dee   dee   deeej0                  ej2                  f      dee   deej4                     deej8                     dee
   dee   deee
e
f      dej<                  f(dZ eddededddeddeedddddeeejB                     eejD                     f   de
dee   dee   d	eeejF                  ejH                  f      d
ee   deeej"                  ej$                  f      deeeej&                     eej(                     f      deeejJ                  ejL                  f      dee   dee   dee   deeej0                  ej2                  f      dee   deej4                     deej8                     dee
   dee   deee
e
f      de'jP                  ejR                     f(dZ*eddededddeddeedddddeeejB                     eejD                     f   de
dee   dee   d	eeejF                  ejH                  f      d
ee   deeej"                  ej$                  f      deeeej&                     eej(                     f      deeejJ                  ejL                  f      dee   dee   dee   deeej0                  ej2                  f      dee   deej4                     deej8                     dee
   dee   deee
e
f      de'jV                  ejR                     f(dZ,y)AgentszAgents API.FN)
max_tokensstreamstoprandom_seedresponse_formattoolstool_choicepresence_penaltyfrequency_penaltyn
predictionparallel_tool_callsprompt_moderetries
server_url
timeout_mshttp_headersmessagesagent_idr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   returnc                j   d}d}|| j                   j                  }||}n| j                  ||      }t        j                  ||||t        j                  |t        t        j                           t        j                  |t        t        j                           t        j                  |t        t        t        j                              t        j                  |	t        t        j                           |
||t        j                  |t        t        j                           |||      | 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|      )	  Agents Completion

        :param messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
        :param agent_id: The ID of the agent to use for this completion.
        :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 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   r   r   r   r   r    r&   POST/v1/agents/completionsTF
user-agentapplication/jsonc                  R    t        j                   dddt        j                        S NFjsonr   serialize_request_bodyr   AgentsCompletionRequestrequests   N/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/mistralai/agents.py<lambda>z!Agents.complete.<locals>.<lambda>   #    (D(Dvv/M/M)     methodpathbase_urlurl_variablesr6   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 ,agents_completion_v1_agents_completions_postconfigr>   operation_idoauth2_scopessecurity_source4224XX5XXhook_ctxr6   error_status_codesretry_config200rU   rV   *API error occurredrW   Unexpected response received) sdk_configurationr#   _get_urlr   r4   r   get_pydantic_modelr   AgentsCompletionRequestMessagesr   ResponseFormatr   Tool!AgentsCompletionRequestToolChoice
Prediction_build_requestrE   r	   r[   
isinstanceRetryConfig
do_requestr   r   Securitymatch_responser   ChatCompletionResponseHTTPValidationErrorDataHTTPValidationErrorstream_to_textSDKErrorselfr%   r&   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r>   r?   reqr[   http_resresponse_datahttp_res_textr6   s                              @r7   completezAgents.complete   s   @ //::J!!H}}X}=H00!#--$vEEF "44&*?*?!@ **52B4CT2UV00Xf&N&NO .///HV%6%67 !4#/
4 !!)'"&$)%)* 2%++44! "! " 
& e%%22%?00==gu001#%HIL?? --!RK  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                  ||||t        j                  |t        t        j                           t        j                  |t        t        j                           t        j                  |t        t        t        j                              t        j                  |	t        t        j                           |
||t        j                  |t        t        j                           |||      | 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)r)   Nr*   r+   r,   TFr-   r.   c                  R    t        j                   dddt        j                        S r0   r2   r5   s   r7   r8   z'Agents.complete_async.<locals>.<lambda>  r9   r:   r;   rG   rM   rN   rO   rT   rX   r\   rU   rV   r]   r^   rW   r_   ) r`   r#   ra   r   r4   r   rb   r   rc   r   rd   r   re   rf   rg   _build_request_asyncrE   r	   r[   ri   rj   do_request_asyncr   r   rl   rm   r   rn   ro   rp   stream_to_text_asyncrr   rs   s                              @r7   complete_asynczAgents.complete_async   s    @ //::J!!H}}X}=H00!#--$vEEF "44&*?*?!@ **52B4CT2UV00Xf&N&NO .///HV%6%67 !4#/
4 '')'"&$)%)* 2%++44! "! ( 
& e%%22%?00==gu001#%HIL.. --!RK  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   H!M$M%B-MMA
MM2MMMTc                   d}d}|| j                   j                  }||}n| j                  ||      }t        j                  ||||t        j                  |t        t        j                           t        j                  |t        t        j                           t        j                  |t        t        t        j                              t        j                  |	t        t        j                           |
||t        j                  |t        t        j                           |||      | 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||      )m	  Stream Agents 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 messages: The prompt(s) to generate completions for, encoded as a list of dict with role and content.
        :param agent_id: The ID of the agent to use for this completion.
        :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 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/agents/completions#streamTFr-   text/event-streamc                  R    t        j                   dddt        j                        S r0   r   r3   r   AgentsCompletionStreamRequestr5   s   r7   r8   zAgents.stream.<locals>.<lambda>  #    (D(Dvv/S/S) r:   r;   rG   rM   stream_agentsrO   rT   rY   r6   rZ   r   r[   r\   c                 J    t        j                  | t        j                        S Nr   unmarshal_jsonr   CompletionEventraws    r7   r8   zAgents.stream.<locals>.<lambda>      E00f6L6LM r:   [DONE]sentinel
client_refrU   r.   rV   r]   r^   rW   r_   )!r`   r#   ra   r   r   r   rb   r   %AgentsCompletionStreamRequestMessagesr   rd   r   re   'AgentsCompletionStreamRequestToolChoicerg   rh   rE   r	   r[   ri   rj   rk   r   r   rl   rm   r
   EventStreamrq   r   ro   rp   rr   rs   s                              @r7   r   zAgents.streamM  s'   D //::J!!H}}X}=H66!#--$vKKL "44&*?*?!@ **52B4CT2UV00Xf&T&TU .///HV%6%67 !4#/
4 !!0'"&$)%)* 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                6  K   d}d}|| j                   j                  }||}n| j                  ||      }t        j                  ||||t        j                  |t        t        j                           t        j                  |t        t        j                           t        j                  |t        t        t        j                              t        j                  |	t        t        j                           |
||t        j                  |t        t        j                           |||      | 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   Nr*   r+   r   TFr-   r   c                  R    t        j                   dddt        j                        S r0   r   r5   s   r7   r8   z%Agents.stream_async.<locals>.<lambda>i  r   r:   r;   rG   rM   r   rO   rT   r   r\   c                 J    t        j                  | t        j                        S r   r   r   s    r7   r8   z%Agents.stream_async.<locals>.<lambda>  r   r:   r   r   rU   r.   rV   r]   r^   rW   r_   )!r`   r#   ra   r   r   r   rb   r   r   r   rd   r   re   r   rg   r|   rE   r	   r[   ri   rj   r}   r   r   rl   rm   r
   EventStreamAsyncr~   r   ro   rp   rr   rs   s                              @r7   stream_asynczAgents.stream_async  s`    D //::J!!H}}X}=H66!#--$vKKL "44&*?*?!@ **52B4CT2UV00Xf&T&TU .///HV%6%67 !4#/
4 ''0'"&$)%)* 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]   H"N%N&A&NNA%N2N3A
N=N>3N1N2NNNNN)-__name__
__module____qualname____doc__r	   r   r   r   rc   (AgentsCompletionRequestMessagesTypedDictstrr   intr   boolAgentsCompletionRequestStop$AgentsCompletionRequestStopTypedDictrd   ResponseFormatTypedDictre   ToolTypedDictrf   *AgentsCompletionRequestToolChoiceTypedDictfloatrg   PredictionTypedDictMistralPromptModer   rj   r   rn   ry   r   r   .AgentsCompletionStreamRequestMessagesTypedDict!AgentsCompletionStreamRequestStop*AgentsCompletionStreamRequestStopTypedDictr   0AgentsCompletionStreamRequestToolChoiceTypedDictr
   r   r   r   r   r    r:   r7   r   r      s	    -2!& -2   ,0-1#( .2BG7<$($(48Q]H 778@@AC
]H ]H %S)]H ]H 22;;=
]H  &c*!]H" "&'')G)GGH
#]H(  $v{{#T&*>*>%??@
)]H. 88AAC
/]H: #5/;]H< $E?=]H> C ?]H@ &##V%?%??@
A]HF &d^G]HH &f&>&>?I]HJ "%"3"34K]HL SMM]HN SMO]HP wsCx01Q]HR 
	&	&S]HN -2!& -2   ,0-1#( .2BG7<$($(48Q]H 778@@AC
]H ]H %S)]H ]H 22;;=
]H  &c*!]H" "&'')G)GGH
#]H(  $v{{#T&*>*>%??@
)]H. 88AAC
/]H: #5/;]H< $E?=]H> C ?]H@ &##V%?%??@
A]HF &d^G]HH &f&>&>?I]HJ "%"3"34K]HL SMM]HN SMO]HP wsCx01Q]HR 
	&	&S]HN -2!% -2   ,0-1#( .2BG7<$($(48QgW ==>FFGI
gW gW %S)gW gW 88AAC
gW  &c*!gW" "&'')G)GGH
#gW(  $v{{#T&*>*>%??@
)gW. >>GGI
/gW: #5/;gW< $E?=gW> C ?gW@ &##V%?%??@
AgWF &d^GgWH &f&>&>?IgWJ "%"3"34KgWL SMMgWN SMOgWP wsCx01QgWR 
	#	#F$:$:	;SgWb -2!% -2   ,0-1#( .2BG7<$($(48QgW ==>FFGI
gW gW %S)gW gW 88AAC
gW  &c*!gW" "&'')G)GGH
#gW(  $v{{#T&*>*>%??@
)gW. >>GGI
/gW: #5/;gW< $E?=gW> C ?gW@ &##V%?%??@
AgWF &d^GgWH &f&>&>?IgWJ "%"3"34KgWL SMMgWN SMOgWP wsCx01QgWR 
	(	()?)?	@Sg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   r   r:   r7   <module>r      s0    G  # ( 3 A K 6 6Q
WW Q
Wr:   