o
    lWig                     @   s   d dl Z d dl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 dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ e e j dZ!G dd dZ"G dd dZ#dS )    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)'convert_and_respect_annotation_metadata)construct_type)UnprocessableEntityError)#GetToolDependentAgentsResponseModel)HttpValidationError)ToolRequestModel)ToolResponseModel)ToolsResponseModel.c                   @     e Zd ZdefddZdddeje dee	 fdd	Z
ddd
edeje dee fddZdddedeje dee fddZdddedeje deej fddZddded
edeje dee fddZdddddedeje deje deje dee f
ddZdS )RawToolsClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   q/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/conversational_ai/tools/raw_client.py__init__      
zRawToolsClient.__init__Nrequest_optionsr!   returnc             	   C   s   | j jjdd|d}z>d|j  krdk r+n ntttt| d}t	||dW S |jdkrCt
t|jtttt| dd	| }W n ty[   t|jt|j|jd
w t|jt|j|d
)a2  
        Get all available tools in the workspace.

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[ToolsResponseModel]
            Successful Response
        v1/convai/toolsGETmethodr!      ,  type_object_responsedata  headersbodystatus_coder1   r2   )r   httpx_clientrequestr4   typingcastr   r   jsonr   r   dictr1   r   r   r   textr   r!   	_response_data_response_jsonr   r   r   list   s>   

zRawToolsClient.listr6   c             	   C   s   | j jjddt|tddddi|td}z>d|j  kr d	k r5n ntt	t
t	| d
}t||dW S |jdkrMtt|jttt
t| d
d| }W n tye   t|jt|j|jdw t|jt|j|d)ac  
        Add a new tool to the available tools in the workspace.

        Parameters
        ----------
        request : ToolRequestModel

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[ToolResponseModel]
            Successful Response
        r#   POSTwriter+   
annotation	directioncontent-typeapplication/jsonr&   r9   r1   r!   omitr'   r(   r)   r,   r/   r0   r3   )r   r5   r6   r   r   OMITr4   r7   r8   r   r   r9   r   r   r:   r1   r   r   r   r;   r   r6   r!   r=   r>   r?   r   r   r   createI   sJ   

zRawToolsClient.createtool_idc             	   C   s   | j jjdt| d|d}z>d|j  krdk r0n ntttt|	 d}t
||dW S |jdkrHtt|jtttt|	 dd	|	 }W n ty`   t|jt|j|jd
w t|jt|j|d
)aq  
        Get tool that is available in the workspace.

        Parameters
        ----------
        tool_id : str
            ID of the requested tool.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[ToolResponseModel]
            Successful Response
        v1/convai/tools/r$   r%   r'   r(   r)   r,   r/   r0   r3   )r   r5   r6   r	   r4   r7   r8   r   r   r9   r   r   r:   r1   r   r   r   r;   r   rM   r!   r=   r>   r?   r   r   r   get   s>   

zRawToolsClient.getc             	   C   s   | j jjdt| d|d}zP|du s|j s t|ddW S d|j  kr+dk rBn nt	tj
ttj
| d}t||dW S |jd	krZtt|jt	ttt| dd
| }W n tyr   t|jt|j|jdw t|jt|j|d)a]  
        Delete tool from the workspace.

        Parameters
        ----------
        tool_id : str
            ID of the requested tool.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[typing.Any]
            Successful Response
        rN   DELETEr%   Nr,   r'   r(   r)   r/   r0   r3   )r   r5   r6   r	   r;   stripr   r4   r7   r8   Anyr   r9   r   r:   r1   r   r   r   rO   r   r   r   delete   sB   

zRawToolsClient.deletec             	   C   s   | j jjdt| dt|tddddi|td}z>d|j  kr%d	k r:n nt	t
tt
| d
}t||dW S |jdkrRtt|jt	ttt| d
d| }W n tyj   t|jt|j|jdw t|jt|j|d)a  
        Update tool that is available in the workspace.

        Parameters
        ----------
        tool_id : str
            ID of the requested tool.

        request : ToolRequestModel

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[ToolResponseModel]
            Successful Response
        rN   PATCHrB   rC   rF   rG   rH   r'   r(   r)   r,   r/   r0   r3   )r   r5   r6   r	   r   r   rJ   r4   r7   r8   r   r   r9   r   r   r:   r1   r   r   r   r;   r   rM   r6   r!   r=   r>   r?   r   r   r   update   sJ   

zRawToolsClient.updatecursor	page_sizer!   rY   rZ   c             	   C   s   | j jjdt| dd||d|d}z>d|j  kr dk r5n ntttt|	 d}t
||d	W S |jd
krMtt|jtttt|	 dd|	 }W n tye   t|jt|j|jdw t|jt|j|d)ay  
        Get a list of agents depending on this tool

        Parameters
        ----------
        tool_id : str
            ID of the requested tool.

        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

        page_size : typing.Optional[int]
            How many documents to return at maximum. Can not exceed 100, defaults to 30.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[GetToolDependentAgentsResponseModel]
            Successful Response
        rN   /dependent-agentsr$   rY   rZ   r&   paramsr!   r'   r(   r)   r,   r/   r0   r3   )r   r5   r6   r	   r4   r7   r8   r   r   r9   r   r   r:   r1   r   r   r   r;   r   rM   rY   rZ   r!   r=   r>   r?   r   r   r   get_dependent_agents"  sD   	

z#RawToolsClient.get_dependent_agents)__name__
__module____qualname__r   r   r7   Optionalr
   r   r   r@   r   r   rL   strrP   rS   rT   rW   intr   r`   r   r   r   r   r      sf    ".
