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/_api_client.py +234 -131
- google/genai/_api_module.py +24 -0
- google/genai/_automatic_function_calling_util.py +43 -22
- google/genai/_common.py +37 -12
- google/genai/_extra_utils.py +25 -19
- google/genai/_replay_api_client.py +47 -35
- google/genai/_test_api_client.py +1 -1
- google/genai/_transformers.py +301 -51
- google/genai/batches.py +204 -165
- google/genai/caches.py +127 -144
- google/genai/chats.py +22 -18
- google/genai/client.py +32 -37
- google/genai/errors.py +1 -1
- google/genai/files.py +333 -165
- google/genai/live.py +16 -6
- google/genai/models.py +601 -283
- google/genai/tunings.py +91 -428
- google/genai/types.py +1190 -955
- google/genai/version.py +1 -1
- google_genai-0.7.0.dist-info/METADATA +1021 -0
- google_genai-0.7.0.dist-info/RECORD +26 -0
- google_genai-0.5.0.dist-info/METADATA +0 -888
- google_genai-0.5.0.dist-info/RECORD +0 -25
- {google_genai-0.5.0.dist-info → google_genai-0.7.0.dist-info}/LICENSE +0 -0
- {google_genai-0.5.0.dist-info → google_genai-0.7.0.dist-info}/WHEEL +0 -0
- {google_genai-0.5.0.dist-info → google_genai-0.7.0.dist-info}/top_level.txt +0 -0
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
|
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(
|
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
|