
    b6iM                        d dl Z d dlm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  e j>                  e j@                  d      Z! G d d      Z" G d d      Z#y)    N)JSONDecodeError   )core)ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)UnprocessableEntityError)AddKnowledgeBaseResponseModel)HttpValidationError)RagDocumentIndexResponseModel)RagDocumentIndexesResponseModel)RagIndexOverviewResponseModel.c                      e Zd ZdefdZdeeedddej                  e   dej                  e   dej                  e   dej                  e	j                     d	ej                  e   d
ee   fdZddd	ej                  e   d
ee   fdZddded	ej                  e   d
ee   fdZdddeded	ej                  e   d
ee   fdZy)RawConversationalAiClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     r/root/.openclaw/workspace/visionaryfx/venv/lib/python3.12/site-packages/elevenlabs/conversational_ai/raw_client.py__init__z"RawConversationalAiClient.__init__   
    -    Nagent_idnameurlfilerequest_optionsr"   r#   r$   r%   r&   returnc                   | j                   j                  j                  ddd|i||di |d|ini |t        d      }	 d|j                  cxk  rd	k  rGn nDt        j                  t        t        t        |j                         
            }t        ||      S |j                  dk(  rUt        t        |j                        t        j                  t        t        t        |j                         
                  |j                         }t!        |j                  t        |j                        |      # t        $ r6 t!        |j                  t        |j                        |j"                        w xY w)a_  
        Upload a file or webpage URL to create a knowledge base document. <br> <Note> After creating the document, update the agent's knowledge base by calling [Update agent](/docs/api-reference/agents/update). </Note>

        Parameters
        ----------
        agent_id : typing.Optional[str]

        name : typing.Optional[str]
            A custom, human-readable name for the document.

        url : typing.Optional[str]
            URL to a page of documentation that the agent will have access to in order to interact with users.

        file : typing.Optional[core.File]
            See core.File for more documentation

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

        Returns
        -------
        HttpResponse[AddKnowledgeBaseResponseModel]
            Successful Response
        v1/convai/knowledge-basePOSTr"   r#   r$   r%   Tmethodparamsdatafilesr&   omitforce_multipart   ,  type_object_responser/     headersbodystatus_coder<   r=   )r   httpx_clientrequestOMITr?   typingcastr   r   jsonr
   r   dictr<   r   r   r   text	r   r"   r#   r$   r%   r&   	_response_data_response_jsons	            r   add_to_knowledge_basez/RawConversationalAiClient.add_to_knowledge_base   sl   B ((55==&H %)%5FD>2 ,  > 
	"	ti++1c11"; ) 0 $YUCC$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts    AD; A4D; ;?E:r&   c                   | j                   j                  j                  dd|      }	 d|j                  cxk  rdk  rGn nDt	        j
                  t        t        t        |j                                     }t        ||      S |j                  dk(  rUt        t        |j                        t	        j
                  t        t        t        |j                                     	      |j                         }t        |j                  t        |j                        |
      # t        $ r6 t        |j                  t        |j                        |j                   
      w xY w)al  
        Provides total size and other information of RAG indexes used by knowledgebase documents

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

        Returns
        -------
        HttpResponse[RagIndexOverviewResponseModel]
            Successful Response
        "v1/convai/knowledge-base/rag-indexGETr-   r&   r3   r4   r5   r8   r:   r;   r>   )r   r@   rA   r?   rC   rD   r   r   rE   r
   r   rF   r<   r   r   r   rG   r   r&   rI   rJ   rK   s        r   rag_index_overviewz,RawConversationalAiClient.rag_index_overviewh   s4     ((55==0+ > 
	
	ti++1c11"; ) 0 $YUCC$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AD% A4D% %?E$documentation_idc                   | j                   j                  j                  dt        |       dd|      }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  d	k(  rUt        t        |j                        t        j                  t        t        t        |j                                     
      |j                         }t!        |j                  t        |j                        |      # t        $ r6 t!        |j                  t        |j                        |j"                        w xY w)a  
        Provides information about all RAG indexes of the specified knowledgebase document.

        Parameters
        ----------
        documentation_id : str
            The id of a document from the knowledge base. This is returned on document addition.

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

        Returns
        -------
        HttpResponse[RagDocumentIndexesResponseModel]
            Successful Response
        v1/convai/knowledge-base/
/rag-indexrP   rQ   r3   r4   r5   r8   r:   r;   r>   )r   r@   rA   r   r?   rC   rD   r   r   rE   r
   r   rF   r<   r   r   r   rG   r   rT   r&   rI   rJ   rK   s         r   get_document_rag_indexesz2RawConversationalAiClient.get_document_rag_indexes   sE   & ((55=='(89I(J'K:V+ > 
	
	ti++1c13"= ) 0 $YUCC$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AD2 A4D2 2?E1rag_index_idc                   | j                   j                  j                  dt        |       dt        |       d|      }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  d	k(  rUt        t        |j                        t        j                  t        t        t        |j                                     
      |j                         }t!        |j                  t        |j                        |      # t        $ r6 t!        |j                  t        |j                        |j"                        w xY w)a&  
        Delete RAG index for the knowledgebase document.

        Parameters
        ----------
        documentation_id : str
            The id of a document from the knowledge base. This is returned on document addition.

        rag_index_id : str
            The id of RAG index of document from the knowledge base.

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

        Returns
        -------
        HttpResponse[RagDocumentIndexResponseModel]
            Successful Response
        rV   /rag-index/DELETErQ   r3   r4   r5   r8   r:   r;   r>   )r   r@   rA   r   r?   rC   rD   r   r   rE   r
   r   rF   r<   r   r   r   rG   r   rT   rZ   r&   rI   rJ   rK   s          r   delete_document_rag_indexz3RawConversationalAiClient.delete_document_rag_index   sQ   , ((55=='(89I(J'K;WghtWuVvw+ > 
	
	ti++1c11"; ) 0 $YUCC$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AD= A4D= =?E<)__name__
__module____qualname__r   r   rB   rC   Optionalstrr   Filer   r
   r   rL   r   rS   r   rY   r   r_    r    r   r   r      sO   .*; . *.%)$(+/;?Jp //#&Jp ooc"	Jp
 __S!Jp oodii(Jp  8Jp 
3	4JpZ EI-p"(//."A-p	3	4-p` \`0p #0p9?9X0p	5	60pf os3p #3p363pLROO\jLk3p	3	43pr    r   c                      e Zd ZdefdZdeeedddej                  e   dej                  e   dej                  e   dej                  e	j                     d	ej                  e   d
ee   fdZddd	ej                  e   d
ee   fdZddded	ej                  e   d
ee   fdZdddeded	ej                  e   d
ee   fdZy)AsyncRawConversationalAiClientr   c                    || _         y r   r   r   s     r   r   z'AsyncRawConversationalAiClient.__init__   r   r    Nr!   r"   r#   r$   r%   r&   r'   c                  K   | j                   j                  j                  ddd|i||di |d|ini |t        d       d{   }	 d	|j                  cxk  rd
k  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  dk(  rUt        t        |j                        t        j                  t        t        t        |j                                           |j                         }t!        |j                  t        |j                        |      7 # t        $ r6 t!        |j                  t        |j                        |j"                        w xY ww)ad  
        Upload a file or webpage URL to create a knowledge base document. <br> <Note> After creating the document, update the agent's knowledge base by calling [Update agent](/docs/api-reference/agents/update). </Note>

        Parameters
        ----------
        agent_id : typing.Optional[str]

        name : typing.Optional[str]
            A custom, human-readable name for the document.

        url : typing.Optional[str]
            URL to a page of documentation that the agent will have access to in order to interact with users.

        file : typing.Optional[core.File]
            See core.File for more documentation

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

        Returns
        -------
        AsyncHttpResponse[AddKnowledgeBaseResponseModel]
            Successful Response
        r)   r*   r"   r+   Nr%   Tr,   r3   r4   r5   r8   r:   r;   r>   )r   r@   rA   rB   r?   rC   rD   r   r   rE   r	   r   rF   r<   r   r   r   rG   rH   s	            r   rL   z4AsyncRawConversationalAiClient.add_to_knowledge_base  s|    B ..;;CC&H %)%5FD>2 ,  D 
 
	"	ti++1c11"; ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooS
N  	ty'<'<d9K\K\F]dmdrdrss	ts8   AF
EF

AE %F
&A4E ,F
?FF
rM   c                  K   | j                   j                  j                  dd|       d{   }	 d|j                  cxk  rdk  rGn nDt	        j
                  t        t        t        |j                                     }t        ||      S |j                  d	k(  rUt        t        |j                        t	        j
                  t        t        t        |j                                     
      |j                         }t        |j                  t        |j                        |      7 # t        $ r6 t        |j                  t        |j                        |j                         w xY ww)aq  
        Provides total size and other information of RAG indexes used by knowledgebase documents

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

        Returns
        -------
        AsyncHttpResponse[RagIndexOverviewResponseModel]
            Successful Response
        rO   rP   rQ   Nr3   r4   r5   r8   r:   r;   r>   )r   r@   rA   r?   rC   rD   r   r   rE   r	   r   rF   r<   r   r   r   rG   rR   s        r   rS   z1AsyncRawConversationalAiClient.rag_index_overviewO  sB      ..;;CC0+ D 
 
	
	ti++1c11"; ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo;
6  	ty'<'<d9K\K\F]dmdrdrss	ts4   ,E4D/E4AD2 E4A4D2 ,E42?E11E4rT   c                  K   | j                   j                  j                  dt        |       dd|       d{   }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||	      S |j                  d
k(  rUt        t        |j                        t        j                  t        t        t        |j                                           |j                         }t!        |j                  t        |j                        |      7 # t        $ r6 t!        |j                  t        |j                        |j"                        w xY ww)a  
        Provides information about all RAG indexes of the specified knowledgebase document.

        Parameters
        ----------
        documentation_id : str
            The id of a document from the knowledge base. This is returned on document addition.

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

        Returns
        -------
        AsyncHttpResponse[RagDocumentIndexesResponseModel]
            Successful Response
        rV   rW   rP   rQ   Nr3   r4   r5   r8   r:   r;   r>   )r   r@   rA   r   r?   rC   rD   r   r   rE   r	   r   rF   r<   r   r   r   rG   rX   s         r   rY   z7AsyncRawConversationalAiClient.get_document_rag_indexes~  sS    & ..;;CC'(89I(J'K:V+ D 
 
	
	ti++1c13"= ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo;
6  	ty'<'<d9K\K\F]dmdrdrss	ts5   9FD<FAD? FA4D? ,F??E>>FrZ   c                  K   | j                   j                  j                  dt        |       dt        |       d|       d{   }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||	      S |j                  d
k(  rUt        t        |j                        t        j                  t        t        t        |j                                           |j                         }t!        |j                  t        |j                        |      7 # t        $ r6 t!        |j                  t        |j                        |j"                        w xY ww)a+  
        Delete RAG index for the knowledgebase document.

        Parameters
        ----------
        documentation_id : str
            The id of a document from the knowledge base. This is returned on document addition.

        rag_index_id : str
            The id of RAG index of document from the knowledge base.

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

        Returns
        -------
        AsyncHttpResponse[RagDocumentIndexResponseModel]
            Successful Response
        rV   r\   r]   rQ   Nr3   r4   r5   r8   r:   r;   r>   )r   r@   rA   r   r?   rC   rD   r   r   rE   r	   r   rF   r<   r   r   r   rG   r^   s          r   r_   z8AsyncRawConversationalAiClient.delete_document_rag_index  s_    , ..;;CC'(89I(J'K;WghtWuVvw+ D 
 
	
	ti++1c11"; ) 0 ))%HH$$+. !2!23+&"5$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo;
6  	ty'<'<d9K\K\F]dmdrdrss	ts8   AFEFAE
 'F(A4E
 ,F
?F		F)r`   ra   rb   r   r   rB   rC   rc   rd   r   re   r   r	   r   rL   r   rS   r   rY   r   r_   rf   r    r   rh   rh      sO   .*< . *.%)$(+/;?Jp //#&Jp ooc"	Jp
 __S!Jp oodii(Jp  8Jp 
8	9JpZ EI-p"(//."A-p	8	9-p` \`0p #0p9?9X0p	:	;0pf os3p #3p363pLROO\jLk3p	8	93pr    rh   )$rC   json.decoderr    r   core.api_errorr   core.client_wrapperr   r   core.http_responser	   r
   core.jsonable_encoderr   core.request_optionsr   core.unchecked_base_modelr   !errors.unprocessable_entity_errorr   'types.add_knowledge_base_response_modelr   types.http_validation_errorr   'types.rag_document_index_response_modelr   )types.rag_document_indexes_response_modelr   'types.rag_index_overview_response_modelr   rD   AnyrB   r   rh   rf   r    r   <module>r}      si     (  % G @ 4 1 6 H S = S W S v{{6::s#dp dpNdp dpr    