
    7Mg{p                         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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)AnyAsyncGenerator	GeneratorListOptionalUnionc            %          e Zd ZdZeddededddee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j2                     dee
   dee   deej4                     f dZeddededddee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j2                     dee
   dee   deej4                     f dZeddededddee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jB                  ejD                  f      dee   dee   dee   deej2                     dee
   dee   dee#ejH                  ddf      f dZ%eddededddee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jB                  ejD                  f      dee   dee   dee   deej2                     dee
   dee   dee&ejH                  df      f dZ'y)AgentszAgents API.FN)
max_tokensstreamstoprandom_seedresponse_formattoolstool_choicepresence_penaltyfrequency_penaltynretries
server_url
timeout_msmessagesagent_idr   r   r   r   r   r   r   r   r   r   r   r   r    returnc                V   d}d}|| j                   j                  }||}t        j                  ||||t	        j
                  |t        t        j                           t	        j
                  |t        t        j                           t	        j
                  |t        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)        dg t+        | j                   j                  t        j,                              |g d|      }d}t	        j.                  |dd      r5t	        j0                  |j2                  t        t        j4                           S t	        j.                  |dd      rDt	        j0                  |j2                  t        j6                        }t        j8                  |      t	        j.                  |ddgd      r7t	        j:                  |      }t        j<                  d|j>                  ||      |j@                  jC                  d      }t	        j:                  |      }t        j<                  d|j>                   d| d|j>                  ||      )  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 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
        N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   ^E:\wamp.anq\www\apps\calme\nutritwin\resources\nutritwin\Lib\site-packages\mistralai/agents.py<lambda>z!Agents.complete.<locals>.<lambda>m   !    (D(Dvv/M/M)    methodpathbase_urlurl_variablesr2   request_body_requiredrequest_has_path_paramsrequest_has_query_paramsuser_agent_headeraccept_header_valuesecurityget_serialized_bodyr    429500502503504,agents_completion_v1_agents_completions_postoperation_idoauth2_scopessecurity_source4224XX5XXhook_ctxr2   error_status_codesretry_config200rO   datarP   rQ   *API error occurredContent-Type$Unexpected response received (code: , type: ))"sdk_configurationr    r   r0   r   get_pydantic_modelr   AgentsCompletionRequestMessagesr   ResponseFormatr   Tool!AgentsCompletionRequestToolChoicebuild_requestrA   r	   rU   
isinstanceRetryConfig
do_requestr   r   Securitymatch_responseunmarshal_jsontextChatCompletionResponseHTTPValidationErrorDataHTTPValidationErrorstream_to_textSDKErrorstatus_codeheadersgetselfr!   r"   r   r   r   r   r   r   r   r   r   r   r   r   r    r:   r;   reqrU   http_resrX   http_res_textcontent_typer2   s                           @r3   completezAgents.complete   s   l //::J!!H00!#--$vEEF "44&*?*?!@ **52B4CT2UV00Xf&N&NO ./%
*   )'"&$)%)* 2++44! " ! 
$ e%%22%?00==gu001#%HIL?? K  5**33V__! 4% # 
 %1CD''x(E(EF  %1CD''v7U7UVD,,$775%.#>!00:M//$h&:&:M8   ''++N;,,X6oo283G3G2HQ]P^^_`  	
 	
r6   c                  K   d}d}|| j                   j                  }||}t        j                  ||||t	        j
                  |t        t        j                           t	        j
                  |t        t        j                           t	        j
                  |t        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)        dg t+        | j                   j                  t        j,                              |g d|       d{   }d}t	        j.                  |dd      r5t	        j0                  |j2                  t        t        j4                           S t	        j.                  |dd      rDt	        j0                  |j2                  t        j6                        }t        j8                  |      t	        j.                  |ddgd      r?t	        j:                  |       d{   }t        j<                  d|j>                  ||      |j@                  jC                  d      }t	        j:                  |       d{   }t        j<                  d|j>                   d| d|j>                  ||      7 q7 7 <w)r%   Nr&   r'   r(   TFr)   r*   c                  R    t        j                   dddt        j                        S r,   r.   r1   s   r3   r4   z'Agents.complete_async.<locals>.<lambda>   r5   r6   r7   rC   rI   rJ   rN   rR   rV   rO   rW   rP   rQ   rY   rZ   r[   r\   r]   r^   )"r_   r    r   r0   r   r`   r   ra   r   rb   r   rc   rd   build_request_asyncrA   r	   rU   rf   rg   do_request_asyncr   r   ri   rj   rk   rl   rm   rn   ro   stream_to_text_asyncrq   rr   rs   rt   ru   s                           @r3   complete_asynczAgents.complete_async   s    l //::J!!H00!#--$vEEF "44&*?*?!@ **52B4CT2UV00Xf&N&NO ./%
