Repository: livekit/agents
File: livekit-plugins/livekit-plugins-avatario/livekit/plugins/avatario/api.py (Python)

Code before:
        self._owns_session = session is None

    async def __aenter__(self) -> AvatarioAPI:
        if self._owns_session:
            self._session = aiohttp.ClientSession()
        return self

    async def __aexit__(
        self, exc_type: type | None, exc_val: Exception | None, exc_tb: Any
    ) -> None:
        if self._owns_session and self._session:
            await self._session.close()

    async def start_session(
        self,
        *,
        livekit_agent_identity: NotGivenOr[str] = NOT_GIVEN,
        properties: NotGivenOr[dict[str, Any]] = NOT_GIVEN,
    ) -> None:
        """
        Initiate a session request

        Args:
            livekit_agent_identity: the participant identity of the agent in room.
            properties: A dictionary consisting of room url and token used by the
                        avatario particpant to join the room.
        """
        if not utils.is_given(livekit_agent_identity):
            raise AvatarioException(
                "the identity of agent needs to be provided "
                "to ensure its proper communication with avatario backend"
            )

        properties = properties if utils.is_given(properties) else {}

        payload = {
            "avatario_face_id": self._avatar_id,
            "agent_id": livekit_agent_identity,
            "livekit": properties,
        }

        if utils.is_given(self._video_info):
            payload.update(self._video_info)
        await self._post(payload)

    async def _post(self, payload: dict[str, Any]) -> dict[str, Any]:
        """
        Make a POST request to the Avatario API with retry logic.

        Args:
            payload: JSON payload for the request

Review comment (suggestion):
```suggestion
                        avatario participant to join the room.
```

Code after:
        self._owns_session = session is None

    async def __aenter__(self) -> AvatarioAPI:
        if self._owns_session:
            self._session = aiohttp.ClientSession()
        return self

    async def __aexit__(
        self, exc_type: type | None, exc_val: Exception | None, exc_tb: Any
    ) -> None:
        if self._owns_session and self._session:
            await self._session.close()

    async def start_session(
        self,
        *,
        livekit_agent_identity: NotGivenOr[str] = NOT_GIVEN,
        properties: NotGivenOr[dict[str, Any]] = NOT_GIVEN,
    ) -> None:
        """
        Initiate a session request

        Args:
            livekit_agent_identity: the participant identity of the agent in room.
            properties: A dictionary consisting of room url and token used by the
                        avatario participant to join the room.
        """
        if not utils.is_given(livekit_agent_identity):
            raise AvatarioException(
                "the identity of agent needs to be provided "
                "to ensure its proper communication with avatario backend"
            )

        properties = properties if utils.is_given(properties) else {}

        payload = {
            "avatario_face_id": self._avatar_id,
            "agent_id": livekit_agent_identity,
            "livekit": properties,
        }

        if utils.is_given(self._video_info):
            payload.update(self._video_info)
        await self._post(payload)

    async def _post(self, payload: dict[str, Any]) -> dict[str, Any]:
        """
        Make a POST request to the Avatario API with retry logic.

        Args:
            payload: JSON payload for the request