
    b6i5                    &   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.                  rddlmZmZ ddlmZmZ  ej<                  ej>                  d      Z  G d d      Z! G d d      Z"y)    )annotationsN   )AsyncClientWrapperSyncClientWrapper)RequestOptions)!GetKnowledgeBaseListResponseModel)GetOrCreateRagIndexRequestModel)KnowledgeBaseDocumentType)KnowledgeBaseSortBy)SortDirection   )AsyncRawKnowledgeBaseClientRawKnowledgeBaseClient)/KnowledgeBaseGetOrCreateRagIndexesResponseValue)AsyncDocumentClientDocumentClient)AsyncDocumentsClientDocumentsClient.c                      e Zd Zd
dZedd       Zdddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdd	 	 	 	 	 ddZed        Zed	        Z	y)KnowledgeBaseClientc               P    t        |      | _        || _        d | _        d | _        y Nclient_wrapper)r   _raw_client_client_wrapper
_documents	_documentselfr   s     }/root/.openclaw/workspace/visionaryfx/venv/lib/python3.12/site-packages/elevenlabs/conversational_ai/knowledge_base/client.py__init__zKnowledgeBaseClient.__init__   s%    1P-<@:>    c                    | j                   S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawKnowledgeBaseClient
        r   r    s    r!   with_raw_responsez%KnowledgeBaseClient.with_raw_response!        r#   N	page_sizesearchshow_only_owned_documentstypesparent_folder_idancestor_folder_idfolders_firstsort_directionsort_bycursorrequest_optionsc               f    | j                   j                  |||||||||	|
|      }|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

        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",
            cursor="cursor",
        )
        r)   r   listdatar    r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   	_responses                r!   r7   zKnowledgeBaseClient.list,   sM    ^ $$))&?-1')+ * 
	 ~~r#   r4   c               T    | j                   j                  ||      }|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",
                )
            ],
        )
        itemsr4   r   get_or_create_rag_indexesr8   r    r>   r4   r:   s       r!   r@   z-KnowledgeBaseClient.get_or_create_rag_indexes   s+    N $$>>U\k>l	~~r#   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   r   )r   documents.clientr   r   )r    r   s     r!   	documentszKnowledgeBaseClient.documents   s+    ??"9-T=Q=QRDOr#   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   r   )r   document.clientr   r   )r    r   s     r!   documentzKnowledgeBaseClient.document   s+    >>!7+4;O;OPDN~~r#   )r   r   )returnr   r*   ztyping.Optional[int]r+   typing.Optional[str]r,   typing.Optional[bool]r-   zdtyping.Optional[typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]]]r.   rJ   r/   rJ   r0   rK   r1   ztyping.Optional[SortDirection]r2   z$typing.Optional[KnowledgeBaseSortBy]r3   rJ   r4   typing.Optional[RequestOptions]rH   r   r>   z0typing.Sequence[GetOrCreateRagIndexRequestModel]r4   rL   rH   zAtyping.Dict[str, KnowledgeBaseGetOrCreateRagIndexesResponseValue]
__name__
__module____qualname__r"   propertyr'   r7   r@   rD   rG    r#   r!   r   r      s   ?     +/'+;? 1537/39=8<'+;?\ (\ %	\
 $9\
\ /\ 1\ -\ 7\ 6\ %\ 9\  
+!\D <@	( @( 9	(
 
K(T    r#   r   c                      e Zd Zd
dZedd       Zdddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdd	 	 	 	 	 ddZed        Zed	        Z	y)AsyncKnowledgeBaseClientc               P    t        |      | _        || _        d | _        d | _        y r   )r   r   r   r   r   r   s     r!   r"   z!AsyncKnowledgeBaseClient.__init__   s%    6nU-AE?Cr#   c                    | j                   S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawKnowledgeBaseClient
        r%   r&   s    r!   r'   z*AsyncKnowledgeBaseClient.with_raw_response   r(   r#   Nr)   c                  K   | j                   j                  |||||||||	|
|       d{   }|j                  S 7 w)ay	  
        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

        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",
                cursor="cursor",
            )


        asyncio.run(main())
        r)   Nr6   r9   s                r!   r7   zAsyncKnowledgeBaseClient.list   s[     n **//&?-1')+ 0 
 
	 ~~
s   *?=?r;   c               p   K   | j                   j                  ||       d{   }|j                  S 7 w)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())
        r=   Nr?   rA   s       r!   r@   z2AsyncKnowledgeBaseClient.get_or_create_rag_indexes=  s8     ^ **DD5bqDrr	~~ ss   !646c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   r   )r   rC   r   r   )r    r   s     r!   rD   z"AsyncKnowledgeBaseClient.documentso  s+    ??">2$BVBVWDOr#   c                n    | j                   ddlm}  || j                        | _         | j                   S )Nr   )r   r   )r   rF   r   r   )r    r   s     r!   rG   z!AsyncKnowledgeBaseClient.documentw  s+    >>!<0@T@TUDN~~r#   )r   r   )rH   r   rI   rM   rN   rS   r#   r!   rU   rU      s    D     +/'+;? 1537/39=8<'+;?d (d %	d
 $9d
d /d 1d -d 7d 6d %d 9d  
+!dT <@	0 @0 9	0
 
K0d    r#   rU   )#
__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_CHECKINGrF   r   r   rC   r   r   castAnyOMITr   rU   rS   r#   r!   <module>rk      sj    #  H 2 ] Z K ? 1 K 
DGv{{6::s#h hVx xr#   