google-genai 1.7.0__py3-none-any.whl → 1.53.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 +4 -2
- google/genai/_adapters.py +55 -0
- google/genai/_api_client.py +1301 -299
- google/genai/_api_module.py +1 -1
- google/genai/_automatic_function_calling_util.py +54 -33
- google/genai/_base_transformers.py +26 -0
- google/genai/_base_url.py +50 -0
- google/genai/_common.py +560 -59
- google/genai/_extra_utils.py +371 -38
- google/genai/_live_converters.py +1467 -0
- google/genai/_local_tokenizer_loader.py +214 -0
- google/genai/_mcp_utils.py +117 -0
- google/genai/_operations_converters.py +394 -0
- google/genai/_replay_api_client.py +204 -92
- google/genai/_test_api_client.py +1 -1
- google/genai/_tokens_converters.py +520 -0
- google/genai/_transformers.py +633 -233
- google/genai/batches.py +1733 -538
- google/genai/caches.py +678 -1012
- google/genai/chats.py +48 -38
- google/genai/client.py +142 -15
- google/genai/documents.py +532 -0
- google/genai/errors.py +141 -35
- google/genai/file_search_stores.py +1296 -0
- google/genai/files.py +312 -744
- google/genai/live.py +617 -367
- google/genai/live_music.py +197 -0
- google/genai/local_tokenizer.py +395 -0
- google/genai/models.py +3598 -3116
- google/genai/operations.py +201 -362
- google/genai/pagers.py +23 -7
- google/genai/py.typed +1 -0
- google/genai/tokens.py +362 -0
- google/genai/tunings.py +1274 -496
- google/genai/types.py +14535 -5454
- google/genai/version.py +2 -2
- {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info}/METADATA +736 -234
- google_genai-1.53.0.dist-info/RECORD +41 -0
- {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info}/WHEEL +1 -1
- google_genai-1.7.0.dist-info/RECORD +0 -27
- {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info/licenses}/LICENSE +0 -0
- {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info}/top_level.txt +0 -0
google/genai/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright 2025 Google LLC
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
|
|
16
16
|
"""Google Gen AI SDK"""
|
|
17
17
|
|
|
18
|
+
from . import types
|
|
19
|
+
from . import version
|
|
18
20
|
from .client import Client
|
|
19
|
-
|
|
21
|
+
|
|
20
22
|
|
|
21
23
|
__version__ = version.__version__
|
|
22
24
|
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
import typing
|
|
17
|
+
|
|
18
|
+
from ._mcp_utils import mcp_to_gemini_tools
|
|
19
|
+
from .types import FunctionCall, Tool
|
|
20
|
+
|
|
21
|
+
if typing.TYPE_CHECKING:
|
|
22
|
+
from mcp import types as mcp_types
|
|
23
|
+
from mcp import ClientSession
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class McpToGenAiToolAdapter:
|
|
27
|
+
"""Adapter for working with MCP tools in a GenAI client."""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
session: "mcp.ClientSession", # type: ignore # noqa: F821
|
|
32
|
+
list_tools_result: "mcp_types.ListToolsResult", # type: ignore
|
|
33
|
+
) -> None:
|
|
34
|
+
self._mcp_session = session
|
|
35
|
+
self._list_tools_result = list_tools_result
|
|
36
|
+
|
|
37
|
+
async def call_tool(
|
|
38
|
+
self, function_call: FunctionCall
|
|
39
|
+
) -> "mcp_types.CallToolResult": # type: ignore
|
|
40
|
+
"""Calls a function on the MCP server."""
|
|
41
|
+
name = function_call.name if function_call.name else ""
|
|
42
|
+
arguments = dict(function_call.args) if function_call.args else {}
|
|
43
|
+
|
|
44
|
+
return typing.cast(
|
|
45
|
+
"mcp_types.CallToolResult",
|
|
46
|
+
await self._mcp_session.call_tool(
|
|
47
|
+
name=name,
|
|
48
|
+
arguments=arguments,
|
|
49
|
+
),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def tools(self) -> list[Tool]:
|
|
54
|
+
"""Returns a list of Google GenAI tools."""
|
|
55
|
+
return mcp_to_gemini_tools(self._list_tools_result.tools)
|