google-genai 0.5.0__py3-none-any.whl → 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
google/genai/live.py CHANGED
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
 
16
- """Live client."""
16
+ """Live client. The live module is experimental."""
17
17
 
18
18
  import asyncio
19
19
  import base64
@@ -25,6 +25,7 @@ from typing import AsyncIterator, Optional, Sequence, Union
25
25
  import google.auth
26
26
  from websockets import ConnectionClosed
27
27
 
28
+ from . import _api_module
28
29
  from . import _common
29
30
  from . import _transformers as t
30
31
  from . import client
@@ -60,7 +61,7 @@ _FUNCTION_RESPONSE_REQUIRES_ID = (
60
61
 
61
62
 
62
63
  class AsyncSession:
63
- """AsyncSession."""
64
+ """AsyncSession. The live module is experimental."""
64
65
 
65
66
  def __init__(self, api_client: client.ApiClient, websocket: ClientConnection):
66
67
  self._api_client = api_client
@@ -74,7 +75,6 @@ class AsyncSession:
74
75
  types.ContentListUnionDict,
75
76
  types.LiveClientContentOrDict,
76
77
  types.LiveClientRealtimeInputOrDict,
77
- types.LiveClientRealtimeInputOrDict,
78
78
  types.LiveClientToolResponseOrDict,
79
79
  types.FunctionResponseOrDict,
80
80
  Sequence[types.FunctionResponseOrDict],
@@ -108,9 +108,11 @@ class AsyncSession:
108
108
 
109
109
  The method will yield the model responses from the server. The returned
110
110
  responses will represent a complete model turn. When the returned message
111
- is fuction call, user must call `send` with the function response to
111
+ is function call, user must call `send` with the function response to
112
112
  continue the turn.
113
113
 
114
+ The live module is experimental.
115
+
114
116
  Yields:
115
117
  The model responses from the server.
116
118
 
@@ -142,6 +144,8 @@ class AsyncSession:
142
144
  input stream to the model and the other task will be used to receive the
143
145
  responses from the model.
144
146
 
147
+ The live module is experimental.
148
+
145
149
  Args:
146
150
  stream: An iterator that yields the model response.
147
151
  mime_type: The MIME type of the data in the stream.
@@ -380,6 +384,10 @@ class AsyncSession:
380
384
  isinstance(c, dict) and 'name' in c and 'response' in c for c in input
381
385
  ):
382
386
  # ToolResponse.FunctionResponse
387
+ if not (self._api_client.vertexai):
388
+ for item in input:
389
+ if 'id' not in item:
390
+ raise ValueError(_FUNCTION_RESPONSE_REQUIRES_ID)
383
391
  client_message = {'tool_response': {'function_responses': input}}
384
392
  elif isinstance(input, Sequence) and any(isinstance(c, str) for c in input):
385
393
  to_object = {}
@@ -466,8 +474,8 @@ class AsyncSession:
466
474
  await self._ws.close()
467
475
 
468
476
 
469
- class AsyncLive(_common.BaseModule):
470
- """AsyncLive."""
477
+ class AsyncLive(_api_module.BaseModule):
478
+ """AsyncLive. The live module is experimental."""
471
479
 
472
480
  def _LiveSetup_to_mldev(
473
481
  self, model: str, config: Optional[types.LiveConnectConfigOrDict] = None
@@ -634,6 +642,8 @@ class AsyncLive(_common.BaseModule):
634
642
  ) -> AsyncSession:
635
643
  """Connect to the live server.
636
644
 
645
+ The live module is experimental.
646
+
637
647
  Usage:
638
648
 
639
649
  .. code-block:: python