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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.pagination import AsyncPager, SyncPager
from ..core.request_options import RequestOptions
from ..types.generation_preset import GenerationPreset
from .raw_client import AsyncRawGenerationPresetsClient, RawGenerationPresetsClient


class GenerationPresetsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawGenerationPresetsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawGenerationPresetsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        llm_name: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page_key: typing.Optional[str] = None,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SyncPager[GenerationPreset]:
        """
        List generation presets used for query or chat requests. Generation presets are
        the build of properties used to configure generation for a request. This includes
        the template that renders the prompt, and various generation settings like
        `temperature`.

        Parameters
        ----------
        llm_name : typing.Optional[str]
            Filter presets by the LLM name.

        limit : typing.Optional[int]
            The maximum number of results to return in the list.

        page_key : typing.Optional[str]
            Used to retrieve the next page of generation presets after the limit has been reached.
            This parameter is not needed for the first page of results.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

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

        Returns
        -------
        SyncPager[GenerationPreset]
            List of Generation Presets.

        Examples
        --------
        from vectara import Vectara
        client = Vectara(api_key="YOUR_API_KEY", client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET", )
        response = client.generation_presets.list()
        for item in response:
            yield item
        # alternatively, you can paginate page-by-page
        for page in response.iter_pages():
            yield page
        """
        response = self._raw_client.list(
            llm_name=llm_name,
            limit=limit,
            page_key=page_key,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            request_options=request_options,
        )
        return response.data


class AsyncGenerationPresetsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawGenerationPresetsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawGenerationPresetsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        llm_name: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        page_key: typing.Optional[str] = None,
        request_timeout: typing.Optional[int] = None,
        request_timeout_millis: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncPager[GenerationPreset]:
        """
        List generation presets used for query or chat requests. Generation presets are
        the build of properties used to configure generation for a request. This includes
        the template that renders the prompt, and various generation settings like
        `temperature`.

        Parameters
        ----------
        llm_name : typing.Optional[str]
            Filter presets by the LLM name.

        limit : typing.Optional[int]
            The maximum number of results to return in the list.

        page_key : typing.Optional[str]
            Used to retrieve the next page of generation presets after the limit has been reached.
            This parameter is not needed for the first page of results.

        request_timeout : typing.Optional[int]
            The API will make a best effort to complete the request in the specified seconds or time out.

        request_timeout_millis : typing.Optional[int]
            The API will make a best effort to complete the request in the specified milliseconds or time out.

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

        Returns
        -------
        AsyncPager[GenerationPreset]
            List of Generation Presets.

        Examples
        --------
        from vectara import AsyncVectara
        import asyncio
        client = AsyncVectara(api_key="YOUR_API_KEY", client_id="YOUR_CLIENT_ID", client_secret="YOUR_CLIENT_SECRET", )
        async def main() -> None:
            response = await client.generation_presets.list()
            async for item in response:
                yield item

            # alternatively, you can paginate page-by-page
            async for page in response.iter_pages():
                yield page
        asyncio.run(main())
        """
        response = await self._raw_client.list(
            llm_name=llm_name,
            limit=limit,
            page_key=page_key,
            request_timeout=request_timeout,
            request_timeout_millis=request_timeout_millis,
            request_options=request_options,
        )
        return response.data
