o
    lWi8                     @  s   d dl mZ d dl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mZ ddlmZ ejrWddlmZmZ ddlmZmZ eejdZ G dd dZ!G dd dZ"dS )    )annotationsN   )AsyncClientWrapperSyncClientWrapper)RequestOptions)!GetKnowledgeBaseListResponseModel)GetOrCreateRagIndexRequestModel)KnowledgeBaseDocumentType)KnowledgeBaseSortBy)SortDirection   )AsyncRawKnowledgeBaseClientRawKnowledgeBaseClient)/KnowledgeBaseGetOrCreateRagIndexesResponseValue)AsyncDocumentClientDocumentClient)AsyncDocumentsClientDocumentsClient.c                   @  r   e Zd Zd+ddZed,ddZd	d	d	d	d	d	d	d	d	d	d	d	d
d-dd Zd	d!d.d%d&Zed'd( Zed)d* Z	d	S )/KnowledgeBaseClientclient_wrapperr   c                C  "   t |d| _|| _d | _d | _d S Nr   )r   _raw_client_client_wrapper
_documents	_documentselfr    r    v/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/conversational_ai/knowledge_base/client.py__init__      
zKnowledgeBaseClient.__init__returnr   c                 C     | j S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawKnowledgeBaseClient
        r   r   r    r    r!   with_raw_response!      	z%KnowledgeBaseClient.with_raw_responseN	page_sizesearchshow_only_owned_documentstypesparent_folder_idancestor_folder_idfolders_firstsort_directionsort_byuse_typesensecursorrequest_optionsr+   typing.Optional[int]r,   typing.Optional[str]r-   typing.Optional[bool]r.   dtyping.Optional[typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]]]r/   r0   r1   r2   typing.Optional[SortDirection]r3   $typing.Optional[KnowledgeBaseSortBy]r4   r5   r6   typing.Optional[RequestOptions]r   c                C  s*   | j j|||||||||	|
||d}|jS )a	  
        Get a list of available knowledge base documents

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

        search : typing.Optional[str]
            If specified, the endpoint returns only such knowledge base documents whose names start with this string.

        show_only_owned_documents : typing.Optional[bool]
            If set to true, the endpoint will return only documents owned by you (and not shared from somebody else).

        types : typing.Optional[typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]]]
            If present, the endpoint will return only documents of the given types.

        parent_folder_id : typing.Optional[str]
            If set, the endpoint will return only documents that are direct children of the given folder.

        ancestor_folder_id : typing.Optional[str]
            If set, the endpoint will return only documents that are descendants of the given folder.

        folders_first : typing.Optional[bool]
            Whether folders should be returned first in the list of documents.

        sort_direction : typing.Optional[SortDirection]
            The direction to sort the results

        sort_by : typing.Optional[KnowledgeBaseSortBy]
            The field to sort the results by

        use_typesense : typing.Optional[bool]
            If set to true, the endpoint will use typesense DB to search for the documents).

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

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

        Returns
        -------
        GetKnowledgeBaseListResponseModel
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.knowledge_base.list(
            page_size=1,
            search="search",
            show_only_owned_documents=True,
            parent_folder_id="parent_folder_id",
            ancestor_folder_id="ancestor_folder_id",
            folders_first=True,
            sort_direction="asc",
            sort_by="name",
            use_typesense=True,
            cursor="cursor",
        )
        r*   r   listdatar   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   	_responser    r    r!   r?   ,   s   TzKnowledgeBaseClient.listr6   items0typing.Sequence[GetOrCreateRagIndexRequestModel]Atyping.Dict[str, KnowledgeBaseGetOrCreateRagIndexesResponseValue]c                C  s   | j j||d}|jS )a  
        Retrieves and/or creates RAG indexes for multiple knowledge base documents in a single request.

        Parameters
        ----------
        items : typing.Sequence[GetOrCreateRagIndexRequestModel]
            List of requested RAG indexes.

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

        Returns
        -------
        typing.Dict[str, KnowledgeBaseGetOrCreateRagIndexesResponseValue]
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs, GetOrCreateRagIndexRequestModel

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.knowledge_base.get_or_create_rag_indexes(
            items=[
                GetOrCreateRagIndexRequestModel(
                    document_id="document_id",
                    create_if_missing=True,
                    model="e5_mistral_7b_instruct",
                )
            ],
        )
        rD   r6   r   get_or_create_rag_indexesr@   r   rD   r6   rB   r    r    r!   rI      s   'z-KnowledgeBaseClient.get_or_create_rag_indexesc                 C  *   | j d u rddlm} || jd| _ | j S )Nr   )r   r   )r   documents.clientr   r   )r   r   r    r    r!   	documents      
