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

import typing

from ... import core
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...core.request_options import RequestOptions
from .raw_client import AsyncRawKnowledgeBaseClient, RawKnowledgeBaseClient
from .types.delete_knowledgebase_id_response import DeleteKnowledgebaseIdResponse
from .types.delete_knowledgebase_knowledge_base_id_items_knowledge_base_item_id_response import (
    DeleteKnowledgebaseKnowledgeBaseIdItemsKnowledgeBaseItemIdResponse,
)
from .types.get_knowledgebase_id_items_response import GetKnowledgebaseIdItemsResponse
from .types.get_knowledgebase_id_response import GetKnowledgebaseIdResponse
from .types.get_knowledgebase_response import GetKnowledgebaseResponse
from .types.post_knowledgebase_id_items_upload_media_response import PostKnowledgebaseIdItemsUploadMediaResponse
from .types.post_knowledgebase_response import PostKnowledgebaseResponse

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class KnowledgeBaseClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawKnowledgeBaseClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawKnowledgeBaseClient
        """
        return self._raw_client

    def get_all_knowledge_bases(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetKnowledgebaseResponse:
        """
        Get all knowledge bases

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

        Returns
        -------
        GetKnowledgebaseResponse
            A list of knowledge bases

        Examples
        --------
        from smallestai import SmallestAI

        client = SmallestAI(
            token="YOUR_TOKEN",
        )
        client.atoms.knowledge_base.get_all_knowledge_bases()
        """
        _response = self._raw_client.get_all_knowledge_bases(request_options=request_options)
        return _response.data

    def create_a_knowledge_base(
        self,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostKnowledgebaseResponse:
        """
        Create a knowledge base

        Parameters
        ----------
        name : str

        description : typing.Optional[str]

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

        Returns
        -------
        PostKnowledgebaseResponse
            Knowledge base created successfully

        Examples
        --------
        from smallestai import SmallestAI

        client = SmallestAI(
            token="YOUR_TOKEN",
        )
        client.atoms.knowledge_base.create_a_knowledge_base(
            name="name",
        )
        """
        _response = self._raw_client.create_a_knowledge_base(
            name=name, description=description, request_options=request_options
        )
        return _response.data

    def get_a_knowledge_base(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetKnowledgebaseIdResponse:
        """
        Get a knowledge base

        Parameters
        ----------
        id : str
            The ID of the knowledge base

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

        Returns
        -------
        GetKnowledgebaseIdResponse
            A knowledge base

        Examples
        --------
        from smallestai import SmallestAI

        client = SmallestAI(
            token="YOUR_TOKEN",
        )
        client.atoms.knowledge_base.get_a_knowledge_base(
            id="id",
        )
        """
        _response = self._raw_client.get_a_knowledge_base(id, request_options=request_options)
        return _response.data

    def delete_a_knowledge_base(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteKnowledgebaseIdResponse:
        """
        Delete a knowledge base

        Parameters
        ----------
        id : str
            The ID of the knowledge base

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

        Returns
        -------
        DeleteKnowledgebaseIdResponse
            Knowledge base deleted successfully

        Examples
        --------
        from smallestai import SmallestAI

        client = SmallestAI(
            token="YOUR_TOKEN",
        )
        client.atoms.knowledge_base.delete_a_knowledge_base(
            id="id",
        )
        """
        _response = self._raw_client.delete_a_knowledge_base(id, request_options=request_options)
        return _response.data

    def get_all_knowledge_base_items(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetKnowledgebaseIdItemsResponse:
        """
        Get all knowledge base items

        Parameters
        ----------
        id : str
            The ID of the knowledge base

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

        Returns
        -------
        GetKnowledgebaseIdItemsResponse
            A list of knowledge base items

        Examples
        --------
        from smallestai import SmallestAI

        client = SmallestAI(
            token="YOUR_TOKEN",
        )
        client.atoms.knowledge_base.get_all_knowledge_base_items(
            id="id",
        )
        """
        _response = self._raw_client.get_all_knowledge_base_items(id, request_options=request_options)
        return _response.data

    def delete_a_knowledge_base_item(
        self,
        knowledge_base_id: str,
        knowledge_base_item_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DeleteKnowledgebaseKnowledgeBaseIdItemsKnowledgeBaseItemIdResponse:
        """
        Delete a knowledge base item

        Parameters
        ----------
        knowledge_base_id : str
            The ID of the knowledge base

        knowledge_base_item_id : str
            The ID of the knowledge base item

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

        Returns
        -------
        DeleteKnowledgebaseKnowledgeBaseIdItemsKnowledgeBaseItemIdResponse
            Knowledge base item deleted successfully

        Examples
        --------
        from smallestai import SmallestAI

        client = SmallestAI(
            token="YOUR_TOKEN",
        )
        client.atoms.knowledge_base.delete_a_knowledge_base_item(
            knowledge_base_id="knowledgeBaseId",
            knowledge_base_item_id="knowledgeBaseItemId",
        )
        """
        _response = self._raw_client.delete_a_knowledge_base_item(
            knowledge_base_id, knowledge_base_item_id, request_options=request_options
        )
        return _response.data

    def upload_a_pdf_file_to_a_knowledge_base(
        self, id: str, *, media: core.File, request_options: typing.Optional[RequestOptions] = None
    ) -> PostKnowledgebaseIdItemsUploadMediaResponse:
        """
        Upload a PDF file to a knowledge base. Only PDF files are accepted.

        Parameters
        ----------
        id : str
            The ID of the knowledge base

        media : core.File
            See core.File for more documentation

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

        Returns
        -------
        PostKnowledgebaseIdItemsUploadMediaResponse
            Knowledge base item created successfully

        Examples
        --------
        from smallestai import SmallestAI

        client = SmallestAI(
            token="YOUR_TOKEN",
        )
        client.atoms.knowledge_base.upload_a_pdf_file_to_a_knowledge_base(
            id="id",
        )
        """
        _response = self._raw_client.upload_a_pdf_file_to_a_knowledge_base(
            id, media=media, request_options=request_options
        )
        return _response.data


class AsyncKnowledgeBaseClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawKnowledgeBaseClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawKnowledgeBaseClient
        """
        return self._raw_client

    async def get_all_knowledge_bases(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetKnowledgebaseResponse:
        """
        Get all knowledge bases

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

        Returns
        -------
        GetKnowledgebaseResponse
            A list of knowledge bases

        Examples
        --------
        import asyncio

        from smallestai import AsyncSmallestAI

        client = AsyncSmallestAI(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.atoms.knowledge_base.get_all_knowledge_bases()


        asyncio.run(main())
        """
        _response = await self._raw_client.get_all_knowledge_bases(request_options=request_options)
        return _response.data

    async def create_a_knowledge_base(
        self,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostKnowledgebaseResponse:
        """
        Create a knowledge base

        Parameters
        ----------
        name : str

        description : typing.Optional[str]

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

        Returns
        -------
        PostKnowledgebaseResponse
            Knowledge base created successfully

        Examples
        --------
        import asyncio

        from smallestai import AsyncSmallestAI

        client = AsyncSmallestAI(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.atoms.knowledge_base.create_a_knowledge_base(
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_a_knowledge_base(
            name=name, description=description, request_options=request_options
        )
        return _response.data

    async def get_a_knowledge_base(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetKnowledgebaseIdResponse:
        """
        Get a knowledge base

        Parameters
        ----------
        id : str
            The ID of the knowledge base

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

        Returns
        -------
        GetKnowledgebaseIdResponse
            A knowledge base

        Examples
        --------
        import asyncio

        from smallestai import AsyncSmallestAI

        client = AsyncSmallestAI(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.atoms.knowledge_base.get_a_knowledge_base(
                id="id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_a_knowledge_base(id, request_options=request_options)
        return _response.data

    async def delete_a_knowledge_base(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteKnowledgebaseIdResponse:
        """
        Delete a knowledge base

        Parameters
        ----------
        id : str
            The ID of the knowledge base

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

        Returns
        -------
        DeleteKnowledgebaseIdResponse
            Knowledge base deleted successfully

        Examples
        --------
        import asyncio

        from smallestai import AsyncSmallestAI

        client = AsyncSmallestAI(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.atoms.knowledge_base.delete_a_knowledge_base(
                id="id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_a_knowledge_base(id, request_options=request_options)
        return _response.data

    async def get_all_knowledge_base_items(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetKnowledgebaseIdItemsResponse:
        """
        Get all knowledge base items

        Parameters
        ----------
        id : str
            The ID of the knowledge base

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

        Returns
        -------
        GetKnowledgebaseIdItemsResponse
            A list of knowledge base items

        Examples
        --------
        import asyncio

        from smallestai import AsyncSmallestAI

        client = AsyncSmallestAI(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.atoms.knowledge_base.get_all_knowledge_base_items(
                id="id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_all_knowledge_base_items(id, request_options=request_options)
        return _response.data

    async def delete_a_knowledge_base_item(
        self,
        knowledge_base_id: str,
        knowledge_base_item_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DeleteKnowledgebaseKnowledgeBaseIdItemsKnowledgeBaseItemIdResponse:
        """
        Delete a knowledge base item

        Parameters
        ----------
        knowledge_base_id : str
            The ID of the knowledge base

        knowledge_base_item_id : str
            The ID of the knowledge base item

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

        Returns
        -------
        DeleteKnowledgebaseKnowledgeBaseIdItemsKnowledgeBaseItemIdResponse
            Knowledge base item deleted successfully

        Examples
        --------
        import asyncio

        from smallestai import AsyncSmallestAI

        client = AsyncSmallestAI(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.atoms.knowledge_base.delete_a_knowledge_base_item(
                knowledge_base_id="knowledgeBaseId",
                knowledge_base_item_id="knowledgeBaseItemId",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_a_knowledge_base_item(
            knowledge_base_id, knowledge_base_item_id, request_options=request_options
        )
        return _response.data

    async def upload_a_pdf_file_to_a_knowledge_base(
        self, id: str, *, media: core.File, request_options: typing.Optional[RequestOptions] = None
    ) -> PostKnowledgebaseIdItemsUploadMediaResponse:
        """
        Upload a PDF file to a knowledge base. Only PDF files are accepted.

        Parameters
        ----------
        id : str
            The ID of the knowledge base

        media : core.File
            See core.File for more documentation

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

        Returns
        -------
        PostKnowledgebaseIdItemsUploadMediaResponse
            Knowledge base item created successfully

        Examples
        --------
        import asyncio

        from smallestai import AsyncSmallestAI

        client = AsyncSmallestAI(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.atoms.knowledge_base.upload_a_pdf_file_to_a_knowledge_base(
                id="id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.upload_a_pdf_file_to_a_knowledge_base(
            id, media=media, request_options=request_options
        )
        return _response.data
