From 97d6fe57959535107f74db06b7a316f1b5bb5d8a Mon Sep 17 00:00:00 2001 From: Ivan Lopez Hernandez Date: Mon, 11 May 2026 18:59:59 -0700 Subject: [PATCH] feat: Introduce Server Side tools deltas PiperOrigin-RevId: 913995290 --- google/genai/_interactions/types/__init__.py | 7 + .../types/code_execution_call_arguments.py | 33 ++++ .../types/google_maps_call_arguments.py | 29 ++++ .../_interactions/types/google_maps_result.py | 65 +++++++ .../types/google_search_call_arguments.py | 29 ++++ .../types/google_search_result.py | 29 ++++ .../genai/_interactions/types/step_delta.py | 164 +++++++++++++++++- .../types/url_context_call_arguments.py | 29 ++++ .../_interactions/types/url_context_result.py | 33 ++++ 9 files changed, 417 insertions(+), 1 deletion(-) create mode 100644 google/genai/_interactions/types/code_execution_call_arguments.py create mode 100644 google/genai/_interactions/types/google_maps_call_arguments.py create mode 100644 google/genai/_interactions/types/google_maps_result.py create mode 100644 google/genai/_interactions/types/google_search_call_arguments.py create mode 100644 google/genai/_interactions/types/google_search_result.py create mode 100644 google/genai/_interactions/types/url_context_call_arguments.py create mode 100644 google/genai/_interactions/types/url_context_result.py diff --git a/google/genai/_interactions/types/__init__.py b/google/genai/_interactions/types/__init__.py index d3e4de38e..1cd5d77a7 100644 --- a/google/genai/_interactions/types/__init__.py +++ b/google/genai/_interactions/types/__init__.py @@ -57,11 +57,13 @@ from .generation_config import GenerationConfig as GenerationConfig from .model_output_step import ModelOutputStep as ModelOutputStep from .function_call_step import FunctionCallStep as FunctionCallStep +from .google_maps_result import GoogleMapsResult as GoogleMapsResult from .image_config_param import ImageConfigParam as ImageConfigParam from .text_content_param import TextContentParam as TextContentParam from .thought_step_param import ThoughtStepParam as ThoughtStepParam from .tool_choice_config import ToolChoiceConfig as ToolChoiceConfig from .url_citation_param import URLCitationParam as URLCitationParam +from .url_context_result import URLContextResult as URLContextResult from .allowed_tools_param import AllowedToolsParam as AllowedToolsParam from .audio_content_param import AudioContentParam as AudioContentParam from .file_citation_param import FileCitationParam as FileCitationParam @@ -72,6 +74,7 @@ from .webhook_ping_params import WebhookPingParams as WebhookPingParams from .dynamic_agent_config import DynamicAgentConfig as DynamicAgentConfig from .function_result_step import FunctionResultStep as FunctionResultStep +from .google_search_result import GoogleSearchResult as GoogleSearchResult from .place_citation_param import PlaceCitationParam as PlaceCitationParam from .text_response_format import TextResponseFormat as TextResponseFormat from .webhook_config_param import WebhookConfigParam as WebhookConfigParam @@ -108,7 +111,9 @@ from .deep_research_agent_config import DeepResearchAgentConfig as DeepResearchAgentConfig from .dynamic_agent_config_param import DynamicAgentConfigParam as DynamicAgentConfigParam from .function_result_step_param import FunctionResultStepParam as FunctionResultStepParam +from .google_maps_call_arguments import GoogleMapsCallArguments as GoogleMapsCallArguments from .text_response_format_param import TextResponseFormatParam as TextResponseFormatParam +from .url_context_call_arguments import URLContextCallArguments as URLContextCallArguments from .audio_response_format_param import AudioResponseFormatParam as AudioResponseFormatParam from .file_search_call_step_param import FileSearchCallStepParam as FileSearchCallStepParam from .google_maps_call_step_param import GoogleMapsCallStepParam as GoogleMapsCallStepParam @@ -117,6 +122,8 @@ from .mcp_server_tool_result_step import MCPServerToolResultStep as MCPServerToolResultStep from .url_context_call_step_param import URLContextCallStepParam as URLContextCallStepParam from .video_response_format_param import VideoResponseFormatParam as VideoResponseFormatParam +from .google_search_call_arguments import GoogleSearchCallArguments as GoogleSearchCallArguments +from .code_execution_call_arguments import CodeExecutionCallArguments as CodeExecutionCallArguments from .file_search_result_step_param import FileSearchResultStepParam as FileSearchResultStepParam from .google_maps_result_step_param import GoogleMapsResultStepParam as GoogleMapsResultStepParam from .google_search_call_step_param import GoogleSearchCallStepParam as GoogleSearchCallStepParam diff --git a/google/genai/_interactions/types/code_execution_call_arguments.py b/google/genai/_interactions/types/code_execution_call_arguments.py new file mode 100644 index 000000000..dce405296 --- /dev/null +++ b/google/genai/_interactions/types/code_execution_call_arguments.py @@ -0,0 +1,33 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["CodeExecutionCallArguments"] + + +class CodeExecutionCallArguments(BaseModel): + """The arguments to pass to the code execution.""" + + code: Optional[str] = None + """The code to be executed.""" + + language: Optional[Literal["python"]] = None + """Programming language of the `code`.""" diff --git a/google/genai/_interactions/types/google_maps_call_arguments.py b/google/genai/_interactions/types/google_maps_call_arguments.py new file mode 100644 index 000000000..3976e8779 --- /dev/null +++ b/google/genai/_interactions/types/google_maps_call_arguments.py @@ -0,0 +1,29 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from .._models import BaseModel + +__all__ = ["GoogleMapsCallArguments"] + + +class GoogleMapsCallArguments(BaseModel): + """The arguments to pass to the Google Maps tool.""" + + queries: Optional[List[str]] = None + """The queries to be executed.""" diff --git a/google/genai/_interactions/types/google_maps_result.py b/google/genai/_interactions/types/google_maps_result.py new file mode 100644 index 000000000..bc2bc528b --- /dev/null +++ b/google/genai/_interactions/types/google_maps_result.py @@ -0,0 +1,65 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from .._models import BaseModel + +__all__ = ["GoogleMapsResult", "Place", "PlaceReviewSnippet"] + + +class PlaceReviewSnippet(BaseModel): + """ + Encapsulates a snippet of a user review that answers a question about + the features of a specific place in Google Maps. + """ + + review_id: Optional[str] = None + """The ID of the review snippet.""" + + title: Optional[str] = None + """Title of the review.""" + + url: Optional[str] = None + """A link that corresponds to the user review on Google Maps.""" + + +class Place(BaseModel): + name: Optional[str] = None + """Title of the place.""" + + place_id: Optional[str] = None + """The ID of the place, in `places/{place_id}` format.""" + + review_snippets: Optional[List[PlaceReviewSnippet]] = None + """ + Snippets of reviews that are used to generate answers about the features of a + given place in Google Maps. + """ + + url: Optional[str] = None + """URI reference of the place.""" + + +class GoogleMapsResult(BaseModel): + """The result of the Google Maps.""" + + places: Optional[List[Place]] = None + """The places that were found.""" + + widget_context_token: Optional[str] = None + """Resource name of the Google Maps widget context token.""" diff --git a/google/genai/_interactions/types/google_search_call_arguments.py b/google/genai/_interactions/types/google_search_call_arguments.py new file mode 100644 index 000000000..9d93e71f2 --- /dev/null +++ b/google/genai/_interactions/types/google_search_call_arguments.py @@ -0,0 +1,29 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from .._models import BaseModel + +__all__ = ["GoogleSearchCallArguments"] + + +class GoogleSearchCallArguments(BaseModel): + """The arguments to pass to Google Search.""" + + queries: Optional[List[str]] = None + """Web search queries for the following-up web search.""" diff --git a/google/genai/_interactions/types/google_search_result.py b/google/genai/_interactions/types/google_search_result.py new file mode 100644 index 000000000..9691f5d40 --- /dev/null +++ b/google/genai/_interactions/types/google_search_result.py @@ -0,0 +1,29 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional + +from .._models import BaseModel + +__all__ = ["GoogleSearchResult"] + + +class GoogleSearchResult(BaseModel): + """The result of the Google Search.""" + + search_suggestions: Optional[str] = None + """Web content snippet that can be embedded in a web page or an app webview.""" diff --git a/google/genai/_interactions/types/step_delta.py b/google/genai/_interactions/types/step_delta.py index 7eee0a8fe..da9fd83f7 100644 --- a/google/genai/_interactions/types/step_delta.py +++ b/google/genai/_interactions/types/step_delta.py @@ -15,7 +15,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from typing_extensions import Literal, Annotated, TypeAlias from .._utils import PropertyInfo @@ -23,6 +23,13 @@ from .annotation import Annotation from .text_content import TextContent from .image_content import ImageContent +from .google_maps_result import GoogleMapsResult +from .url_context_result import URLContextResult +from .google_search_result import GoogleSearchResult +from .google_maps_call_arguments import GoogleMapsCallArguments +from .url_context_call_arguments import URLContextCallArguments +from .google_search_call_arguments import GoogleSearchCallArguments +from .code_execution_call_arguments import CodeExecutionCallArguments __all__ = [ "StepDelta", @@ -37,6 +44,19 @@ "DeltaThoughtSignature", "DeltaTextAnnotationDelta", "DeltaArgumentsDelta", + "DeltaCodeExecutionCall", + "DeltaURLContextCall", + "DeltaGoogleSearchCall", + "DeltaMCPServerToolCall", + "DeltaFileSearchCall", + "DeltaGoogleMapsCall", + "DeltaCodeExecutionResult", + "DeltaURLContextResult", + "DeltaGoogleSearchResult", + "DeltaMCPServerToolResult", + "DeltaMCPServerToolResultResultFunctionResultSubcontentList", + "DeltaFileSearchResult", + "DeltaGoogleMapsResult", ] @@ -162,6 +182,136 @@ class DeltaArgumentsDelta(BaseModel): partial_arguments: Optional[str] = None +class DeltaCodeExecutionCall(BaseModel): + arguments: CodeExecutionCallArguments + """The arguments to pass to the code execution.""" + + type: Literal["code_execution_call"] + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + +class DeltaURLContextCall(BaseModel): + arguments: URLContextCallArguments + """The arguments to pass to the URL context.""" + + type: Literal["url_context_call"] + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + +class DeltaGoogleSearchCall(BaseModel): + arguments: GoogleSearchCallArguments + """The arguments to pass to Google Search.""" + + type: Literal["google_search_call"] + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + +class DeltaMCPServerToolCall(BaseModel): + arguments: Dict[str, object] + + name: str + + server_name: str + + type: Literal["mcp_server_tool_call"] + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + +class DeltaFileSearchCall(BaseModel): + type: Literal["file_search_call"] + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + +class DeltaGoogleMapsCall(BaseModel): + type: Literal["google_maps_call"] + + arguments: Optional[GoogleMapsCallArguments] = None + """The arguments to pass to the Google Maps tool.""" + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + +class DeltaCodeExecutionResult(BaseModel): + result: str + + type: Literal["code_execution_result"] + + is_error: Optional[bool] = None + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + +class DeltaURLContextResult(BaseModel): + result: List[URLContextResult] + + type: Literal["url_context_result"] + + is_error: Optional[bool] = None + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + +class DeltaGoogleSearchResult(BaseModel): + result: List[GoogleSearchResult] + + type: Literal["google_search_result"] + + is_error: Optional[bool] = None + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + +DeltaMCPServerToolResultResultFunctionResultSubcontentList: TypeAlias = Annotated[ + Union[TextContent, ImageContent], PropertyInfo(discriminator="type") +] + + +class DeltaMCPServerToolResult(BaseModel): + result: Union[List[DeltaMCPServerToolResultResultFunctionResultSubcontentList], str, object] + + type: Literal["mcp_server_tool_result"] + + name: Optional[str] = None + + server_name: Optional[str] = None + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + +class DeltaFileSearchResult(BaseModel): + result: List[object] + + type: Literal["file_search_result"] + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + +class DeltaGoogleMapsResult(BaseModel): + type: Literal["google_maps_result"] + + result: Optional[List[GoogleMapsResult]] = None + """The results of the Google Maps.""" + + signature: Optional[str] = None + """A signature hash for backend validation.""" + + Delta: TypeAlias = Annotated[ Union[ DeltaText, @@ -173,6 +323,18 @@ class DeltaArgumentsDelta(BaseModel): DeltaThoughtSignature, DeltaTextAnnotationDelta, DeltaArgumentsDelta, + DeltaCodeExecutionCall, + DeltaURLContextCall, + DeltaGoogleSearchCall, + DeltaMCPServerToolCall, + DeltaFileSearchCall, + DeltaGoogleMapsCall, + DeltaCodeExecutionResult, + DeltaURLContextResult, + DeltaGoogleSearchResult, + DeltaMCPServerToolResult, + DeltaFileSearchResult, + DeltaGoogleMapsResult, ], PropertyInfo(discriminator="type"), ] diff --git a/google/genai/_interactions/types/url_context_call_arguments.py b/google/genai/_interactions/types/url_context_call_arguments.py new file mode 100644 index 000000000..f1a1aca39 --- /dev/null +++ b/google/genai/_interactions/types/url_context_call_arguments.py @@ -0,0 +1,29 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from .._models import BaseModel + +__all__ = ["URLContextCallArguments"] + + +class URLContextCallArguments(BaseModel): + """The arguments to pass to the URL context.""" + + urls: Optional[List[str]] = None + """The URLs to fetch.""" diff --git a/google/genai/_interactions/types/url_context_result.py b/google/genai/_interactions/types/url_context_result.py new file mode 100644 index 000000000..996f43c56 --- /dev/null +++ b/google/genai/_interactions/types/url_context_result.py @@ -0,0 +1,33 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["URLContextResult"] + + +class URLContextResult(BaseModel): + """The result of the URL context.""" + + status: Optional[Literal["success", "error", "paywall", "unsafe"]] = None + """The status of the URL retrieval.""" + + url: Optional[str] = None + """The URL that was fetched."""