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

import typing
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.http_response import AsyncHttpResponse, HttpResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import parse_obj_as
from ..core.request_options import RequestOptions
from ..core.serialization import convert_and_respect_annotation_metadata
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from ..types.trigger_config_schema import TriggerConfigSchema
from ..types.voice_agent_status_response import VoiceAgentStatusResponse
from ..types.voice_profile_list_response import VoiceProfileListResponse
from ..types.voice_profile_response import VoiceProfileResponse

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


class RawMeetingBuddyVoiceAgentClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def start_voice_agent(
        self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[VoiceAgentStatusResponse]:
        """
        Start the voice agent for an active session.

        Parameters
        ----------
        session_id : str

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

        Returns
        -------
        HttpResponse[VoiceAgentStatusResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/sessions/{jsonable_encoder(session_id)}/voice-agent/start",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceAgentStatusResponse,
                    parse_obj_as(
                        type_=VoiceAgentStatusResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def stop_voice_agent(
        self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[typing.Any]:
        """
        Stop the voice agent for a session.

        Parameters
        ----------
        session_id : str

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

        Returns
        -------
        HttpResponse[typing.Any]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/sessions/{jsonable_encoder(session_id)}/voice-agent/stop",
            method="POST",
            request_options=request_options,
        )
        try:
            if _response is None or not _response.text.strip():
                return HttpResponse(response=_response, data=None)
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.Any,
                    parse_obj_as(
                        type_=typing.Any,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def voice_agent_speak(
        self, session_id: str, *, text: str, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[VoiceAgentStatusResponse]:
        """
        Force the voice agent to say specific text in the meeting.

        Parameters
        ----------
        session_id : str

        text : str
            Text for the agent to speak

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

        Returns
        -------
        HttpResponse[VoiceAgentStatusResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/sessions/{jsonable_encoder(session_id)}/voice-agent/speak",
            method="POST",
            json={
                "text": text,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceAgentStatusResponse,
                    parse_obj_as(
                        type_=VoiceAgentStatusResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def voice_agent_ask(
        self, session_id: str, *, question: str, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[VoiceAgentStatusResponse]:
        """
        Ask the voice agent a question; it responds in the meeting.

        Parameters
        ----------
        session_id : str

        question : str
            Question for the agent

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

        Returns
        -------
        HttpResponse[VoiceAgentStatusResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/sessions/{jsonable_encoder(session_id)}/voice-agent/ask",
            method="POST",
            json={
                "question": question,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceAgentStatusResponse,
                    parse_obj_as(
                        type_=VoiceAgentStatusResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def voice_agent_status(
        self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[VoiceAgentStatusResponse]:
        """
        Get voice agent status for a session.

        Parameters
        ----------
        session_id : str

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

        Returns
        -------
        HttpResponse[VoiceAgentStatusResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/sessions/{jsonable_encoder(session_id)}/voice-agent/status",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceAgentStatusResponse,
                    parse_obj_as(
                        type_=VoiceAgentStatusResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def list_voice_profiles(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[VoiceProfileListResponse]:
        """
        List all voice profiles for the organization.

        Parameters
        ----------
        organization_id : str

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

        Returns
        -------
        HttpResponse[VoiceProfileListResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/organizations/{jsonable_encoder(organization_id)}/voice-profiles",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceProfileListResponse,
                    parse_obj_as(
                        type_=VoiceProfileListResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def create_voice_profile(
        self,
        organization_id: str,
        *,
        name: str,
        tts_provider: typing.Optional[str] = OMIT,
        tts_model: typing.Optional[str] = OMIT,
        voice_id: typing.Optional[str] = OMIT,
        personality: typing.Optional[str] = OMIT,
        system_prompt: typing.Optional[str] = OMIT,
        trigger_config: typing.Optional[TriggerConfigSchema] = OMIT,
        stt_provider: typing.Optional[str] = OMIT,
        stt_model: typing.Optional[str] = OMIT,
        emotion_provider: typing.Optional[str] = OMIT,
        emotion_model: typing.Optional[str] = OMIT,
        emotion_enabled: typing.Optional[bool] = OMIT,
        model_key: typing.Optional[str] = OMIT,
        max_response_tokens: typing.Optional[int] = OMIT,
        temperature: typing.Optional[float] = OMIT,
        context_window_minutes: typing.Optional[int] = OMIT,
        max_context_tokens: typing.Optional[int] = OMIT,
        default_emotion: typing.Optional[str] = OMIT,
        emotion_adaptation: typing.Optional[bool] = OMIT,
        is_default: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[VoiceProfileResponse]:
        """
        Create a new voice profile for the organization.

        Parameters
        ----------
        organization_id : str

        name : str
            Profile name

        tts_provider : typing.Optional[str]
            TTS provider

        tts_model : typing.Optional[str]
            TTS model

        voice_id : typing.Optional[str]
            Voice identifier

        personality : typing.Optional[str]
            Personality description

        system_prompt : typing.Optional[str]
            Custom system prompt

        trigger_config : typing.Optional[TriggerConfigSchema]
            Trigger settings

        stt_provider : typing.Optional[str]

        stt_model : typing.Optional[str]

        emotion_provider : typing.Optional[str]

        emotion_model : typing.Optional[str]

        emotion_enabled : typing.Optional[bool]

        model_key : typing.Optional[str]
            LLM model key

        max_response_tokens : typing.Optional[int]

        temperature : typing.Optional[float]

        context_window_minutes : typing.Optional[int]

        max_context_tokens : typing.Optional[int]

        default_emotion : typing.Optional[str]

        emotion_adaptation : typing.Optional[bool]

        is_default : typing.Optional[bool]
            Set as org default

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

        Returns
        -------
        HttpResponse[VoiceProfileResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/organizations/{jsonable_encoder(organization_id)}/voice-profiles",
            method="POST",
            json={
                "name": name,
                "tts_provider": tts_provider,
                "tts_model": tts_model,
                "voice_id": voice_id,
                "personality": personality,
                "system_prompt": system_prompt,
                "trigger_config": convert_and_respect_annotation_metadata(
                    object_=trigger_config, annotation=TriggerConfigSchema, direction="write"
                ),
                "stt_provider": stt_provider,
                "stt_model": stt_model,
                "emotion_provider": emotion_provider,
                "emotion_model": emotion_model,
                "emotion_enabled": emotion_enabled,
                "model_key": model_key,
                "max_response_tokens": max_response_tokens,
                "temperature": temperature,
                "context_window_minutes": context_window_minutes,
                "max_context_tokens": max_context_tokens,
                "default_emotion": default_emotion,
                "emotion_adaptation": emotion_adaptation,
                "is_default": is_default,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceProfileResponse,
                    parse_obj_as(
                        type_=VoiceProfileResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def get_voice_profile(
        self, organization_id: str, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[VoiceProfileResponse]:
        """
        Get a specific voice profile.

        Parameters
        ----------
        organization_id : str

        profile_id : str

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

        Returns
        -------
        HttpResponse[VoiceProfileResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/organizations/{jsonable_encoder(organization_id)}/voice-profiles/{jsonable_encoder(profile_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceProfileResponse,
                    parse_obj_as(
                        type_=VoiceProfileResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def update_voice_profile(
        self,
        organization_id: str,
        profile_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        tts_provider: typing.Optional[str] = OMIT,
        tts_model: typing.Optional[str] = OMIT,
        voice_id: typing.Optional[str] = OMIT,
        personality: typing.Optional[str] = OMIT,
        system_prompt: typing.Optional[str] = OMIT,
        trigger_config: typing.Optional[TriggerConfigSchema] = OMIT,
        stt_provider: typing.Optional[str] = OMIT,
        stt_model: typing.Optional[str] = OMIT,
        emotion_provider: typing.Optional[str] = OMIT,
        emotion_model: typing.Optional[str] = OMIT,
        emotion_enabled: typing.Optional[bool] = OMIT,
        model_key: typing.Optional[str] = OMIT,
        max_response_tokens: typing.Optional[int] = OMIT,
        temperature: typing.Optional[float] = OMIT,
        context_window_minutes: typing.Optional[int] = OMIT,
        max_context_tokens: typing.Optional[int] = OMIT,
        default_emotion: typing.Optional[str] = OMIT,
        emotion_adaptation: typing.Optional[bool] = OMIT,
        is_default: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[VoiceProfileResponse]:
        """
        Update a voice profile.

        Parameters
        ----------
        organization_id : str

        profile_id : str

        name : typing.Optional[str]

        tts_provider : typing.Optional[str]

        tts_model : typing.Optional[str]

        voice_id : typing.Optional[str]

        personality : typing.Optional[str]

        system_prompt : typing.Optional[str]

        trigger_config : typing.Optional[TriggerConfigSchema]

        stt_provider : typing.Optional[str]

        stt_model : typing.Optional[str]

        emotion_provider : typing.Optional[str]

        emotion_model : typing.Optional[str]

        emotion_enabled : typing.Optional[bool]

        model_key : typing.Optional[str]

        max_response_tokens : typing.Optional[int]

        temperature : typing.Optional[float]

        context_window_minutes : typing.Optional[int]

        max_context_tokens : typing.Optional[int]

        default_emotion : typing.Optional[str]

        emotion_adaptation : typing.Optional[bool]

        is_default : typing.Optional[bool]

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

        Returns
        -------
        HttpResponse[VoiceProfileResponse]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/organizations/{jsonable_encoder(organization_id)}/voice-profiles/{jsonable_encoder(profile_id)}",
            method="PUT",
            json={
                "name": name,
                "tts_provider": tts_provider,
                "tts_model": tts_model,
                "voice_id": voice_id,
                "personality": personality,
                "system_prompt": system_prompt,
                "trigger_config": convert_and_respect_annotation_metadata(
                    object_=trigger_config, annotation=typing.Optional[TriggerConfigSchema], direction="write"
                ),
                "stt_provider": stt_provider,
                "stt_model": stt_model,
                "emotion_provider": emotion_provider,
                "emotion_model": emotion_model,
                "emotion_enabled": emotion_enabled,
                "model_key": model_key,
                "max_response_tokens": max_response_tokens,
                "temperature": temperature,
                "context_window_minutes": context_window_minutes,
                "max_context_tokens": max_context_tokens,
                "default_emotion": default_emotion,
                "emotion_adaptation": emotion_adaptation,
                "is_default": is_default,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceProfileResponse,
                    parse_obj_as(
                        type_=VoiceProfileResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def delete_voice_profile(
        self, organization_id: str, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> HttpResponse[typing.Any]:
        """
        Delete a voice profile.

        Parameters
        ----------
        organization_id : str

        profile_id : str

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

        Returns
        -------
        HttpResponse[typing.Any]
            Successful Response
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/organizations/{jsonable_encoder(organization_id)}/voice-profiles/{jsonable_encoder(profile_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if _response is None or not _response.text.strip():
                return HttpResponse(response=_response, data=None)
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.Any,
                    parse_obj_as(
                        type_=typing.Any,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


class AsyncRawMeetingBuddyVoiceAgentClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def start_voice_agent(
        self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[VoiceAgentStatusResponse]:
        """
        Start the voice agent for an active session.

        Parameters
        ----------
        session_id : str

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

        Returns
        -------
        AsyncHttpResponse[VoiceAgentStatusResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/sessions/{jsonable_encoder(session_id)}/voice-agent/start",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceAgentStatusResponse,
                    parse_obj_as(
                        type_=VoiceAgentStatusResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def stop_voice_agent(
        self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[typing.Any]:
        """
        Stop the voice agent for a session.

        Parameters
        ----------
        session_id : str

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

        Returns
        -------
        AsyncHttpResponse[typing.Any]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/sessions/{jsonable_encoder(session_id)}/voice-agent/stop",
            method="POST",
            request_options=request_options,
        )
        try:
            if _response is None or not _response.text.strip():
                return AsyncHttpResponse(response=_response, data=None)
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.Any,
                    parse_obj_as(
                        type_=typing.Any,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def voice_agent_speak(
        self, session_id: str, *, text: str, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[VoiceAgentStatusResponse]:
        """
        Force the voice agent to say specific text in the meeting.

        Parameters
        ----------
        session_id : str

        text : str
            Text for the agent to speak

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

        Returns
        -------
        AsyncHttpResponse[VoiceAgentStatusResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/sessions/{jsonable_encoder(session_id)}/voice-agent/speak",
            method="POST",
            json={
                "text": text,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceAgentStatusResponse,
                    parse_obj_as(
                        type_=VoiceAgentStatusResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def voice_agent_ask(
        self, session_id: str, *, question: str, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[VoiceAgentStatusResponse]:
        """
        Ask the voice agent a question; it responds in the meeting.

        Parameters
        ----------
        session_id : str

        question : str
            Question for the agent

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

        Returns
        -------
        AsyncHttpResponse[VoiceAgentStatusResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/sessions/{jsonable_encoder(session_id)}/voice-agent/ask",
            method="POST",
            json={
                "question": question,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceAgentStatusResponse,
                    parse_obj_as(
                        type_=VoiceAgentStatusResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def voice_agent_status(
        self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[VoiceAgentStatusResponse]:
        """
        Get voice agent status for a session.

        Parameters
        ----------
        session_id : str

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

        Returns
        -------
        AsyncHttpResponse[VoiceAgentStatusResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/sessions/{jsonable_encoder(session_id)}/voice-agent/status",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceAgentStatusResponse,
                    parse_obj_as(
                        type_=VoiceAgentStatusResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def list_voice_profiles(
        self, organization_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[VoiceProfileListResponse]:
        """
        List all voice profiles for the organization.

        Parameters
        ----------
        organization_id : str

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

        Returns
        -------
        AsyncHttpResponse[VoiceProfileListResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/organizations/{jsonable_encoder(organization_id)}/voice-profiles",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceProfileListResponse,
                    parse_obj_as(
                        type_=VoiceProfileListResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def create_voice_profile(
        self,
        organization_id: str,
        *,
        name: str,
        tts_provider: typing.Optional[str] = OMIT,
        tts_model: typing.Optional[str] = OMIT,
        voice_id: typing.Optional[str] = OMIT,
        personality: typing.Optional[str] = OMIT,
        system_prompt: typing.Optional[str] = OMIT,
        trigger_config: typing.Optional[TriggerConfigSchema] = OMIT,
        stt_provider: typing.Optional[str] = OMIT,
        stt_model: typing.Optional[str] = OMIT,
        emotion_provider: typing.Optional[str] = OMIT,
        emotion_model: typing.Optional[str] = OMIT,
        emotion_enabled: typing.Optional[bool] = OMIT,
        model_key: typing.Optional[str] = OMIT,
        max_response_tokens: typing.Optional[int] = OMIT,
        temperature: typing.Optional[float] = OMIT,
        context_window_minutes: typing.Optional[int] = OMIT,
        max_context_tokens: typing.Optional[int] = OMIT,
        default_emotion: typing.Optional[str] = OMIT,
        emotion_adaptation: typing.Optional[bool] = OMIT,
        is_default: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[VoiceProfileResponse]:
        """
        Create a new voice profile for the organization.

        Parameters
        ----------
        organization_id : str

        name : str
            Profile name

        tts_provider : typing.Optional[str]
            TTS provider

        tts_model : typing.Optional[str]
            TTS model

        voice_id : typing.Optional[str]
            Voice identifier

        personality : typing.Optional[str]
            Personality description

        system_prompt : typing.Optional[str]
            Custom system prompt

        trigger_config : typing.Optional[TriggerConfigSchema]
            Trigger settings

        stt_provider : typing.Optional[str]

        stt_model : typing.Optional[str]

        emotion_provider : typing.Optional[str]

        emotion_model : typing.Optional[str]

        emotion_enabled : typing.Optional[bool]

        model_key : typing.Optional[str]
            LLM model key

        max_response_tokens : typing.Optional[int]

        temperature : typing.Optional[float]

        context_window_minutes : typing.Optional[int]

        max_context_tokens : typing.Optional[int]

        default_emotion : typing.Optional[str]

        emotion_adaptation : typing.Optional[bool]

        is_default : typing.Optional[bool]
            Set as org default

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

        Returns
        -------
        AsyncHttpResponse[VoiceProfileResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/organizations/{jsonable_encoder(organization_id)}/voice-profiles",
            method="POST",
            json={
                "name": name,
                "tts_provider": tts_provider,
                "tts_model": tts_model,
                "voice_id": voice_id,
                "personality": personality,
                "system_prompt": system_prompt,
                "trigger_config": convert_and_respect_annotation_metadata(
                    object_=trigger_config, annotation=TriggerConfigSchema, direction="write"
                ),
                "stt_provider": stt_provider,
                "stt_model": stt_model,
                "emotion_provider": emotion_provider,
                "emotion_model": emotion_model,
                "emotion_enabled": emotion_enabled,
                "model_key": model_key,
                "max_response_tokens": max_response_tokens,
                "temperature": temperature,
                "context_window_minutes": context_window_minutes,
                "max_context_tokens": max_context_tokens,
                "default_emotion": default_emotion,
                "emotion_adaptation": emotion_adaptation,
                "is_default": is_default,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceProfileResponse,
                    parse_obj_as(
                        type_=VoiceProfileResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def get_voice_profile(
        self, organization_id: str, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[VoiceProfileResponse]:
        """
        Get a specific voice profile.

        Parameters
        ----------
        organization_id : str

        profile_id : str

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

        Returns
        -------
        AsyncHttpResponse[VoiceProfileResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/organizations/{jsonable_encoder(organization_id)}/voice-profiles/{jsonable_encoder(profile_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceProfileResponse,
                    parse_obj_as(
                        type_=VoiceProfileResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def update_voice_profile(
        self,
        organization_id: str,
        profile_id: str,
        *,
        name: typing.Optional[str] = OMIT,
        tts_provider: typing.Optional[str] = OMIT,
        tts_model: typing.Optional[str] = OMIT,
        voice_id: typing.Optional[str] = OMIT,
        personality: typing.Optional[str] = OMIT,
        system_prompt: typing.Optional[str] = OMIT,
        trigger_config: typing.Optional[TriggerConfigSchema] = OMIT,
        stt_provider: typing.Optional[str] = OMIT,
        stt_model: typing.Optional[str] = OMIT,
        emotion_provider: typing.Optional[str] = OMIT,
        emotion_model: typing.Optional[str] = OMIT,
        emotion_enabled: typing.Optional[bool] = OMIT,
        model_key: typing.Optional[str] = OMIT,
        max_response_tokens: typing.Optional[int] = OMIT,
        temperature: typing.Optional[float] = OMIT,
        context_window_minutes: typing.Optional[int] = OMIT,
        max_context_tokens: typing.Optional[int] = OMIT,
        default_emotion: typing.Optional[str] = OMIT,
        emotion_adaptation: typing.Optional[bool] = OMIT,
        is_default: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[VoiceProfileResponse]:
        """
        Update a voice profile.

        Parameters
        ----------
        organization_id : str

        profile_id : str

        name : typing.Optional[str]

        tts_provider : typing.Optional[str]

        tts_model : typing.Optional[str]

        voice_id : typing.Optional[str]

        personality : typing.Optional[str]

        system_prompt : typing.Optional[str]

        trigger_config : typing.Optional[TriggerConfigSchema]

        stt_provider : typing.Optional[str]

        stt_model : typing.Optional[str]

        emotion_provider : typing.Optional[str]

        emotion_model : typing.Optional[str]

        emotion_enabled : typing.Optional[bool]

        model_key : typing.Optional[str]

        max_response_tokens : typing.Optional[int]

        temperature : typing.Optional[float]

        context_window_minutes : typing.Optional[int]

        max_context_tokens : typing.Optional[int]

        default_emotion : typing.Optional[str]

        emotion_adaptation : typing.Optional[bool]

        is_default : typing.Optional[bool]

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

        Returns
        -------
        AsyncHttpResponse[VoiceProfileResponse]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/organizations/{jsonable_encoder(organization_id)}/voice-profiles/{jsonable_encoder(profile_id)}",
            method="PUT",
            json={
                "name": name,
                "tts_provider": tts_provider,
                "tts_model": tts_model,
                "voice_id": voice_id,
                "personality": personality,
                "system_prompt": system_prompt,
                "trigger_config": convert_and_respect_annotation_metadata(
                    object_=trigger_config, annotation=typing.Optional[TriggerConfigSchema], direction="write"
                ),
                "stt_provider": stt_provider,
                "stt_model": stt_model,
                "emotion_provider": emotion_provider,
                "emotion_model": emotion_model,
                "emotion_enabled": emotion_enabled,
                "model_key": model_key,
                "max_response_tokens": max_response_tokens,
                "temperature": temperature,
                "context_window_minutes": context_window_minutes,
                "max_context_tokens": max_context_tokens,
                "default_emotion": default_emotion,
                "emotion_adaptation": emotion_adaptation,
                "is_default": is_default,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    VoiceProfileResponse,
                    parse_obj_as(
                        type_=VoiceProfileResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def delete_voice_profile(
        self, organization_id: str, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AsyncHttpResponse[typing.Any]:
        """
        Delete a voice profile.

        Parameters
        ----------
        organization_id : str

        profile_id : str

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

        Returns
        -------
        AsyncHttpResponse[typing.Any]
            Successful Response
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/meeting-buddy/organizations/{jsonable_encoder(organization_id)}/voice-profiles/{jsonable_encoder(profile_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if _response is None or not _response.text.strip():
                return AsyncHttpResponse(response=_response, data=None)
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.Any,
                    parse_obj_as(
                        type_=typing.Any,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            if _response.status_code == 422:
                raise UnprocessableEntityError(
                    headers=dict(_response.headers),
                    body=typing.cast(
                        typing.Any,
                        parse_obj_as(
                            type_=typing.Any,  # type: ignore
                            object_=_response.json(),
                        ),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