zKnowledgeBaseClient.documentsc                 C  rK   )Nr   )r   r   )r   document.clientr   r   )r   r   r    r    r!   document   rN   zKnowledgeBaseClient.document)r   r   )r$   r   r+   r7   r,   r8   r-   r9   r.   r:   r/   r8   r0   r8   r1   r9   r2   r;   r3   r<   r4   r9   r5   r8   r6   r=   r$   r   rD   rE   r6   r=   r$   rF   
__name__
__module____qualname__r"   propertyr(   r?   rI   rM   rP   r    r    r    r!   r      s.    
h*
r   c                   @  r   )/AsyncKnowledgeBaseClientr   r   c                C  r   r   )r   r   r   r   r   r   r    r    r!   r"      r#   z!AsyncKnowledgeBaseClient.__init__r$   r   c                 C  r%   )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawKnowledgeBaseClient
        r&   r'   r    r    r!   r(      r)   z*AsyncKnowledgeBaseClient.with_raw_responseNr*   r+   r7   r,   r8   r-   r9   r.   r:   r/   r0   r1   r2   r;   r3   r<   r4   r5   r6   r=   r   c                  s2   | j j|||||||||	|
||dI dH }|jS )a)
  
        Get a list of available knowledge base documents

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

        search : typing.Optional[str]
            If specified, the endpoint returns only such knowledge base documents whose names start with this string.

        show_only_owned_documents : typing.Optional[bool]
            If set to true, the endpoint will return only documents owned by you (and not shared from somebody else).

        types : typing.Optional[typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]]]
            If present, the endpoint will return only documents of the given types.

        parent_folder_id : typing.Optional[str]
            If set, the endpoint will return only documents that are direct children of the given folder.

        ancestor_folder_id : typing.Optional[str]
            If set, the endpoint will return only documents that are descendants of the given folder.

        folders_first : typing.Optional[bool]
            Whether folders should be returned first in the list of documents.

        sort_direction : typing.Optional[SortDirection]
            The direction to sort the results

        sort_by : typing.Optional[KnowledgeBaseSortBy]
            The field to sort the results by

        use_typesense : typing.Optional[bool]
            If set to true, the endpoint will use typesense DB to search for the documents).

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

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

        Returns
        -------
        GetKnowledgeBaseListResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.knowledge_base.list(
                page_size=1,
                search="search",
                show_only_owned_documents=True,
                parent_folder_id="parent_folder_id",
                ancestor_folder_id="ancestor_folder_id",
                folders_first=True,
                sort_direction="asc",
                sort_by="name",
                use_typesense=True,
                cursor="cursor",
            )


        asyncio.run(main())
        r*   Nr>   rA   r    r    r!   r?      s    \zAsyncKnowledgeBaseClient.listrC   rD   rE   rF   c                  s   | j j||dI dH }|jS )a  
        Retrieves and/or creates RAG indexes for multiple knowledge base documents in a single request.

        Parameters
        ----------
        items : typing.Sequence[GetOrCreateRagIndexRequestModel]
            List of requested RAG indexes.

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

        Returns
        -------
        typing.Dict[str, KnowledgeBaseGetOrCreateRagIndexesResponseValue]
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs, GetOrCreateRagIndexRequestModel

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.knowledge_base.get_or_create_rag_indexes(
                items=[
                    GetOrCreateRagIndexRequestModel(
                        document_id="document_id",
                        create_if_missing=True,
                        model="e5_mistral_7b_instruct",
                    )
                ],
            )


        asyncio.run(main())
        rG   NrH   rJ   r    r    r!   rI   I  s   /z2AsyncKnowledgeBaseClient.get_or_create_rag_indexesc                 C  rK   )Nr   )r   r   )r   rL   r   r   )r   r   r    r    r!   rM   {  rN   z"AsyncKnowledgeBaseClient.documentsc                 C  rK   )Nr   )r   r   )r   rO   r   r   )r   r   r    r    r!   rP     rN   z!AsyncKnowledgeBaseClient.document)r   r   )r$   r   rQ   rR   rS   r    r    r    r!   rX      s.    
p2
rX   )#
__future__r   typingcore.client_wrapperr   r   core.request_optionsr   ,types.get_knowledge_base_list_response_modelr   +types.get_or_create_rag_index_request_modelr   "types.knowledge_base_document_typer	   types.knowledge_base_sort_byr
   types.sort_directionr   
raw_clientr   r   =types.knowledge_base_get_or_create_rag_indexes_response_valuer   TYPE_CHECKINGrO   r   r   rL   r   r   castAnyOMITr   rX   r    r    r    r!   <module>   s$    2