diff --git a/README.md b/README.md index 179611b5a..1b3848d4f 100644 --- a/README.md +++ b/README.md @@ -1486,6 +1486,8 @@ print(response.text) ## Interactions (Preview) +> **Warning:** The Interactions API is in **Beta**. This is a preview of an experimental feature. Features and schemas are subject to **breaking changes**. + The Interactions API is a unified interface for interacting with Gemini models and agents. It simplifies state management, tool orchestration, and long-running tasks. See the [documentation site](https://ai.google.dev/gemini-api/docs/interactions) for more details. diff --git a/google/genai/client.py b/google/genai/client.py index a1eeaf635..2eb1657c8 100644 --- a/google/genai/client.py +++ b/google/genai/client.py @@ -47,7 +47,7 @@ from ._interactions.resources import AsyncInteractionsResource as AsyncNextGenInteractionsResource, InteractionsResource as NextGenInteractionsResource from ._interactions.resources import WebhooksResource, AsyncWebhooksResource - +_interactions_experimental_warned = False class AsyncGeminiNextGenAPIClientAdapter(_interactions.AsyncGeminiNextGenAPIClientAdapter): """Adapter for the Gemini NextGen API Client.""" @@ -189,6 +189,14 @@ def _nextgen_client(self) -> AsyncGeminiNextGenAPIClient: @property def interactions(self) -> AsyncNextGenInteractionsResource: + global _interactions_experimental_warned + if not _interactions_experimental_warned: + _interactions_experimental_warned = True + warnings.warn( + 'Interactions usage is experimental and may change in future versions.', + category=UserWarning, + stacklevel=1, + ) return self._nextgen_client.interactions @property @@ -546,6 +554,14 @@ def _nextgen_client(self) -> GeminiNextGenAPIClient: @property def interactions(self) -> NextGenInteractionsResource: + global _interactions_experimental_warned + if not _interactions_experimental_warned: + _interactions_experimental_warned = True + warnings.warn( + 'Interactions usage is experimental and may change in future versions.', + category=UserWarning, + stacklevel=2, + ) return self._nextgen_client.interactions @property diff --git a/google/genai/tests/interactions/test_integration.py b/google/genai/tests/interactions/test_integration.py index c6e94e2f0..13b76f5c0 100644 --- a/google/genai/tests/interactions/test_integration.py +++ b/google/genai/tests/interactions/test_integration.py @@ -19,6 +19,21 @@ pytest_plugins = ("pytest_asyncio",) +def test_client_future_warning(): + with mock.patch.object( + client_lib, "_interactions_experimental_warned", new=False + ): + client = client_lib.Client( + api_key="placeholder", + http_options={ + "api_version": "v1alpha", + } + ) + with pytest.warns( + UserWarning, match="Interactions.*experimental" + ): + _ = client.interactions + def test_client_timeout(): with mock.patch.object(