o
    i                     @   s   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 ddlmZ dd	lmZmZmZmZmZ G d
d deZdS )zACode generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.   )BaseSDK    )modelsutils)HookContext)OptionalNullableUNSET)get_security_from_env)unmarshal_json_response)AnyListMappingOptionalUnionc                   @   s  e Zd ZdZeddeeedddd	dededee deee	e
j e	e
j f  deee
je
jf  d	ee d
ee	e  deej dee dee deeeef  de
jfddZeddeeedddd	dededee deee	e
j e	e
j f  deee
je
jf  d	ee d
ee	e  deej dee dee deeeef  de
jfddZddedddddee dee deej dee dee deeeef  de	e
j fddZddedddddee dee deej dee dee deeeef  de	e
j fddZedddddedeej dee dee deeeef  de
jfdd Zedddddedeej dee dee deeeef  de
jfd!d"Zeddeeeeedddd#dedee 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  deej dee dee deeeef  de
jfd$d%Zeddeeeeedddd#dedee 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  deej dee dee deeeef  de
jfd&d'Zeddddded(edeej dee dee deeeef  de
jfd)d*Zeddddded(edeej dee dee deeeef  de
jfd+d,ZdS )-MistralAgentsz(beta) Agents APIN)	instructionstoolscompletion_argsdescriptionhandoffsretries
server_url
timeout_mshttp_headersmodelnamer   r   r   r   r   r   r   r   r   returnc                   s  d}d}|
du r| j j}
|	dur|	}n| ||}tj|t|tttj	  t|ttj
 ||||d | jdd|| ddddd|| j j fd	d
|
d}|tkr\| j jtur\| j j}d}t|tjrj|g df}| jt| j |prddg t| j jtjd|g d|d}d}t|ddrttj|S t|ddrttj|}t||t|ddrt|}td||t|ddrt|}td||td|)  Create a agent that can be used within a conversation.

        Create a new agent giving it instructions, tools, description. The agent is then available to be used as a regular assistant in a conversation or as part of an agent pool from which it can be used.

        :param model:
        :param name:
        :param instructions: Instruction prompt the model will follow during the conversation.
        :param tools: List of tools which are available to the model during the conversation.
        :param completion_args: White-listed arguments from the completion API
        :param description:
        :param handoffs:
        :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   POST
/v1/agentsTF
user-agentapplication/jsonc                         t  dddtjS NFjsonr   serialize_request_bodyr   AgentCreationRequest requestr)   ^/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/mistralai/mistral_agents.py<lambda>Z       z&MistralAgents.create.<locals>.<lambda>methodpathbase_urlurl_variablesr+   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_api_v1_agents_createconfigr2   operation_idoauth2_scopessecurity_source4224XX5XXhook_ctxr+   error_status_codesretry_config200rI   rJ   *API error occurredrK   Unexpected response received)sdk_configurationr   _get_urlr   r(   r   get_pydantic_modelr   r   AgentCreationRequestToolsCompletionArgs_build_requestr9   r   rO   
isinstanceRetryConfig
do_requestr   r	   Securitymatch_responser
   AgentHTTPValidationErrorDataHTTPValidationErrorstream_to_textSDKErrorselfr   r   r   r   r   r   r   r   r   r   r   r2   r3   reqrO   http_resresponse_datahttp_res_textr)   r*   r,   create   s   &


	

zMistralAgents.createc                   s  d}d}|
du r| j j}
|	dur|	}n| ||}tj|t|tttj	  t|ttj
 ||||d | jdd|| ddddd|| j j fd	d