9
3
5
?r   c                   @   r   )AsyncRawToolsClientr   c                C   r   r   r   r   r   r   r   r   e  r   zAsyncRawToolsClient.__init__Nr    r!   r"   c             	      s   | j jjdd|dI dH }z>d|j  krdk r/n ntttt| d}t	||dW S |jd	krGt
t|jtttt| dd
| }W n ty_   t|jt|j|jdw t|jt|j|d)a7  
        Get all available tools in the workspace.

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[ToolsResponseModel]
            Successful Response
        r#   r$   r%   Nr'   r(   r)   r,   r/   r0   r3   )r   r5   r6   r4   r7   r8   r   r   r9   r   r   r:   r1   r   r   r   r;   r<   r   r   r   r@   h  s@   

zAsyncRawToolsClient.listr6   c             	      s   | j jjddt|tddddi|tdI dH }z>d	|j  kr$d
k r9n ntt	t
t	| d}t||dW S |jdkrQtt|jttt
t| dd| }W n tyi   t|jt|j|jdw t|jt|j|d)ah  
        Add a new tool to the available tools in the workspace.

        Parameters
        ----------
        request : ToolRequestModel

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[ToolResponseModel]
            Successful Response
        r#   rA   rB   rC   rF   rG   rH   Nr'   r(   r)   r,   r/   r0   r3   )r   r5   r6   r   r   rJ   r4   r7   r8   r   r   r9   r   r   r:   r1   r   r   r   r;   rK   r   r   r   rL     sL   

zAsyncRawToolsClient.createrM   c             	      s   | j jjdt| d|dI dH }z>d|j  krdk r4n ntttt|	 d}t
||dW S |jd	krLtt|jtttt|	 dd
|	 }W n tyd   t|jt|j|jdw t|jt|j|d)av  
        Get tool that is available in the workspace.

        Parameters
        ----------
        tool_id : str
            ID of the requested tool.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[ToolResponseModel]
            Successful Response
        rN   r$   r%   Nr'   r(   r)   r,   r/   r0   r3   )r   r5   r6   r	   r4   r7   r8   r   r   r9   r   r   r:   r1   r   r   r   r;   rO   r   r   r   rP     s@   

zAsyncRawToolsClient.getc             	      s  | j jjdt| d|dI dH }zP|du s|j s$t|ddW S d|j  kr/dk rFn nt	tj
ttj
| d}t||dW S |jd	kr^tt|jt	ttt| dd
| }W n tyv   t|jt|j|jdw t|jt|j|d)ab  
        Delete tool from the workspace.

        Parameters
        ----------
        tool_id : str
            ID of the requested tool.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[typing.Any]
            Successful Response
        rN   rQ   r%   Nr,   r'   r(   r)   r/   r0   r3   )r   r5   r6   r	   r;   rR   r   r4   r7   r8   rS   r   r9   r   r:   r1   r   r   r   rO   r   r   r   rT     sD   

zAsyncRawToolsClient.deletec             	      s   | j jjdt| dt|tddddi|tdI dH }z>d	|j  kr)d
k r>n nt	t
tt
| d}t||dW S |jdkrVtt|jt	ttt| dd| }W n tyn   t|jt|j|jdw t|jt|j|d)a  
        Update tool that is available in the workspace.

        Parameters
        ----------
        tool_id : str
            ID of the requested tool.

        request : ToolRequestModel

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[ToolResponseModel]
            Successful Response
        rN   rU   rB   rC   rF   rG   rH   Nr'   r(   r)   r,   r/   r0   r3   )r   r5   r6   r	   r   r   rJ   r4   r7   r8   r   r   r9   r   r   r:   r1   r   r   r   r;   rV   r   r   r   rW   5  sL   

zAsyncRawToolsClient.updaterX   rY   rZ   c             	      s   | j jjdt| dd||d|dI dH }z>d|j  kr$dk r9n ntttt|	 d	}t
||d
W S |jdkrQtt|jtttt|	 d	d|	 }W n tyi   t|jt|j|jdw t|jt|j|d)a~  
        Get a list of agents depending on this tool

        Parameters
        ----------
        tool_id : str
            ID of the requested tool.

        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

        page_size : typing.Optional[int]
            How many documents to return at maximum. Can not exceed 100, defaults to 30.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[GetToolDependentAgentsResponseModel]
            Successful Response
        rN   r[   r$   r\   r]   Nr'   r(   r)   r,   r/   r0   r3   )r   r5   r6   r	   r4   r7   r8   r   r   r9   r   r   r:   r1   r   r   r   r;   r_   r   r   r   r`   p  sF   	

z(AsyncRawToolsClient.get_dependent_agents)ra   rb   rc   r   r   r7   rd   r
   r   r   r@   r   r   rL   re   rP   rS   rT   rW   rf   r   r`   r   r   r   r   rg   d  sp    
0
9
3
5
?rg   )$r7   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r   core.jsonable_encoderr	   core.request_optionsr
   core.serializationr   core.unchecked_base_modelr   !errors.unprocessable_entity_errorr   .types.get_tool_dependent_agents_response_modelr   types.http_validation_errorr   types.tool_request_modelr   types.tool_response_modelr   types.tools_response_modelr   r8   rS   rJ   r   rg   r   r   r   r   <module>   s(     N