# This file was auto-generated by Fern from our API Definition.

import typing

from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .....core.request_options import RequestOptions
from .....types.embedding_model_enum import EmbeddingModelEnum
from .....types.knowledge_base_document_chunks_response_model import KnowledgeBaseDocumentChunksResponseModel
from .raw_client import AsyncRawChunksClient, RawChunksClient


class ChunksClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawChunksClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawChunksClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawChunksClient
        """
        return self._raw_client

    def list(
        self,
        documentation_id: str,
        *,
        embedding_model: EmbeddingModelEnum,
        page_size: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeBaseDocumentChunksResponseModel:
        """
        Get all RAG chunks for a specific knowledge base document.

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

        embedding_model : EmbeddingModelEnum
            The embedding model used to retrieve the chunk.

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

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

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

        Returns
        -------
        KnowledgeBaseDocumentChunksResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.knowledge_base.documents.chunks.list(
            documentation_id="21m00Tcm4TlvDq8ikWAM",
            embedding_model="e5_mistral_7b_instruct",
            page_size=1,
            cursor="cursor",
        )
        """
        _response = self._raw_client.list(
            documentation_id,
            embedding_model=embedding_model,
            page_size=page_size,
            cursor=cursor,
            request_options=request_options,
        )
        return _response.data


class AsyncChunksClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawChunksClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawChunksClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawChunksClient
        """
        return self._raw_client

    async def list(
        self,
        documentation_id: str,
        *,
        embedding_model: EmbeddingModelEnum,
        page_size: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> KnowledgeBaseDocumentChunksResponseModel:
        """
        Get all RAG chunks for a specific knowledge base document.

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

        embedding_model : EmbeddingModelEnum
            The embedding model used to retrieve the chunk.

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

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

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

        Returns
        -------
        KnowledgeBaseDocumentChunksResponseModel
            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.documents.chunks.list(
                documentation_id="21m00Tcm4TlvDq8ikWAM",
                embedding_model="e5_mistral_7b_instruct",
                page_size=1,
                cursor="cursor",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            documentation_id,
            embedding_model=embedding_model,
            page_size=page_size,
            cursor=cursor,
            request_options=request_options,
        )
        return _response.data