|
d}|tkr]| j jtur]| j j}d}t|tjrk|g df}| jt| j |psddg t| j jtjd|g d|dI dH }d}t|ddrttj|S t|ddrttj|}t||t|ddrt|I dH }td||t|ddrt|I dH }td||td|)r   Nr   r   r    TFr!   r"   c                      r#   r$   r&   r)   r*   r)   r,   r-      r.   z,MistralAgents.create_async.<locals>.<lambda>r/   r;   rA   rB   rC   rH   rL   rP   rI   rJ   rQ   rR   rK   rS   )rT   r   rU   r   r(   r   rV   r   r   rW   rX   _build_request_asyncr9   r   rO   rZ   r[   do_request_asyncr   r	   r]   r^   r
   r_   r`   ra   stream_to_text_asyncrc   rd   r)   r*   r,   create_async   s   &


	zMistralAgents.create_asyncr      )page	page_sizer   r   r   r   rp   rq   c                C   sv  d}d}|du r| j j}|dur|}n| ||}tj||d}	| jdd|||	ddddd|| j j|d	}
|tkrB| j jturB| j j}d}t	|t
jrP|g d
f}| jt| j |pXddg t| j jtjd|
g d|d}d}t
|ddr|tttj |S t
|ddrttj|}t||t
|ddrt
|}td||t
|ddrt
|}td||td|a  List agent entities.

        Retrieve a list of agent entities sorted by creation time.

        :param page:
        :param page_size:
        :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)rp   rq   GETr    FTr!   r"   r0   r1   r2   r3   r+   r4   r5   r6   r7   r8   r   r9   r   r;   rA   agents_api_v1_agents_listrC   rH   rL   rP   rI   rJ   rQ   rR   rK   rS   )rT   r   rU   r   AgentsAPIV1AgentsListRequestrY   r9   r   rO   rZ   r   r[   r\   r   r	   r]   r^   r
   r   r_   r`   ra   rb   rc   re   rp   rq   r   r   r   r   r2   r3   r+   rf   rO   rg   rh   ri   r)   r)   r,   list  sz   
	

zMistralAgents.listc                   s  d}d}|du r| j j}|dur|}n| ||}tj||d}	| jdd|||	ddddd|| j j|d	}
|tkrC| j jturC| j j}d}t	|t
jrQ|g d
f}| jt| j |pYddg t| j jtjd|
g d|dI dH }d}t
|ddrtttj |S t
|ddrttj|}t||t
|ddrt
|I dH }td||t
|ddrt
|I dH }td||td|rr   )rT   r   rU   r   rv   rk   r9   r   rO   rZ   r   r[   rl   r   r	   r]   r^   r
   r   r_   r`   ra   rm   rc   rw   r)   r)   r,   
list_async]  s|   
	zMistralAgents.list_async)r   r   r   r   agent_idc                C   sp  d}d}|du r| j j}|dur|}n| ||}tj|d}| jdd|||ddddd|| j j|d	}	|tkrA| j jturA| j j}d}
t	|t
jrO|g d
f}
| jt| j |pWddg t| j jtjd|	g d|
d}d}t
|ddryttj|S t
|ddrttj|}t||t
|ddrt
|}td||t
|ddrt
|}td||td|a  Retrieve an agent entity.

        Given an agent retrieve an agent entity with its attributes.

        :param agent_id:
        :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)rz   rs   /v1/agents/{agent_id}FTr!   r"   rt   r;   rA   agents_api_v1_agents_getrC   rH   rL   rP   rI   rJ   rQ   rR   rK   rS   )rT   r   rU   r   AgentsAPIV1AgentsGetRequestrY   r9   r   rO   rZ   r   r[   r\   r   r	   r]   r^   r
   r_   r`   ra   rb   rc   re   rz   r   r   r   r   r2   r3   r+   rf   rO   rg   rh   ri   r)   r)   r,   get  sx   
	

zMistralAgents.getc                   s  d}d}|du r| j j}|dur|}n| ||}tj|d}| jdd|||ddddd|| j j|d	}	|tkrB| j jturB| j j}d}
t	|t
jrP|g d
f}
| jt| j |pXddg t| j jtjd|	g d|
dI dH }d}t
|ddr}ttj|S t
|ddrttj|}t||t
|ddrt
|I dH }td||t
|ddrt
|I dH }td||td|r{   )rT   r   rU   r   r~   rk   r9   r   rO   rZ   r   r[   rl   r   r	   r]   r^   r
   r_   r`   ra   rm   rc   r   r)   r)   r,   	get_async  sz   
	zMistralAgents.get_async)r   r   r   r   r   r   r   r   r   r   r   c                   s  d}d}|du r| j j}|
dur|
}n| ||}tj|tj|t|tt	tj
  t|ttj ||||dd | jdd|| ddddd|| j j fd	d
|d}|	tkra| j jtura| j j}	d}t|	tjro|	g df}| jt| j |pwddg t| j jtjd|g d|d}d}t|ddrttj|S t|ddrttj|}t||t|ddrt|}td||t|ddrt|}td||td|)=  Update an agent entity.

        Update an agent attributes and create a new version.

        :param agent_id:
        :param instructions: Instruction prompt the model will follow during the conversation.
        :param tools: List of tools which are available to the model during the conversation.
        :param completion_args: White-listed arguments from the completion API
        :param model:
        :param name:
        :param description:
        :param handoffs:
        :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   rz   agent_update_requestPATCHr|   Tr!   r"   c                         t  jdddtjS r$   r   r'   r   r   AgentUpdateRequestr)   r*   r)   r,   r-         z&MistralAgents.update.<locals>.<lambda>r/   r;   rA   agents_api_v1_agents_updaterC   rH   rL   rP   rI   rJ   rQ   rR   rK   rS   )rT   r   rU   r   AgentsAPIV1AgentsUpdateRequestr   r   rV   r   r   AgentUpdateRequestToolsrX   rY   r9   r   rO   rZ   r[   r\   r   r	   r]   r^   r
   r_   r`   ra   rb   rc   re   rz   r   r   r   r   r   r   r   r   r   r   r   r2   r3   rf   rO   rg   rh   ri   r)   r*   r,   updatek  s   (


	

zMistralAgents.updatec                   s  d}d}|du r| j j}|
dur|
}n| ||}tj|tj|t|tt	tj
  t|ttj ||||dd | jdd|| ddddd|| j j fd	d
