# 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 .raw_client import AsyncRawAgentTemplatesClient, RawAgentTemplatesClient
from .types.get_agent_template_response import GetAgentTemplateResponse
from .types.post_agent_from_template_response import PostAgentFromTemplateResponse

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


class AgentTemplatesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAgentTemplatesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAgentTemplatesClient
        """
        return self._raw_client

    def get_agent_templates(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetAgentTemplateResponse:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetAgentTemplateResponse
            Successful response

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

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

    def create_agent_from_template(
        self,
        *,
        agent_name: str,
        template_id: str,
        agent_description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostAgentFromTemplateResponse:
        """
        We have created templates for some common use cases. You can use these templates to create an agent. For getting list of templates, you can use the /agent/template endpoint. It will give you the list of templates with their description and id. You can pass the id of the template in the request body to create an agent from the template.

        Parameters
        ----------
        agent_name : str
            Name of the agent

        template_id : str
            ID of the template to use. You can get the list of templates with their description and id from the /agent/template endpoint.

        agent_description : typing.Optional[str]
            Description of the agent

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

        Returns
        -------
        PostAgentFromTemplateResponse
            Successful response

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

        client = SmallestAI(
            token="YOUR_TOKEN",
        )
        client.atoms.agent_templates.create_agent_from_template(
            agent_name="agentName",
            template_id="templateId",
        )
        """
        _response = self._raw_client.create_agent_from_template(
            agent_name=agent_name,
            template_id=template_id,
            agent_description=agent_description,
            request_options=request_options,
        )
        return _response.data


class AsyncAgentTemplatesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAgentTemplatesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAgentTemplatesClient
        """
        return self._raw_client

    async def get_agent_templates(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetAgentTemplateResponse:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        GetAgentTemplateResponse
            Successful response

        Examples
        --------
        import asyncio

        from smallestai import AsyncSmallestAI

        client = AsyncSmallestAI(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.atoms.agent_templates.get_agent_templates()


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

    async def create_agent_from_template(
        self,
        *,
        agent_name: str,
        template_id: str,
        agent_description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostAgentFromTemplateResponse:
        """
        We have created templates for some common use cases. You can use these templates to create an agent. For getting list of templates, you can use the /agent/template endpoint. It will give you the list of templates with their description and id. You can pass the id of the template in the request body to create an agent from the template.

        Parameters
        ----------
        agent_name : str
            Name of the agent

        template_id : str
            ID of the template to use. You can get the list of templates with their description and id from the /agent/template endpoint.

        agent_description : typing.Optional[str]
            Description of the agent

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

        Returns
        -------
        PostAgentFromTemplateResponse
            Successful response

        Examples
        --------
        import asyncio

        from smallestai import AsyncSmallestAI

        client = AsyncSmallestAI(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.atoms.agent_templates.create_agent_from_template(
                agent_name="agentName",
                template_id="templateId",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_agent_from_template(
            agent_name=agent_name,
            template_id=template_id,
            agent_description=agent_description,
            request_options=request_options,
        )
        return _response.data
