diff --git a/README.md b/README.md index 72d34b4..5b4a914 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,18 @@ async with client.connect(session_options=session_options) as session: Currently, only `"high"` or `"auto"` are supported `video_quality` values. +### AI avatar disclosure + +Anam applies the AI avatar disclosure automatically when required. When +enabled, it remains visible throughout the session. To request it explicitly: + +```python +session_options = SessionOptions(show_ai_avatar_disclosure=True) +``` + +Set `show_ai_avatar_disclosure=False` when the application provides its own +disclosure. Leave it unset to use Anam's default. + ## Direct Egress (Daily) > [!WARNING] diff --git a/src/anam/types.py b/src/anam/types.py index b82444b..a267230 100644 --- a/src/anam/types.py +++ b/src/anam/types.py @@ -208,6 +208,8 @@ class SessionOptions: video_width: Requested video output width. Must be provided with video_height. video_height: Requested video output height. Must be provided with video_width. egress: Optional direct egress to a third-party transport (e.g. Daily). See :class:`EgressOptions`. + show_ai_avatar_disclosure: Show the AI avatar disclosure throughout the session. + Omit to use Anam's default. """ enable_session_replay: bool = True @@ -215,6 +217,7 @@ class SessionOptions: video_width: int | None = None video_height: int | None = None egress: EgressOptions | None = None + show_ai_avatar_disclosure: bool | None = None def __post_init__(self) -> None: self._session_replay = SessionReplayOptions( @@ -243,6 +246,8 @@ def to_dict(self) -> dict[str, Any]: result["videoHeight"] = self.video_height if self.egress is not None: result["egress"] = self.egress.to_dict() + if self.show_ai_avatar_disclosure is not None: + result["showAIAvatarDisclosure"] = self.show_ai_avatar_disclosure return result diff --git a/tests/test_client.py b/tests/test_client.py index 4c88d2d..3933e70 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -12,6 +12,8 @@ AnamEvent, ClientOptions, DirectorNotes, + EgressDailyOptions, + EgressOptions, MessageRole, MessageStreamEvent, PersonaConfig, @@ -283,6 +285,33 @@ def test_to_dict_with_video_dimensions(self) -> None: "videoHeight": 768, } + @pytest.mark.parametrize("value", [True, False]) + def test_to_dict_with_ai_avatar_disclosure(self, value: bool) -> None: + options = SessionOptions(show_ai_avatar_disclosure=value) + + assert options.to_dict()["showAIAvatarDisclosure"] is value + + def test_to_dict_omits_ai_avatar_disclosure_by_default(self) -> None: + assert "showAIAvatarDisclosure" not in SessionOptions().to_dict() + + def test_ai_avatar_disclosure_preserves_positional_egress_argument(self) -> None: + egress = EgressOptions( + mode="daily", + daily=EgressDailyOptions(room_url="https://example.daily.co/room"), + ) + options = SessionOptions(True, "high", None, None, egress, True) + + assert options.egress is egress + assert options.show_ai_avatar_disclosure is True + result = options.to_dict() + assert result["egress"]["mode"] == "daily" + assert list(result) == [ + "sessionReplay", + "videoQuality", + "egress", + "showAIAvatarDisclosure", + ] + def test_invalid_video_quality_raises_value_error(self) -> None: with pytest.raises(ValueError, match='video_quality must be either "high" or "auto"'): SessionOptions(video_quality="medium") # type: ignore[arg-type]