|d}|	tkrb| j jturb| j j}	d}t|	tjrp|	g df}| jt| j |pxddg t| j jtjd|g d|dI dH }d}t|ddrttj|S t|ddrttj|}t||t|ddrt|I dH }td||t|ddrt|I dH }td||td|)r   Nr   r   r   r|   Tr!   r"   c                      r   r$   r   r)   r*   r)   r,   r-   =  r   z,MistralAgents.update_async.<locals>.<lambda>r/   r;   rA   r   rC   rH   rL   rP   rI   rJ   rQ   rR   rK   rS   )rT   r   rU   r   r   r   r   rV   r   r   r   rX   rk   r9   r   rO   rZ   r[   rl   r   r	   r]   r^   r
   r_   r`   ra   rm   rc   r   r)   r*   r,   update_async  s   (


	zMistralAgents.update_asyncversionc                C   sr  d}d}|du r| j j}|dur|}n| ||}tj||d}	| jdd|||	ddddd|| j j|d	}
|tkrB| j jturB| j j}d}t	|t
jrP|g d
f}| jt| j |pXddg t| j jtjd|
g d|d}d}t
|ddrzttj|S t
|ddrttj|}t||t
|ddrt
|}td||t
|ddrt
|}td||td|a  Update an agent version.

        Switch the version of an agent.

        :param agent_id:
        :param version:
        :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)rz   r   r   z/v1/agents/{agent_id}/versionFTr!   r"   rt   r;   rA   #agents_api_v1_agents_update_versionrC   rH   rL   rP   rI   rJ   rQ   rR   rK   rS   )rT   r   rU   r   %AgentsAPIV1AgentsUpdateVersionRequestrY   r9   r   rO   rZ   r   r[   r\   r   r	   r]   r^   r
   r_   r`   ra   rb   rc   re   rz   r   r   r   r   r   r2   r3   r+   rf   rO   rg   rh   ri   r)   r)   r,   update_versiono  sz   
	

zMistralAgents.update_versionc                   s  d}d}|du r| j j}|dur|}n| ||}tj||d}	| jdd|||	ddddd|| j j|d	}
|tkrC| j jturC| j j}d}t	|t
jrQ|g d
f}| jt| j |pYddg t| j jtjd|
g d|dI dH }d}t
|ddr~ttj|S t
|ddrttj|}t||t
|ddrt
|I dH }td||t
|ddrt
|I dH }td||td|r   )rT   r   rU   r   r   rk   r9   r   rO   rZ   r   r[   rl   r   r	   r]   r^   r
   r_   r`   ra   rm   rc   r   r)   r)   r,   update_version_async  s|   
	z"MistralAgents.update_version_async) __name__
__module____qualname____doc__r   strr   r   r   r   r   rW   "AgentCreationRequestToolsTypedDictrX   CompletionArgsTypedDictr   r[   intr   r_   rj   rn   rx   ry   r   r   r    AgentUpdateRequestToolsTypedDictr   r   r   r   r)   r)   r)   r,   r      sL   

~

|	
_	
`
]
]

 

 	
a	r   N)r   basesdkr   	mistralair   r   mistralai._hooksr   mistralai.typesr   r   mistralai.utilsr	   'mistralai.utils.unmarshal_json_responser
   typingr   r   r   r   r   r   r)   r)   r)   r,   <module>   s    