# 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.evaluator_config import EvaluatorConfig
from ..types.evaluator_mapping_output_interface import EvaluatorMappingOutputInterface
from ..types.evaluator_output_interface import EvaluatorOutputInterface
from ..types.legacy_evaluator import LegacyEvaluator
from .raw_client import AsyncRawEvaluatorsClient, RawEvaluatorsClient

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


class EvaluatorsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawEvaluatorsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawEvaluatorsClient
        """
        return self._raw_client

    def get_evaluators_endpoint(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[LegacyEvaluator]:
        """
        Endpoint to fetch a list of evaluators.

        Returns:
            List[Evaluator]: A list of evaluator objects.

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

        Returns
        -------
        typing.List[LegacyEvaluator]
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.evaluators.get_evaluators_endpoint()
        """
        _response = self._raw_client.get_evaluators_endpoint(
            request_options=request_options
        )
        return _response.data

    def evaluator_data_map(
        self,
        *,
        inputs: typing.Dict[str, typing.Optional[typing.Any]],
        mapping: typing.Dict[str, typing.Optional[typing.Any]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EvaluatorMappingOutputInterface:
        """
        Endpoint to map the experiment data tree to evaluator interface.

        Args:
            request (Request): The request object.
            payload (EvaluatorMappingInputInterface): The payload containing the request data.

        Returns:
            EvaluatorMappingOutputInterface: the evaluator mapping output object

        Parameters
        ----------
        inputs : typing.Dict[str, typing.Optional[typing.Any]]

        mapping : typing.Dict[str, typing.Optional[typing.Any]]

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

        Returns
        -------
        EvaluatorMappingOutputInterface
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.evaluators.evaluator_data_map(
            inputs={"key": "value"},
            mapping={"key": "value"},
        )
        """
        _response = self._raw_client.evaluator_data_map(
            inputs=inputs, mapping=mapping, request_options=request_options
        )
        return _response.data

    def evaluator_run(
        self,
        evaluator_key: str,
        *,
        inputs: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        settings: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        credentials: typing.Optional[
            typing.Dict[str, typing.Optional[typing.Any]]
        ] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EvaluatorOutputInterface:
        """
        Endpoint to evaluate LLM app run

        Args:
            request (Request): The request object.
            evaluator_key (str): The key of the evaluator.
            payload (EvaluatorInputInterface): The payload containing the request data.

        Returns:
            result: EvaluatorOutputInterface object containing the outputs.

        Parameters
        ----------
        evaluator_key : str

        inputs : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

        settings : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

        credentials : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

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

        Returns
        -------
        EvaluatorOutputInterface
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.evaluators.evaluator_run(
            evaluator_key="evaluator_key",
        )
        """
        _response = self._raw_client.evaluator_run(
            evaluator_key,
            inputs=inputs,
            settings=settings,
            credentials=credentials,
            request_options=request_options,
        )
        return _response.data

    def get_evaluator_configs(
        self, *, app_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[EvaluatorConfig]:
        """
        Endpoint to fetch evaluator configurations for a specific app.

        Args:
            app_id (str): The ID of the app.

        Returns:
            List[EvaluatorConfigDB]: A list of evaluator configuration objects.

        Parameters
        ----------
        app_id : str

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

        Returns
        -------
        typing.List[EvaluatorConfig]
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.evaluators.get_evaluator_configs(
            app_id="app_id",
        )
        """
        _response = self._raw_client.get_evaluator_configs(
            app_id=app_id, request_options=request_options
        )
        return _response.data

    def create_new_evaluator_config(
        self,
        *,
        app_id: str,
        name: str,
        evaluator_key: str,
        settings_values: typing.Dict[str, typing.Optional[typing.Any]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EvaluatorConfig:
        """
        Endpoint to fetch evaluator configurations for a specific app.

        Args:
            app_id (str): The ID of the app.

        Returns:
            EvaluatorConfigDB: Evaluator configuration api model.

        Parameters
        ----------
        app_id : str

        name : str

        evaluator_key : str

        settings_values : typing.Dict[str, typing.Optional[typing.Any]]

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

        Returns
        -------
        EvaluatorConfig
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.evaluators.create_new_evaluator_config(
            app_id="app_id",
            name="name",
            evaluator_key="evaluator_key",
            settings_values={"key": "value"},
        )
        """
        _response = self._raw_client.create_new_evaluator_config(
            app_id=app_id,
            name=name,
            evaluator_key=evaluator_key,
            settings_values=settings_values,
            request_options=request_options,
        )
        return _response.data

    def get_evaluator_config(
        self,
        evaluator_config_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EvaluatorConfig:
        """
        Endpoint to fetch evaluator configurations for a specific app.

        Returns:
            List[EvaluatorConfigDB]: A list of evaluator configuration objects.

        Parameters
        ----------
        evaluator_config_id : str

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

        Returns
        -------
        EvaluatorConfig
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.evaluators.get_evaluator_config(
            evaluator_config_id="evaluator_config_id",
        )
        """
        _response = self._raw_client.get_evaluator_config(
            evaluator_config_id, request_options=request_options
        )
        return _response.data

    def update_evaluator_config(
        self,
        evaluator_config_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        evaluator_key: typing.Optional[str] = OMIT,
        settings_values: typing.Optional[
            typing.Dict[str, typing.Optional[typing.Any]]
        ] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EvaluatorConfig:
        """
        Endpoint to update evaluator configurations for a specific app.

        Returns:
            List[EvaluatorConfigDB]: A list of evaluator configuration objects.

        Parameters
        ----------
        evaluator_config_id : str

        name : typing.Optional[str]

        evaluator_key : typing.Optional[str]

        settings_values : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

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

        Returns
        -------
        EvaluatorConfig
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.evaluators.update_evaluator_config(
            evaluator_config_id="evaluator_config_id",
        )
        """
        _response = self._raw_client.update_evaluator_config(
            evaluator_config_id,
            name=name,
            evaluator_key=evaluator_key,
            settings_values=settings_values,
            request_options=request_options,
        )
        return _response.data

    def delete_evaluator_config(
        self,
        evaluator_config_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> bool:
        """
        Endpoint to delete a specific evaluator configuration.

        Args:
            evaluator_config_id (str): The unique identifier of the evaluator configuration.

        Returns:
            bool: True if deletion was successful, False otherwise.

        Parameters
        ----------
        evaluator_config_id : str

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

        Returns
        -------
        bool
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.evaluators.delete_evaluator_config(
            evaluator_config_id="evaluator_config_id",
        )
        """
        _response = self._raw_client.delete_evaluator_config(
            evaluator_config_id, request_options=request_options
        )
        return _response.data


class AsyncEvaluatorsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawEvaluatorsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawEvaluatorsClient
        """
        return self._raw_client

    async def get_evaluators_endpoint(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[LegacyEvaluator]:
        """
        Endpoint to fetch a list of evaluators.

        Returns:
            List[Evaluator]: A list of evaluator objects.

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

        Returns
        -------
        typing.List[LegacyEvaluator]
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.evaluators.get_evaluators_endpoint()


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

    async def evaluator_data_map(
        self,
        *,
        inputs: typing.Dict[str, typing.Optional[typing.Any]],
        mapping: typing.Dict[str, typing.Optional[typing.Any]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EvaluatorMappingOutputInterface:
        """
        Endpoint to map the experiment data tree to evaluator interface.

        Args:
            request (Request): The request object.
            payload (EvaluatorMappingInputInterface): The payload containing the request data.

        Returns:
            EvaluatorMappingOutputInterface: the evaluator mapping output object

        Parameters
        ----------
        inputs : typing.Dict[str, typing.Optional[typing.Any]]

        mapping : typing.Dict[str, typing.Optional[typing.Any]]

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

        Returns
        -------
        EvaluatorMappingOutputInterface
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.evaluators.evaluator_data_map(
                inputs={"key": "value"},
                mapping={"key": "value"},
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.evaluator_data_map(
            inputs=inputs, mapping=mapping, request_options=request_options
        )
        return _response.data

    async def evaluator_run(
        self,
        evaluator_key: str,
        *,
        inputs: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        settings: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
        credentials: typing.Optional[
            typing.Dict[str, typing.Optional[typing.Any]]
        ] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EvaluatorOutputInterface:
        """
        Endpoint to evaluate LLM app run

        Args:
            request (Request): The request object.
            evaluator_key (str): The key of the evaluator.
            payload (EvaluatorInputInterface): The payload containing the request data.

        Returns:
            result: EvaluatorOutputInterface object containing the outputs.

        Parameters
        ----------
        evaluator_key : str

        inputs : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

        settings : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

        credentials : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

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

        Returns
        -------
        EvaluatorOutputInterface
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.evaluators.evaluator_run(
                evaluator_key="evaluator_key",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.evaluator_run(
            evaluator_key,
            inputs=inputs,
            settings=settings,
            credentials=credentials,
            request_options=request_options,
        )
        return _response.data

    async def get_evaluator_configs(
        self, *, app_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[EvaluatorConfig]:
        """
        Endpoint to fetch evaluator configurations for a specific app.

        Args:
            app_id (str): The ID of the app.

        Returns:
            List[EvaluatorConfigDB]: A list of evaluator configuration objects.

        Parameters
        ----------
        app_id : str

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

        Returns
        -------
        typing.List[EvaluatorConfig]
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.evaluators.get_evaluator_configs(
                app_id="app_id",
            )


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

    async def create_new_evaluator_config(
        self,
        *,
        app_id: str,
        name: str,
        evaluator_key: str,
        settings_values: typing.Dict[str, typing.Optional[typing.Any]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EvaluatorConfig:
        """
        Endpoint to fetch evaluator configurations for a specific app.

        Args:
            app_id (str): The ID of the app.

        Returns:
            EvaluatorConfigDB: Evaluator configuration api model.

        Parameters
        ----------
        app_id : str

        name : str

        evaluator_key : str

        settings_values : typing.Dict[str, typing.Optional[typing.Any]]

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

        Returns
        -------
        EvaluatorConfig
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.evaluators.create_new_evaluator_config(
                app_id="app_id",
                name="name",
                evaluator_key="evaluator_key",
                settings_values={"key": "value"},
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_new_evaluator_config(
            app_id=app_id,
            name=name,
            evaluator_key=evaluator_key,
            settings_values=settings_values,
            request_options=request_options,
        )
        return _response.data

    async def get_evaluator_config(
        self,
        evaluator_config_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EvaluatorConfig:
        """
        Endpoint to fetch evaluator configurations for a specific app.

        Returns:
            List[EvaluatorConfigDB]: A list of evaluator configuration objects.

        Parameters
        ----------
        evaluator_config_id : str

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

        Returns
        -------
        EvaluatorConfig
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.evaluators.get_evaluator_config(
                evaluator_config_id="evaluator_config_id",
            )


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

    async def update_evaluator_config(
        self,
        evaluator_config_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        evaluator_key: typing.Optional[str] = OMIT,
        settings_values: typing.Optional[
            typing.Dict[str, typing.Optional[typing.Any]]
        ] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EvaluatorConfig:
        """
        Endpoint to update evaluator configurations for a specific app.

        Returns:
            List[EvaluatorConfigDB]: A list of evaluator configuration objects.

        Parameters
        ----------
        evaluator_config_id : str

        name : typing.Optional[str]

        evaluator_key : typing.Optional[str]

        settings_values : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]

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

        Returns
        -------
        EvaluatorConfig
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.evaluators.update_evaluator_config(
                evaluator_config_id="evaluator_config_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_evaluator_config(
            evaluator_config_id,
            name=name,
            evaluator_key=evaluator_key,
            settings_values=settings_values,
            request_options=request_options,
        )
        return _response.data

    async def delete_evaluator_config(
        self,
        evaluator_config_id: str,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> bool:
        """
        Endpoint to delete a specific evaluator configuration.

        Args:
            evaluator_config_id (str): The unique identifier of the evaluator configuration.

        Returns:
            bool: True if deletion was successful, False otherwise.

        Parameters
        ----------
        evaluator_config_id : str

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

        Returns
        -------
        bool
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.evaluators.delete_evaluator_config(
                evaluator_config_id="evaluator_config_id",
            )


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