* &&)'"&$)%)* 2++44! " ' 
$ e%%22%?00==gu001#%HIL.. K  5**33V__! 4% / 
 
 %1CD''x(E(EF  %1CD''v7U7UVD,,$775%.#>"'"<"<X"FFM//$h&:&:M8   ''++N;#88BBoo283G3G2HQ]P^^_`  	
 	
;
, G Cs8   GMMCM3M4AMM
8MM
MTc                6   d}d}|| j                   j                  }||}t        j                  ||||t	        j
                  |t        t        j                           t	        j
                  |t        t        j                           t	        j
                  |t        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)        dg t+        | j                   j                  t        j,                              |g dd|      }d}t	        j.                  |dd      rt1        j2                  |d d      S t	        j.                  |dd      rOt	        j4                  |      }t	        j6                  |t        j8                        }t        j:                  |      t	        j.                  |ddgd      r7t	        j4                  |      }t        j<                  d|j>                  ||      |j@                  jC                  d      }t	        j4                  |      }t        j<                  d|j>                   d| d|j>                  ||      )5  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 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
        Nr&   r'   /v1/agents/completions#streamTFr)   text/event-streamc                  R    t        j                   dddt        j                        S r,   r   r/   r   AgentsCompletionStreamRequestr1   s   r3   r4   zAgents.stream.<locals>.<lambda>  !    (D(Dvv/S/S)r6   r7   rC   stream_agentsrJ   rN   rS   r2   rT   r   rU   rV   c                 J    t        j                  | t        j                        S Nr   rk   r   CompletionEventraws    r3   r4   zAgents.stream.<locals>.<lambda>      E00f6L6LMr6   [DONE]sentinelrO   r*   rW   rP   rQ   rY   rZ   r[   r\   r]   r^   )"r_   r    r   r   r   r`   r   %AgentsCompletionStreamRequestMessagesr   rb   r   rc   'AgentsCompletionStreamRequestToolChoicere   rA   r	   rU   rf   rg   rh   r   r   ri   rj   r
   stream_eventsrp   rk   rn   ro   rq   rr   rs   rt   ru   s                           @r3   r   zAgents.stream0  s   p //::J!!H66!#--$vKKL "44&*?*?!@ **52B4CT2UV00Xf&T&TU ./%
*   0'"&$)%)* 3++44! " ! 
$ e%%22%?00==gu001#%HIL?? ,  5**33V__! 4% # 
 %1DE!//M! 
 %1CD!00:M''v7U7UVD,,$775%.#>!00:M//$h&:&:M8   ''++N;,,X6oo283G3G2HQ]P^^_`  	
 	
