# 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.analysis_scope import AnalysisScope
from ....types.get_conversation_response_model import GetConversationResponseModel
from .raw_client import AsyncRawAnalysisClient, RawAnalysisClient

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


class AnalysisClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAnalysisClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAnalysisClient
        """
        return self._raw_client

    def run(
        self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetConversationResponseModel:
        """
        Run the analysis for a conversation using the agent's current evaluation criteria and data collection settings.

        Parameters
        ----------
        conversation_id : str
            ID of the conversation

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

        Returns
        -------
        GetConversationResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.analysis.run(
            conversation_id="conversation_id",
        )
        """
        _response = self._raw_client.run(conversation_id, request_options=request_options)
        return _response.data

    def run_evaluation(
        self,
        conversation_id: str,
        *,
        evaluation_id: str,
        scope: typing.Optional[AnalysisScope] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetConversationResponseModel:
        """
        Rerun a specific evaluation for a conversation.

        Parameters
        ----------
        conversation_id : str
            ID of the conversation

        evaluation_id : str
            ID of the single evaluation criterion to rerun.

        scope : typing.Optional[AnalysisScope]

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

        Returns
        -------
        GetConversationResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.analysis.run_evaluation(
            conversation_id="conversation_id",
            evaluation_id="evaluation_id",
        )
        """
        _response = self._raw_client.run_evaluation(
            conversation_id, evaluation_id=evaluation_id, scope=scope, request_options=request_options
        )
        return _response.data


class AsyncAnalysisClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAnalysisClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAnalysisClient
        """
        return self._raw_client

    async def run(
        self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> GetConversationResponseModel:
        """
        Run the analysis for a conversation using the agent's current evaluation criteria and data collection settings.

        Parameters
        ----------
        conversation_id : str
            ID of the conversation

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

        Returns
        -------
        GetConversationResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.analysis.run(
                conversation_id="conversation_id",
            )


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

    async def run_evaluation(
        self,
        conversation_id: str,
        *,
        evaluation_id: str,
        scope: typing.Optional[AnalysisScope] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetConversationResponseModel:
        """
        Rerun a specific evaluation for a conversation.

        Parameters
        ----------
        conversation_id : str
            ID of the conversation

        evaluation_id : str
            ID of the single evaluation criterion to rerun.

        scope : typing.Optional[AnalysisScope]

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

        Returns
        -------
        GetConversationResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.analysis.run_evaluation(
                conversation_id="conversation_id",
                evaluation_id="evaluation_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.run_evaluation(
            conversation_id, evaluation_id=evaluation_id, scope=scope, request_options=request_options
        )
        return _response.data
