google-genai 1.54.0__py3-none-any.whl → 1.56.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/__init__.py +1 -0
- google/genai/_interactions/__init__.py +117 -0
- google/genai/_interactions/_base_client.py +2025 -0
- google/genai/_interactions/_client.py +511 -0
- google/genai/_interactions/_compat.py +234 -0
- google/genai/_interactions/_constants.py +29 -0
- google/genai/_interactions/_exceptions.py +122 -0
- google/genai/_interactions/_files.py +139 -0
- google/genai/_interactions/_models.py +873 -0
- google/genai/_interactions/_qs.py +165 -0
- google/genai/_interactions/_resource.py +58 -0
- google/genai/_interactions/_response.py +847 -0
- google/genai/_interactions/_streaming.py +354 -0
- google/genai/_interactions/_types.py +276 -0
- google/genai/_interactions/_utils/__init__.py +79 -0
- google/genai/_interactions/_utils/_compat.py +61 -0
- google/genai/_interactions/_utils/_datetime_parse.py +151 -0
- google/genai/_interactions/_utils/_logs.py +40 -0
- google/genai/_interactions/_utils/_proxy.py +80 -0
- google/genai/_interactions/_utils/_reflection.py +57 -0
- google/genai/_interactions/_utils/_resources_proxy.py +39 -0
- google/genai/_interactions/_utils/_streams.py +27 -0
- google/genai/_interactions/_utils/_sync.py +73 -0
- google/genai/_interactions/_utils/_transform.py +472 -0
- google/genai/_interactions/_utils/_typing.py +172 -0
- google/genai/_interactions/_utils/_utils.py +437 -0
- google/genai/_interactions/_version.py +18 -0
- google/genai/_interactions/py.typed +0 -0
- google/genai/_interactions/resources/__init__.py +34 -0
- google/genai/_interactions/resources/interactions.py +1350 -0
- google/genai/_interactions/types/__init__.py +109 -0
- google/genai/_interactions/types/allowed_tools.py +33 -0
- google/genai/_interactions/types/allowed_tools_param.py +35 -0
- google/genai/_interactions/types/annotation.py +42 -0
- google/genai/_interactions/types/annotation_param.py +42 -0
- google/genai/_interactions/types/audio_content.py +37 -0
- google/genai/_interactions/types/audio_content_param.py +44 -0
- google/genai/_interactions/types/audio_mime_type.py +25 -0
- google/genai/_interactions/types/audio_mime_type_param.py +27 -0
- google/genai/_interactions/types/code_execution_call_arguments.py +33 -0
- google/genai/_interactions/types/code_execution_call_arguments_param.py +32 -0
- google/genai/_interactions/types/code_execution_call_content.py +36 -0
- google/genai/_interactions/types/code_execution_call_content_param.py +36 -0
- google/genai/_interactions/types/code_execution_result_content.py +41 -0
- google/genai/_interactions/types/code_execution_result_content_param.py +40 -0
- google/genai/_interactions/types/content_delta.py +342 -0
- google/genai/_interactions/types/content_start.py +79 -0
- google/genai/_interactions/types/content_stop.py +35 -0
- google/genai/_interactions/types/deep_research_agent_config.py +32 -0
- google/genai/_interactions/types/deep_research_agent_config_param.py +31 -0
- google/genai/_interactions/types/document_content.py +37 -0
- google/genai/_interactions/types/document_content_param.py +44 -0
- google/genai/_interactions/types/document_mime_type.py +23 -0
- google/genai/_interactions/types/document_mime_type_param.py +25 -0
- google/genai/_interactions/types/dynamic_agent_config.py +43 -0
- google/genai/_interactions/types/dynamic_agent_config_param.py +32 -0
- google/genai/_interactions/types/error_event.py +46 -0
- google/genai/_interactions/types/file_search_result_content.py +45 -0
- google/genai/_interactions/types/file_search_result_content_param.py +45 -0
- google/genai/_interactions/types/function.py +38 -0
- google/genai/_interactions/types/function_call_content.py +38 -0
- google/genai/_interactions/types/function_call_content_param.py +38 -0
- google/genai/_interactions/types/function_param.py +37 -0
- google/genai/_interactions/types/function_result_content.py +51 -0
- google/genai/_interactions/types/function_result_content_param.py +53 -0
- google/genai/_interactions/types/generation_config.py +57 -0
- google/genai/_interactions/types/generation_config_param.py +59 -0
- google/genai/_interactions/types/google_search_call_arguments.py +29 -0
- google/genai/_interactions/types/google_search_call_arguments_param.py +31 -0
- google/genai/_interactions/types/google_search_call_content.py +36 -0
- google/genai/_interactions/types/google_search_call_content_param.py +36 -0
- google/genai/_interactions/types/google_search_result.py +35 -0
- google/genai/_interactions/types/google_search_result_content.py +42 -0
- google/genai/_interactions/types/google_search_result_content_param.py +43 -0
- google/genai/_interactions/types/google_search_result_param.py +35 -0
- google/genai/_interactions/types/image_content.py +40 -0
- google/genai/_interactions/types/image_content_param.py +47 -0
- google/genai/_interactions/types/image_mime_type.py +23 -0
- google/genai/_interactions/types/image_mime_type_param.py +25 -0
- google/genai/_interactions/types/interaction.py +165 -0
- google/genai/_interactions/types/interaction_create_params.py +212 -0
- google/genai/_interactions/types/interaction_event.py +37 -0
- google/genai/_interactions/types/interaction_get_params.py +46 -0
- google/genai/_interactions/types/interaction_sse_event.py +32 -0
- google/genai/_interactions/types/interaction_status_update.py +37 -0
- google/genai/_interactions/types/mcp_server_tool_call_content.py +41 -0
- google/genai/_interactions/types/mcp_server_tool_call_content_param.py +41 -0
- google/genai/_interactions/types/mcp_server_tool_result_content.py +51 -0
- google/genai/_interactions/types/mcp_server_tool_result_content_param.py +53 -0
- google/genai/_interactions/types/model.py +36 -0
- google/genai/_interactions/types/model_param.py +38 -0
- google/genai/_interactions/types/speech_config.py +35 -0
- google/genai/_interactions/types/speech_config_param.py +35 -0
- google/genai/_interactions/types/text_content.py +36 -0
- google/genai/_interactions/types/text_content_param.py +37 -0
- google/genai/_interactions/types/thinking_level.py +22 -0
- google/genai/_interactions/types/thought_content.py +40 -0
- google/genai/_interactions/types/thought_content_param.py +46 -0
- google/genai/_interactions/types/tool.py +100 -0
- google/genai/_interactions/types/tool_choice.py +26 -0
- google/genai/_interactions/types/tool_choice_config.py +28 -0
- google/genai/_interactions/types/tool_choice_config_param.py +29 -0
- google/genai/_interactions/types/tool_choice_param.py +28 -0
- google/genai/_interactions/types/tool_choice_type.py +22 -0
- google/genai/_interactions/types/tool_param.py +97 -0
- google/genai/_interactions/types/turn.py +76 -0
- google/genai/_interactions/types/turn_param.py +73 -0
- google/genai/_interactions/types/url_context_call_arguments.py +29 -0
- google/genai/_interactions/types/url_context_call_arguments_param.py +31 -0
- google/genai/_interactions/types/url_context_call_content.py +36 -0
- google/genai/_interactions/types/url_context_call_content_param.py +36 -0
- google/genai/_interactions/types/url_context_result.py +33 -0
- google/genai/_interactions/types/url_context_result_content.py +42 -0
- google/genai/_interactions/types/url_context_result_content_param.py +43 -0
- google/genai/_interactions/types/url_context_result_param.py +32 -0
- google/genai/_interactions/types/usage.py +106 -0
- google/genai/_interactions/types/usage_param.py +106 -0
- google/genai/_interactions/types/video_content.py +40 -0
- google/genai/_interactions/types/video_content_param.py +47 -0
- google/genai/_interactions/types/video_mime_type.py +36 -0
- google/genai/_interactions/types/video_mime_type_param.py +38 -0
- google/genai/_live_converters.py +33 -30
- google/genai/_tokens_converters.py +5 -0
- google/genai/batches.py +7 -0
- google/genai/client.py +226 -1
- google/genai/interactions.py +17 -0
- google/genai/live.py +4 -3
- google/genai/models.py +14 -29
- google/genai/tunings.py +1 -27
- google/genai/types.py +92 -22
- google/genai/version.py +1 -1
- {google_genai-1.54.0.dist-info → google_genai-1.56.0.dist-info}/METADATA +226 -22
- google_genai-1.56.0.dist-info/RECORD +162 -0
- google_genai-1.54.0.dist-info/RECORD +0 -41
- {google_genai-1.54.0.dist-info → google_genai-1.56.0.dist-info}/WHEEL +0 -0
- {google_genai-1.54.0.dist-info → google_genai-1.56.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.54.0.dist-info → google_genai-1.56.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Copyright 2025 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from typing import Any, List, Tuple, Union, Mapping, TypeVar
|
|
19
|
+
from urllib.parse import parse_qs, urlencode
|
|
20
|
+
from typing_extensions import Literal, get_args
|
|
21
|
+
|
|
22
|
+
from ._types import NotGiven, not_given
|
|
23
|
+
from ._utils import flatten
|
|
24
|
+
|
|
25
|
+
_T = TypeVar("_T")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
ArrayFormat = Literal["comma", "repeat", "indices", "brackets"]
|
|
29
|
+
NestedFormat = Literal["dots", "brackets"]
|
|
30
|
+
|
|
31
|
+
PrimitiveData = Union[str, int, float, bool, None]
|
|
32
|
+
# this should be Data = Union[PrimitiveData, "List[Data]", "Tuple[Data]", "Mapping[str, Data]"]
|
|
33
|
+
# https://github.com/microsoft/pyright/issues/3555
|
|
34
|
+
Data = Union[PrimitiveData, List[Any], Tuple[Any], "Mapping[str, Any]"]
|
|
35
|
+
Params = Mapping[str, Data]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Querystring:
|
|
39
|
+
array_format: ArrayFormat
|
|
40
|
+
nested_format: NestedFormat
|
|
41
|
+
|
|
42
|
+
def __init__(
|
|
43
|
+
self,
|
|
44
|
+
*,
|
|
45
|
+
array_format: ArrayFormat = "repeat",
|
|
46
|
+
nested_format: NestedFormat = "brackets",
|
|
47
|
+
) -> None:
|
|
48
|
+
self.array_format = array_format
|
|
49
|
+
self.nested_format = nested_format
|
|
50
|
+
|
|
51
|
+
def parse(self, query: str) -> Mapping[str, object]:
|
|
52
|
+
# Note: custom format syntax is not supported yet
|
|
53
|
+
return parse_qs(query)
|
|
54
|
+
|
|
55
|
+
def stringify(
|
|
56
|
+
self,
|
|
57
|
+
params: Params,
|
|
58
|
+
*,
|
|
59
|
+
array_format: ArrayFormat | NotGiven = not_given,
|
|
60
|
+
nested_format: NestedFormat | NotGiven = not_given,
|
|
61
|
+
) -> str:
|
|
62
|
+
return urlencode(
|
|
63
|
+
self.stringify_items(
|
|
64
|
+
params,
|
|
65
|
+
array_format=array_format,
|
|
66
|
+
nested_format=nested_format,
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
def stringify_items(
|
|
71
|
+
self,
|
|
72
|
+
params: Params,
|
|
73
|
+
*,
|
|
74
|
+
array_format: ArrayFormat | NotGiven = not_given,
|
|
75
|
+
nested_format: NestedFormat | NotGiven = not_given,
|
|
76
|
+
) -> list[tuple[str, str]]:
|
|
77
|
+
opts = Options(
|
|
78
|
+
qs=self,
|
|
79
|
+
array_format=array_format,
|
|
80
|
+
nested_format=nested_format,
|
|
81
|
+
)
|
|
82
|
+
return flatten([self._stringify_item(key, value, opts) for key, value in params.items()])
|
|
83
|
+
|
|
84
|
+
def _stringify_item(
|
|
85
|
+
self,
|
|
86
|
+
key: str,
|
|
87
|
+
value: Data,
|
|
88
|
+
opts: Options,
|
|
89
|
+
) -> list[tuple[str, str]]:
|
|
90
|
+
if isinstance(value, Mapping):
|
|
91
|
+
items: list[tuple[str, str]] = []
|
|
92
|
+
nested_format = opts.nested_format
|
|
93
|
+
for subkey, subvalue in value.items():
|
|
94
|
+
items.extend(
|
|
95
|
+
self._stringify_item(
|
|
96
|
+
# TODO: error if unknown format
|
|
97
|
+
f"{key}.{subkey}" if nested_format == "dots" else f"{key}[{subkey}]",
|
|
98
|
+
subvalue,
|
|
99
|
+
opts,
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
return items
|
|
103
|
+
|
|
104
|
+
if isinstance(value, (list, tuple)):
|
|
105
|
+
array_format = opts.array_format
|
|
106
|
+
if array_format == "comma":
|
|
107
|
+
return [
|
|
108
|
+
(
|
|
109
|
+
key,
|
|
110
|
+
",".join(self._primitive_value_to_str(item) for item in value if item is not None),
|
|
111
|
+
),
|
|
112
|
+
]
|
|
113
|
+
elif array_format == "repeat":
|
|
114
|
+
items = []
|
|
115
|
+
for item in value:
|
|
116
|
+
items.extend(self._stringify_item(key, item, opts))
|
|
117
|
+
return items
|
|
118
|
+
elif array_format == "indices":
|
|
119
|
+
raise NotImplementedError("The array indices format is not supported yet")
|
|
120
|
+
elif array_format == "brackets":
|
|
121
|
+
items = []
|
|
122
|
+
key = key + "[]"
|
|
123
|
+
for item in value:
|
|
124
|
+
items.extend(self._stringify_item(key, item, opts))
|
|
125
|
+
return items
|
|
126
|
+
else:
|
|
127
|
+
raise NotImplementedError(
|
|
128
|
+
f"Unknown array_format value: {array_format}, choose from {', '.join(get_args(ArrayFormat))}"
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
serialised = self._primitive_value_to_str(value)
|
|
132
|
+
if not serialised:
|
|
133
|
+
return []
|
|
134
|
+
return [(key, serialised)]
|
|
135
|
+
|
|
136
|
+
def _primitive_value_to_str(self, value: PrimitiveData) -> str:
|
|
137
|
+
# copied from httpx
|
|
138
|
+
if value is True:
|
|
139
|
+
return "true"
|
|
140
|
+
elif value is False:
|
|
141
|
+
return "false"
|
|
142
|
+
elif value is None:
|
|
143
|
+
return ""
|
|
144
|
+
return str(value)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
_qs = Querystring()
|
|
148
|
+
parse = _qs.parse
|
|
149
|
+
stringify = _qs.stringify
|
|
150
|
+
stringify_items = _qs.stringify_items
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class Options:
|
|
154
|
+
array_format: ArrayFormat
|
|
155
|
+
nested_format: NestedFormat
|
|
156
|
+
|
|
157
|
+
def __init__(
|
|
158
|
+
self,
|
|
159
|
+
qs: Querystring = _qs,
|
|
160
|
+
*,
|
|
161
|
+
array_format: ArrayFormat | NotGiven = not_given,
|
|
162
|
+
nested_format: NestedFormat | NotGiven = not_given,
|
|
163
|
+
) -> None:
|
|
164
|
+
self.array_format = qs.array_format if isinstance(array_format, NotGiven) else array_format
|
|
165
|
+
self.nested_format = qs.nested_format if isinstance(nested_format, NotGiven) else nested_format
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright 2025 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import time
|
|
21
|
+
from typing import TYPE_CHECKING
|
|
22
|
+
|
|
23
|
+
import anyio
|
|
24
|
+
|
|
25
|
+
if TYPE_CHECKING:
|
|
26
|
+
from ._client import GeminiNextGenAPIClient, AsyncGeminiNextGenAPIClient
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class SyncAPIResource:
|
|
30
|
+
_client: GeminiNextGenAPIClient
|
|
31
|
+
|
|
32
|
+
def __init__(self, client: GeminiNextGenAPIClient) -> None:
|
|
33
|
+
self._client = client
|
|
34
|
+
self._get = client.get
|
|
35
|
+
self._post = client.post
|
|
36
|
+
self._patch = client.patch
|
|
37
|
+
self._put = client.put
|
|
38
|
+
self._delete = client.delete
|
|
39
|
+
self._get_api_list = client.get_api_list
|
|
40
|
+
|
|
41
|
+
def _sleep(self, seconds: float) -> None:
|
|
42
|
+
time.sleep(seconds)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class AsyncAPIResource:
|
|
46
|
+
_client: AsyncGeminiNextGenAPIClient
|
|
47
|
+
|
|
48
|
+
def __init__(self, client: AsyncGeminiNextGenAPIClient) -> None:
|
|
49
|
+
self._client = client
|
|
50
|
+
self._get = client.get
|
|
51
|
+
self._post = client.post
|
|
52
|
+
self._patch = client.patch
|
|
53
|
+
self._put = client.put
|
|
54
|
+
self._delete = client.delete
|
|
55
|
+
self._get_api_list = client.get_api_list
|
|
56
|
+
|
|
57
|
+
async def _sleep(self, seconds: float) -> None:
|
|
58
|
+
await anyio.sleep(seconds)
|