r6   c                  K   d}d}|| j                   j                  }||}t        j                  ||||t	        j
                  |t        t        j                           t	        j
                  |t        t        j                           t	        j
                  |t        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)        dg t+        | j                   j                  t        j,                              |g dd|       d{   }d}t	        j.                  |dd      rt1        j2                  |d d      S t	        j.                  |dd      rWt	        j4                  |       d{   }t	        j6                  |t        j8                        }t        j:                  |      t	        j.                  |ddgd      r?t	        j4                  |       d{   }t        j<                  d|j>                  ||      |j@                  jC                  d      }t	        j4                  |       d{   }t        j<                  d|j>                   d| d|j>                  ||      7 h7 7 7 ?w)r   Nr&   r'   r   TFr)   r   c                  R    t        j                   dddt        j                        S r,   r   r1   s   r3   r4   z%Agents.stream_async.<locals>.<lambda>(  r   r6   r7   rC   r   rJ   rN   r   rV   c                 J    t        j                  | t        j                        S r   r   r   s    r3   r4   z%Agents.stream_async.<locals>.<lambda>H  r   r6   r   r   rO   r*   rW   rP   rQ   rY   rZ   r[   r\   r]   r^   )"r_   r    r   r   r   r`   r   r   r   rb   r   rc   r   r~   rA   r	   rU   rf   rg   r   r   r   ri   rj   r
   stream_events_asyncr   rk   rn   ro   rq   rr   rs   rt   ru   s                           @r3   stream_asynczAgents.stream_async  s    p //::J!!H66!#--$vKKL "44&*?*?!@ **52B4CT2UV00Xf&T&TU ./%
* &&0'"&$)%)* 3++44! " ' 
$ e%%22%?00==gu001#%HIL.. ,  5**33V__! 4% / 
 
 %1DE!55M! 
 %1CD"'"<"<X"FFM''v7U7UVD,,$775%.#>"'"<"<X"FFM//$h&:&:M8   ''++N;#88BBoo283G3G2HQ]P^^_`  	
 	
C
, G G CsK   GML=A%M;M <A/M+M,AMM8M MMM)(__name__
__module____qualname____doc__r	   r   r   r   ra   (AgentsCompletionRequestMessagesTypedDictstrr   intr   boolAgentsCompletionRequestStop$AgentsCompletionRequestStopTypedDictrb   ResponseFormatTypedDictrc   ToolTypedDictrd   *AgentsCompletionRequestToolChoiceTypedDictfloatr   rg   rm   r{   r   r   .AgentsCompletionStreamRequestMessagesTypedDict!AgentsCompletionStreamRequestStop*AgentsCompletionStreamRequestStopTypedDictr   0AgentsCompletionStreamRequestToolChoiceTypedDictr   r   r   r   r    r6   r3   r   r      s    -2!& -2   ,0-1#(7<$($(EO
 778@@AC
O
 O
 %S)O
 O
 22;;=
O
  &c*!O
" "&'')G)GGH
#O
(  $v{{#T&*>*>%??@
)O
. 88AAC
/O
: #5/;O
< $E?=O
> C ?O
@ "%"3"34AO
B SMCO
D SMEO
F 
&//	0GO
r -2!& -2   ,0-1#(7<$($(EO
 778@@AC
O
 O
 %S)O
 O
 22;;=
O
  &c*!O
" "&'')G)GGH
#O
(  $v{{#T&*>*>%??@
)O
. 88AAC
/O
: #5/;O
< $E?=O
> C ?O
@ "%"3"34AO
B SMCO
D SMEO
F 
&//	0GO
r -2!% -2   ,0-1#(7<$($(EU
 ==>FFGI
U
 U
 %S)U
 U
 88AAC
U
  &c*!U
" "&'')G)GGH
#U
(  $v{{#T&*>*>%??@
)U
. >>GGI
/U
: #5/;U
< $E?=U
> C ?U
@ "%"3"34AU
B SMCU
D SMEU
F 
)F22D$>?	@GU
~ -2!% -2   ,0-1#(7<$($(EU
 ==>FFGI
U
 U
 %S)U
 U
 88AAC
U
  &c*!U
" "&'')G)GGH
#U
(  $v{{#T&*>*>%??@
)U
. >>GGI
/U
: #5/;U
< $E?=U
> C ?U
@ "%"3"34AU
B SMCU
D SMEU
F 
.!7!7!=>	?GU
r6   r   N)r   basesdkr   	mistralair   r   mistralai._hooksr   mistralai.typesr   r	   mistralai.utilsr
   r   typingr   r   r   r   r   r   r   r   r6   r3   <module>r      s+    G  # ( 3 A H HQ	
W Q	
r6   