google-genai 1.54.0__py3-none-any.whl → 1.55.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 +2019 -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/resources/__init__.py +34 -0
- google/genai/_interactions/resources/interactions.py +1350 -0
- google/genai/_interactions/types/__init__.py +107 -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 +38 -0
- google/genai/_interactions/types/audio_content_param.py +45 -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 +37 -0
- google/genai/_interactions/types/code_execution_call_content_param.py +37 -0
- google/genai/_interactions/types/code_execution_result_content.py +42 -0
- google/genai/_interactions/types/code_execution_result_content_param.py +41 -0
- google/genai/_interactions/types/content_delta.py +358 -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 +33 -0
- google/genai/_interactions/types/deep_research_agent_config_param.py +32 -0
- google/genai/_interactions/types/document_content.py +36 -0
- google/genai/_interactions/types/document_content_param.py +43 -0
- google/genai/_interactions/types/dynamic_agent_config.py +44 -0
- google/genai/_interactions/types/dynamic_agent_config_param.py +33 -0
- google/genai/_interactions/types/error_event.py +46 -0
- google/genai/_interactions/types/file_search_result_content.py +46 -0
- google/genai/_interactions/types/file_search_result_content_param.py +46 -0
- google/genai/_interactions/types/function.py +38 -0
- google/genai/_interactions/types/function_call_content.py +39 -0
- google/genai/_interactions/types/function_call_content_param.py +39 -0
- google/genai/_interactions/types/function_param.py +37 -0
- google/genai/_interactions/types/function_result_content.py +52 -0
- google/genai/_interactions/types/function_result_content_param.py +54 -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 +37 -0
- google/genai/_interactions/types/google_search_call_content_param.py +37 -0
- google/genai/_interactions/types/google_search_result.py +35 -0
- google/genai/_interactions/types/google_search_result_content.py +43 -0
- google/genai/_interactions/types/google_search_result_content_param.py +44 -0
- google/genai/_interactions/types/google_search_result_param.py +35 -0
- google/genai/_interactions/types/image_content.py +41 -0
- google/genai/_interactions/types/image_content_param.py +48 -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 +42 -0
- google/genai/_interactions/types/mcp_server_tool_call_content_param.py +42 -0
- google/genai/_interactions/types/mcp_server_tool_result_content.py +52 -0
- google/genai/_interactions/types/mcp_server_tool_result_content_param.py +54 -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 +37 -0
- google/genai/_interactions/types/text_content_param.py +38 -0
- google/genai/_interactions/types/thinking_level.py +22 -0
- google/genai/_interactions/types/thought_content.py +41 -0
- google/genai/_interactions/types/thought_content_param.py +47 -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 +37 -0
- google/genai/_interactions/types/url_context_call_content_param.py +37 -0
- google/genai/_interactions/types/url_context_result.py +33 -0
- google/genai/_interactions/types/url_context_result_content.py +43 -0
- google/genai/_interactions/types/url_context_result_content_param.py +44 -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 +41 -0
- google/genai/_interactions/types/video_content_param.py +48 -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 +31 -0
- google/genai/_tokens_converters.py +5 -0
- google/genai/batches.py +7 -0
- google/genai/client.py +223 -0
- google/genai/interactions.py +17 -0
- google/genai/live.py +4 -3
- google/genai/models.py +12 -0
- google/genai/tests/__init__.py +21 -0
- google/genai/tests/afc/__init__.py +21 -0
- google/genai/tests/afc/test_convert_if_exist_pydantic_model.py +309 -0
- google/genai/tests/afc/test_convert_number_values_for_function_call_args.py +63 -0
- google/genai/tests/afc/test_find_afc_incompatible_tool_indexes.py +240 -0
- google/genai/tests/afc/test_generate_content_stream_afc.py +530 -0
- google/genai/tests/afc/test_generate_content_stream_afc_thoughts.py +77 -0
- google/genai/tests/afc/test_get_function_map.py +176 -0
- google/genai/tests/afc/test_get_function_response_parts.py +277 -0
- google/genai/tests/afc/test_get_max_remote_calls_for_afc.py +130 -0
- google/genai/tests/afc/test_invoke_function_from_dict_args.py +241 -0
- google/genai/tests/afc/test_raise_error_for_afc_incompatible_config.py +159 -0
- google/genai/tests/afc/test_should_append_afc_history.py +53 -0
- google/genai/tests/afc/test_should_disable_afc.py +214 -0
- google/genai/tests/batches/__init__.py +17 -0
- google/genai/tests/batches/test_cancel.py +77 -0
- google/genai/tests/batches/test_create.py +78 -0
- google/genai/tests/batches/test_create_with_bigquery.py +113 -0
- google/genai/tests/batches/test_create_with_file.py +82 -0
- google/genai/tests/batches/test_create_with_gcs.py +125 -0
- google/genai/tests/batches/test_create_with_inlined_requests.py +255 -0
- google/genai/tests/batches/test_delete.py +86 -0
- google/genai/tests/batches/test_embedding.py +157 -0
- google/genai/tests/batches/test_get.py +78 -0
- google/genai/tests/batches/test_list.py +79 -0
- google/genai/tests/caches/__init__.py +17 -0
- google/genai/tests/caches/constants.py +29 -0
- google/genai/tests/caches/test_create.py +210 -0
- google/genai/tests/caches/test_create_custom_url.py +105 -0
- google/genai/tests/caches/test_delete.py +54 -0
- google/genai/tests/caches/test_delete_custom_url.py +52 -0
- google/genai/tests/caches/test_get.py +94 -0
- google/genai/tests/caches/test_get_custom_url.py +52 -0
- google/genai/tests/caches/test_list.py +68 -0
- google/genai/tests/caches/test_update.py +70 -0
- google/genai/tests/caches/test_update_custom_url.py +58 -0
- google/genai/tests/chats/__init__.py +1 -0
- google/genai/tests/chats/test_get_history.py +597 -0
- google/genai/tests/chats/test_send_message.py +844 -0
- google/genai/tests/chats/test_validate_response.py +90 -0
- google/genai/tests/client/__init__.py +17 -0
- google/genai/tests/client/test_async_stream.py +427 -0
- google/genai/tests/client/test_client_close.py +197 -0
- google/genai/tests/client/test_client_initialization.py +1687 -0
- google/genai/tests/client/test_client_requests.py +355 -0
- google/genai/tests/client/test_custom_client.py +77 -0
- google/genai/tests/client/test_http_options.py +178 -0
- google/genai/tests/client/test_replay_client_equality.py +168 -0
- google/genai/tests/client/test_retries.py +846 -0
- google/genai/tests/client/test_upload_errors.py +136 -0
- google/genai/tests/common/__init__.py +17 -0
- google/genai/tests/common/test_common.py +954 -0
- google/genai/tests/conftest.py +162 -0
- google/genai/tests/documents/__init__.py +17 -0
- google/genai/tests/documents/test_delete.py +51 -0
- google/genai/tests/documents/test_get.py +85 -0
- google/genai/tests/documents/test_list.py +72 -0
- google/genai/tests/errors/__init__.py +1 -0
- google/genai/tests/errors/test_api_error.py +417 -0
- google/genai/tests/file_search_stores/__init__.py +17 -0
- google/genai/tests/file_search_stores/test_create.py +66 -0
- google/genai/tests/file_search_stores/test_delete.py +64 -0
- google/genai/tests/file_search_stores/test_get.py +94 -0
- google/genai/tests/file_search_stores/test_import_file.py +112 -0
- google/genai/tests/file_search_stores/test_list.py +57 -0
- google/genai/tests/file_search_stores/test_upload_to_file_search_store.py +141 -0
- google/genai/tests/files/__init__.py +17 -0
- google/genai/tests/files/test_delete.py +46 -0
- google/genai/tests/files/test_download.py +85 -0
- google/genai/tests/files/test_get.py +46 -0
- google/genai/tests/files/test_list.py +72 -0
- google/genai/tests/files/test_upload.py +255 -0
- google/genai/tests/imports/test_no_optional_imports.py +28 -0
- google/genai/tests/interactions/__init__.py +0 -0
- google/genai/tests/interactions/test_integration.py +80 -0
- google/genai/tests/live/__init__.py +16 -0
- google/genai/tests/live/test_live.py +2177 -0
- google/genai/tests/live/test_live_music.py +362 -0
- google/genai/tests/live/test_live_response.py +163 -0
- google/genai/tests/live/test_send_client_content.py +147 -0
- google/genai/tests/live/test_send_realtime_input.py +268 -0
- google/genai/tests/live/test_send_tool_response.py +222 -0
- google/genai/tests/local_tokenizer/__init__.py +17 -0
- google/genai/tests/local_tokenizer/test_local_tokenizer.py +343 -0
- google/genai/tests/local_tokenizer/test_local_tokenizer_loader.py +235 -0
- google/genai/tests/mcp/__init__.py +17 -0
- google/genai/tests/mcp/test_has_mcp_tool_usage.py +89 -0
- google/genai/tests/mcp/test_mcp_to_gemini_tools.py +191 -0
- google/genai/tests/mcp/test_parse_config_for_mcp_sessions.py +201 -0
- google/genai/tests/mcp/test_parse_config_for_mcp_usage.py +130 -0
- google/genai/tests/mcp/test_set_mcp_usage_header.py +72 -0
- google/genai/tests/models/__init__.py +17 -0
- google/genai/tests/models/constants.py +8 -0
- google/genai/tests/models/test_compute_tokens.py +120 -0
- google/genai/tests/models/test_count_tokens.py +159 -0
- google/genai/tests/models/test_delete.py +107 -0
- google/genai/tests/models/test_edit_image.py +264 -0
- google/genai/tests/models/test_embed_content.py +94 -0
- google/genai/tests/models/test_function_call_streaming.py +442 -0
- google/genai/tests/models/test_generate_content.py +2502 -0
- google/genai/tests/models/test_generate_content_cached_content.py +132 -0
- google/genai/tests/models/test_generate_content_config_zero_value.py +103 -0
- google/genai/tests/models/test_generate_content_from_apikey.py +44 -0
- google/genai/tests/models/test_generate_content_http_options.py +40 -0
- google/genai/tests/models/test_generate_content_image_generation.py +143 -0
- google/genai/tests/models/test_generate_content_mcp.py +343 -0
- google/genai/tests/models/test_generate_content_media_resolution.py +97 -0
- google/genai/tests/models/test_generate_content_model.py +139 -0
- google/genai/tests/models/test_generate_content_part.py +821 -0
- google/genai/tests/models/test_generate_content_thought.py +76 -0
- google/genai/tests/models/test_generate_content_tools.py +1761 -0
- google/genai/tests/models/test_generate_images.py +191 -0
- google/genai/tests/models/test_generate_videos.py +759 -0
- google/genai/tests/models/test_get.py +104 -0
- google/genai/tests/models/test_list.py +233 -0
- google/genai/tests/models/test_recontext_image.py +189 -0
- google/genai/tests/models/test_segment_image.py +148 -0
- google/genai/tests/models/test_update.py +95 -0
- google/genai/tests/models/test_upscale_image.py +157 -0
- google/genai/tests/operations/__init__.py +17 -0
- google/genai/tests/operations/test_get.py +38 -0
- google/genai/tests/public_samples/__init__.py +17 -0
- google/genai/tests/public_samples/test_gemini_text_only.py +34 -0
- google/genai/tests/pytest_helper.py +229 -0
- google/genai/tests/shared/__init__.py +16 -0
- google/genai/tests/shared/batches/__init__.py +14 -0
- google/genai/tests/shared/batches/test_create_delete.py +57 -0
- google/genai/tests/shared/batches/test_create_get_cancel.py +56 -0
- google/genai/tests/shared/batches/test_list.py +40 -0
- google/genai/tests/shared/caches/__init__.py +14 -0
- google/genai/tests/shared/caches/test_create_get_delete.py +67 -0
- google/genai/tests/shared/caches/test_create_update_get.py +71 -0
- google/genai/tests/shared/caches/test_list.py +40 -0
- google/genai/tests/shared/chats/__init__.py +14 -0
- google/genai/tests/shared/chats/test_send_message.py +48 -0
- google/genai/tests/shared/chats/test_send_message_stream.py +50 -0
- google/genai/tests/shared/files/__init__.py +14 -0
- google/genai/tests/shared/files/test_list.py +41 -0
- google/genai/tests/shared/files/test_upload_get_delete.py +54 -0
- google/genai/tests/shared/models/__init__.py +14 -0
- google/genai/tests/shared/models/test_compute_tokens.py +41 -0
- google/genai/tests/shared/models/test_count_tokens.py +40 -0
- google/genai/tests/shared/models/test_edit_image.py +67 -0
- google/genai/tests/shared/models/test_embed.py +40 -0
- google/genai/tests/shared/models/test_generate_content.py +39 -0
- google/genai/tests/shared/models/test_generate_content_stream.py +54 -0
- google/genai/tests/shared/models/test_generate_images.py +40 -0
- google/genai/tests/shared/models/test_generate_videos.py +38 -0
- google/genai/tests/shared/models/test_list.py +37 -0
- google/genai/tests/shared/models/test_recontext_image.py +55 -0
- google/genai/tests/shared/models/test_segment_image.py +52 -0
- google/genai/tests/shared/models/test_upscale_image.py +52 -0
- google/genai/tests/shared/tunings/__init__.py +16 -0
- google/genai/tests/shared/tunings/test_create.py +46 -0
- google/genai/tests/shared/tunings/test_create_get_cancel.py +56 -0
- google/genai/tests/shared/tunings/test_list.py +39 -0
- google/genai/tests/tokens/__init__.py +16 -0
- google/genai/tests/tokens/test_create.py +154 -0
- google/genai/tests/transformers/__init__.py +17 -0
- google/genai/tests/transformers/test_blobs.py +71 -0
- google/genai/tests/transformers/test_bytes.py +15 -0
- google/genai/tests/transformers/test_duck_type.py +96 -0
- google/genai/tests/transformers/test_function_responses.py +72 -0
- google/genai/tests/transformers/test_schema.py +653 -0
- google/genai/tests/transformers/test_t_batch.py +286 -0
- google/genai/tests/transformers/test_t_content.py +160 -0
- google/genai/tests/transformers/test_t_contents.py +398 -0
- google/genai/tests/transformers/test_t_part.py +85 -0
- google/genai/tests/transformers/test_t_parts.py +87 -0
- google/genai/tests/transformers/test_t_tool.py +157 -0
- google/genai/tests/transformers/test_t_tools.py +195 -0
- google/genai/tests/tunings/__init__.py +16 -0
- google/genai/tests/tunings/test_cancel.py +39 -0
- google/genai/tests/tunings/test_end_to_end.py +106 -0
- google/genai/tests/tunings/test_get.py +67 -0
- google/genai/tests/tunings/test_list.py +75 -0
- google/genai/tests/tunings/test_tune.py +268 -0
- google/genai/tests/types/__init__.py +16 -0
- google/genai/tests/types/test_bytes_internal.py +271 -0
- google/genai/tests/types/test_bytes_type.py +152 -0
- google/genai/tests/types/test_future.py +101 -0
- google/genai/tests/types/test_optional_types.py +36 -0
- google/genai/tests/types/test_part_type.py +616 -0
- google/genai/tests/types/test_schema_from_json_schema.py +417 -0
- google/genai/tests/types/test_schema_json_schema.py +468 -0
- google/genai/tests/types/test_types.py +2903 -0
- google/genai/types.py +72 -0
- google/genai/version.py +1 -1
- {google_genai-1.54.0.dist-info → google_genai-1.55.0.dist-info}/METADATA +3 -1
- google_genai-1.55.0.dist-info/RECORD +345 -0
- google_genai-1.54.0.dist-info/RECORD +0 -41
- {google_genai-1.54.0.dist-info → google_genai-1.55.0.dist-info}/WHEEL +0 -0
- {google_genai-1.54.0.dist-info → google_genai-1.55.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.54.0.dist-info → google_genai-1.55.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,1350 @@
|
|
|
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
|
+
from typing import List, Union, Iterable
|
|
21
|
+
from typing_extensions import Literal, overload
|
|
22
|
+
|
|
23
|
+
import httpx
|
|
24
|
+
|
|
25
|
+
from ..types import interaction_get_params, interaction_create_params
|
|
26
|
+
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
27
|
+
from .._utils import required_args, maybe_transform, async_maybe_transform
|
|
28
|
+
from .._compat import cached_property
|
|
29
|
+
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
30
|
+
from .._response import (
|
|
31
|
+
to_raw_response_wrapper,
|
|
32
|
+
to_streamed_response_wrapper,
|
|
33
|
+
async_to_raw_response_wrapper,
|
|
34
|
+
async_to_streamed_response_wrapper,
|
|
35
|
+
)
|
|
36
|
+
from .._streaming import Stream, AsyncStream
|
|
37
|
+
from .._base_client import make_request_options
|
|
38
|
+
from ..types.tool_param import ToolParam
|
|
39
|
+
from ..types.interaction import Interaction
|
|
40
|
+
from ..types.model_param import ModelParam
|
|
41
|
+
from ..types.interaction_sse_event import InteractionSSEEvent
|
|
42
|
+
from ..types.generation_config_param import GenerationConfigParam
|
|
43
|
+
|
|
44
|
+
__all__ = ["InteractionsResource", "AsyncInteractionsResource"]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class InteractionsResource(SyncAPIResource):
|
|
48
|
+
@cached_property
|
|
49
|
+
def with_raw_response(self) -> InteractionsResourceWithRawResponse:
|
|
50
|
+
"""
|
|
51
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
52
|
+
the raw response object instead of the parsed content.
|
|
53
|
+
|
|
54
|
+
For more information, see https://www.github.com/stainless-sdks/gemini-next-gen-api-python#accessing-raw-response-data-eg-headers
|
|
55
|
+
"""
|
|
56
|
+
return InteractionsResourceWithRawResponse(self)
|
|
57
|
+
|
|
58
|
+
@cached_property
|
|
59
|
+
def with_streaming_response(self) -> InteractionsResourceWithStreamingResponse:
|
|
60
|
+
"""
|
|
61
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
62
|
+
|
|
63
|
+
For more information, see https://www.github.com/stainless-sdks/gemini-next-gen-api-python#with_streaming_response
|
|
64
|
+
"""
|
|
65
|
+
return InteractionsResourceWithStreamingResponse(self)
|
|
66
|
+
|
|
67
|
+
@overload
|
|
68
|
+
def create(
|
|
69
|
+
self,
|
|
70
|
+
*,
|
|
71
|
+
input: interaction_create_params.Input,
|
|
72
|
+
model: ModelParam,
|
|
73
|
+
api_version: str | None = None,
|
|
74
|
+
background: bool | Omit = omit,
|
|
75
|
+
generation_config: GenerationConfigParam | Omit = omit,
|
|
76
|
+
previous_interaction_id: str | Omit = omit,
|
|
77
|
+
response_format: object | Omit = omit,
|
|
78
|
+
response_mime_type: str | Omit = omit,
|
|
79
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
80
|
+
store: bool | Omit = omit,
|
|
81
|
+
stream: Literal[False] | Omit = omit,
|
|
82
|
+
system_instruction: str | Omit = omit,
|
|
83
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
84
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
85
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
86
|
+
extra_headers: Headers | None = None,
|
|
87
|
+
extra_query: Query | None = None,
|
|
88
|
+
extra_body: Body | None = None,
|
|
89
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
90
|
+
) -> Interaction:
|
|
91
|
+
"""
|
|
92
|
+
Creates a new interaction.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
input: The inputs for the interaction.
|
|
96
|
+
|
|
97
|
+
model: The name of the `Model` used for generating the interaction.
|
|
98
|
+
|
|
99
|
+
background: Whether to run the model interaction in the background.
|
|
100
|
+
|
|
101
|
+
generation_config: Input only. Configuration parameters for the model interaction.
|
|
102
|
+
|
|
103
|
+
previous_interaction_id: The ID of the previous interaction, if any.
|
|
104
|
+
|
|
105
|
+
response_format: Enforces that the generated response is a JSON object that complies with
|
|
106
|
+
the JSON schema specified in this field.
|
|
107
|
+
|
|
108
|
+
response_mime_type: The mime type of the response. This is required if response_format is set.
|
|
109
|
+
|
|
110
|
+
response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
|
|
111
|
+
|
|
112
|
+
store: Input only. Whether to store the response and request for later retrieval.
|
|
113
|
+
|
|
114
|
+
stream: Input only. Whether the interaction will be streamed.
|
|
115
|
+
|
|
116
|
+
system_instruction: System instruction for the interaction.
|
|
117
|
+
|
|
118
|
+
tools: A list of tool declarations the model may call during interaction.
|
|
119
|
+
|
|
120
|
+
extra_headers: Send extra headers
|
|
121
|
+
|
|
122
|
+
extra_query: Add additional query parameters to the request
|
|
123
|
+
|
|
124
|
+
extra_body: Add additional JSON properties to the request
|
|
125
|
+
|
|
126
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
127
|
+
"""
|
|
128
|
+
...
|
|
129
|
+
|
|
130
|
+
@overload
|
|
131
|
+
def create(
|
|
132
|
+
self,
|
|
133
|
+
*,
|
|
134
|
+
input: interaction_create_params.Input,
|
|
135
|
+
model: ModelParam,
|
|
136
|
+
stream: Literal[True],
|
|
137
|
+
api_version: str | None = None,
|
|
138
|
+
background: bool | Omit = omit,
|
|
139
|
+
generation_config: GenerationConfigParam | Omit = omit,
|
|
140
|
+
previous_interaction_id: str | Omit = omit,
|
|
141
|
+
response_format: object | Omit = omit,
|
|
142
|
+
response_mime_type: str | Omit = omit,
|
|
143
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
144
|
+
store: bool | Omit = omit,
|
|
145
|
+
system_instruction: str | Omit = omit,
|
|
146
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
147
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
148
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
149
|
+
extra_headers: Headers | None = None,
|
|
150
|
+
extra_query: Query | None = None,
|
|
151
|
+
extra_body: Body | None = None,
|
|
152
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
153
|
+
) -> Stream[InteractionSSEEvent]:
|
|
154
|
+
"""
|
|
155
|
+
Creates a new interaction.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
input: The inputs for the interaction.
|
|
159
|
+
|
|
160
|
+
model: The name of the `Model` used for generating the interaction.
|
|
161
|
+
|
|
162
|
+
stream: Input only. Whether the interaction will be streamed.
|
|
163
|
+
|
|
164
|
+
background: Whether to run the model interaction in the background.
|
|
165
|
+
|
|
166
|
+
generation_config: Input only. Configuration parameters for the model interaction.
|
|
167
|
+
|
|
168
|
+
previous_interaction_id: The ID of the previous interaction, if any.
|
|
169
|
+
|
|
170
|
+
response_format: Enforces that the generated response is a JSON object that complies with
|
|
171
|
+
the JSON schema specified in this field.
|
|
172
|
+
|
|
173
|
+
response_mime_type: The mime type of the response. This is required if response_format is set.
|
|
174
|
+
|
|
175
|
+
response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
|
|
176
|
+
|
|
177
|
+
store: Input only. Whether to store the response and request for later retrieval.
|
|
178
|
+
|
|
179
|
+
system_instruction: System instruction for the interaction.
|
|
180
|
+
|
|
181
|
+
tools: A list of tool declarations the model may call during interaction.
|
|
182
|
+
|
|
183
|
+
extra_headers: Send extra headers
|
|
184
|
+
|
|
185
|
+
extra_query: Add additional query parameters to the request
|
|
186
|
+
|
|
187
|
+
extra_body: Add additional JSON properties to the request
|
|
188
|
+
|
|
189
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
190
|
+
"""
|
|
191
|
+
...
|
|
192
|
+
|
|
193
|
+
@overload
|
|
194
|
+
def create(
|
|
195
|
+
self,
|
|
196
|
+
*,
|
|
197
|
+
agent: Union[str, Literal["deep-research-pro-preview-12-2025"]],
|
|
198
|
+
input: interaction_create_params.Input,
|
|
199
|
+
api_version: str | None = None,
|
|
200
|
+
agent_config: interaction_create_params.AgentConfig | Omit = omit,
|
|
201
|
+
background: bool | Omit = omit,
|
|
202
|
+
previous_interaction_id: str | Omit = omit,
|
|
203
|
+
response_format: object | Omit = omit,
|
|
204
|
+
response_mime_type: str | Omit = omit,
|
|
205
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
206
|
+
store: bool | Omit = omit,
|
|
207
|
+
stream: Literal[False] | Omit = omit,
|
|
208
|
+
system_instruction: str | Omit = omit,
|
|
209
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
210
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
211
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
212
|
+
extra_headers: Headers | None = None,
|
|
213
|
+
extra_query: Query | None = None,
|
|
214
|
+
extra_body: Body | None = None,
|
|
215
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
216
|
+
) -> Interaction:
|
|
217
|
+
"""
|
|
218
|
+
Creates a new interaction.
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
agent: The name of the `Agent` used for generating the interaction.
|
|
222
|
+
|
|
223
|
+
input: The inputs for the interaction.
|
|
224
|
+
|
|
225
|
+
agent_config: Configuration for the agent.
|
|
226
|
+
|
|
227
|
+
background: Whether to run the model interaction in the background.
|
|
228
|
+
|
|
229
|
+
previous_interaction_id: The ID of the previous interaction, if any.
|
|
230
|
+
|
|
231
|
+
response_format: Enforces that the generated response is a JSON object that complies with
|
|
232
|
+
the JSON schema specified in this field.
|
|
233
|
+
|
|
234
|
+
response_mime_type: The mime type of the response. This is required if response_format is set.
|
|
235
|
+
|
|
236
|
+
response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
|
|
237
|
+
|
|
238
|
+
store: Input only. Whether to store the response and request for later retrieval.
|
|
239
|
+
|
|
240
|
+
stream: Input only. Whether the interaction will be streamed.
|
|
241
|
+
|
|
242
|
+
system_instruction: System instruction for the interaction.
|
|
243
|
+
|
|
244
|
+
tools: A list of tool declarations the model may call during interaction.
|
|
245
|
+
|
|
246
|
+
extra_headers: Send extra headers
|
|
247
|
+
|
|
248
|
+
extra_query: Add additional query parameters to the request
|
|
249
|
+
|
|
250
|
+
extra_body: Add additional JSON properties to the request
|
|
251
|
+
|
|
252
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
253
|
+
"""
|
|
254
|
+
...
|
|
255
|
+
|
|
256
|
+
@overload
|
|
257
|
+
def create(
|
|
258
|
+
self,
|
|
259
|
+
*,
|
|
260
|
+
agent: Union[str, Literal["deep-research-pro-preview-12-2025"]],
|
|
261
|
+
input: interaction_create_params.Input,
|
|
262
|
+
stream: Literal[True],
|
|
263
|
+
api_version: str | None = None,
|
|
264
|
+
agent_config: interaction_create_params.AgentConfig | Omit = omit,
|
|
265
|
+
background: bool | Omit = omit,
|
|
266
|
+
previous_interaction_id: str | Omit = omit,
|
|
267
|
+
response_format: object | Omit = omit,
|
|
268
|
+
response_mime_type: str | Omit = omit,
|
|
269
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
270
|
+
store: bool | Omit = omit,
|
|
271
|
+
system_instruction: str | Omit = omit,
|
|
272
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
273
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
274
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
275
|
+
extra_headers: Headers | None = None,
|
|
276
|
+
extra_query: Query | None = None,
|
|
277
|
+
extra_body: Body | None = None,
|
|
278
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
279
|
+
) -> Stream[InteractionSSEEvent]:
|
|
280
|
+
"""
|
|
281
|
+
Creates a new interaction.
|
|
282
|
+
|
|
283
|
+
Args:
|
|
284
|
+
agent: The name of the `Agent` used for generating the interaction.
|
|
285
|
+
|
|
286
|
+
input: The inputs for the interaction.
|
|
287
|
+
|
|
288
|
+
stream: Input only. Whether the interaction will be streamed.
|
|
289
|
+
|
|
290
|
+
agent_config: Configuration for the agent.
|
|
291
|
+
|
|
292
|
+
background: Whether to run the model interaction in the background.
|
|
293
|
+
|
|
294
|
+
previous_interaction_id: The ID of the previous interaction, if any.
|
|
295
|
+
|
|
296
|
+
response_format: Enforces that the generated response is a JSON object that complies with
|
|
297
|
+
the JSON schema specified in this field.
|
|
298
|
+
|
|
299
|
+
response_mime_type: The mime type of the response. This is required if response_format is set.
|
|
300
|
+
|
|
301
|
+
response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
|
|
302
|
+
|
|
303
|
+
store: Input only. Whether to store the response and request for later retrieval.
|
|
304
|
+
|
|
305
|
+
system_instruction: System instruction for the interaction.
|
|
306
|
+
|
|
307
|
+
tools: A list of tool declarations the model may call during interaction.
|
|
308
|
+
|
|
309
|
+
extra_headers: Send extra headers
|
|
310
|
+
|
|
311
|
+
extra_query: Add additional query parameters to the request
|
|
312
|
+
|
|
313
|
+
extra_body: Add additional JSON properties to the request
|
|
314
|
+
|
|
315
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
316
|
+
"""
|
|
317
|
+
...
|
|
318
|
+
|
|
319
|
+
@overload
|
|
320
|
+
def create(
|
|
321
|
+
self,
|
|
322
|
+
*,
|
|
323
|
+
input: interaction_create_params.Input,
|
|
324
|
+
model: ModelParam,
|
|
325
|
+
stream: bool,
|
|
326
|
+
api_version: str | None = None,
|
|
327
|
+
background: bool | Omit = omit,
|
|
328
|
+
generation_config: GenerationConfigParam | Omit = omit,
|
|
329
|
+
previous_interaction_id: str | Omit = omit,
|
|
330
|
+
response_format: object | Omit = omit,
|
|
331
|
+
response_mime_type: str | Omit = omit,
|
|
332
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
333
|
+
store: bool | Omit = omit,
|
|
334
|
+
system_instruction: str | Omit = omit,
|
|
335
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
336
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
337
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
338
|
+
extra_headers: Headers | None = None,
|
|
339
|
+
extra_query: Query | None = None,
|
|
340
|
+
extra_body: Body | None = None,
|
|
341
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
342
|
+
) -> Interaction | Stream[InteractionSSEEvent]:
|
|
343
|
+
"""
|
|
344
|
+
Creates a new interaction.
|
|
345
|
+
|
|
346
|
+
Args:
|
|
347
|
+
input: The inputs for the interaction.
|
|
348
|
+
|
|
349
|
+
model: The name of the `Model` used for generating the interaction.
|
|
350
|
+
|
|
351
|
+
stream: Input only. Whether the interaction will be streamed.
|
|
352
|
+
|
|
353
|
+
background: Whether to run the model interaction in the background.
|
|
354
|
+
|
|
355
|
+
generation_config: Input only. Configuration parameters for the model interaction.
|
|
356
|
+
|
|
357
|
+
previous_interaction_id: The ID of the previous interaction, if any.
|
|
358
|
+
|
|
359
|
+
response_format: Enforces that the generated response is a JSON object that complies with
|
|
360
|
+
the JSON schema specified in this field.
|
|
361
|
+
|
|
362
|
+
response_mime_type: The mime type of the response. This is required if response_format is set.
|
|
363
|
+
|
|
364
|
+
response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
|
|
365
|
+
|
|
366
|
+
store: Input only. Whether to store the response and request for later retrieval.
|
|
367
|
+
|
|
368
|
+
system_instruction: System instruction for the interaction.
|
|
369
|
+
|
|
370
|
+
tools: A list of tool declarations the model may call during interaction.
|
|
371
|
+
|
|
372
|
+
extra_headers: Send extra headers
|
|
373
|
+
|
|
374
|
+
extra_query: Add additional query parameters to the request
|
|
375
|
+
|
|
376
|
+
extra_body: Add additional JSON properties to the request
|
|
377
|
+
|
|
378
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
379
|
+
"""
|
|
380
|
+
...
|
|
381
|
+
|
|
382
|
+
@required_args(["input", "model"], ["input", "model", "stream"], ["agent", "input"], ["agent", "input", "stream"])
|
|
383
|
+
def create(
|
|
384
|
+
self,
|
|
385
|
+
*,
|
|
386
|
+
input: interaction_create_params.Input,
|
|
387
|
+
model: ModelParam | Omit = omit,
|
|
388
|
+
api_version: str | None = None,
|
|
389
|
+
background: bool | Omit = omit,
|
|
390
|
+
generation_config: GenerationConfigParam | Omit = omit,
|
|
391
|
+
previous_interaction_id: str | Omit = omit,
|
|
392
|
+
response_format: object | Omit = omit,
|
|
393
|
+
response_mime_type: str | Omit = omit,
|
|
394
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
395
|
+
store: bool | Omit = omit,
|
|
396
|
+
stream: Literal[False] | Literal[True] | Omit = omit,
|
|
397
|
+
system_instruction: str | Omit = omit,
|
|
398
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
399
|
+
agent: Union[str, Literal["deep-research-pro-preview-12-2025"]] | Omit = omit,
|
|
400
|
+
agent_config: interaction_create_params.AgentConfig | Omit = omit,
|
|
401
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
402
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
403
|
+
extra_headers: Headers | None = None,
|
|
404
|
+
extra_query: Query | None = None,
|
|
405
|
+
extra_body: Body | None = None,
|
|
406
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
407
|
+
) -> Interaction | Stream[InteractionSSEEvent]:
|
|
408
|
+
if api_version is None:
|
|
409
|
+
api_version = self._client._get_api_version_path_param()
|
|
410
|
+
if not api_version:
|
|
411
|
+
raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
|
|
412
|
+
if model is not omit and agent_config is not omit:
|
|
413
|
+
raise ValueError("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.")
|
|
414
|
+
if agent is not omit and generation_config is not omit:
|
|
415
|
+
raise ValueError("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.")
|
|
416
|
+
return self._post(
|
|
417
|
+
self._client._build_maybe_vertex_path(api_version=api_version, path='interactions'),
|
|
418
|
+
body=maybe_transform(
|
|
419
|
+
{
|
|
420
|
+
"input": input,
|
|
421
|
+
"model": model,
|
|
422
|
+
"background": background,
|
|
423
|
+
"generation_config": generation_config,
|
|
424
|
+
"previous_interaction_id": previous_interaction_id,
|
|
425
|
+
"response_format": response_format,
|
|
426
|
+
"response_mime_type": response_mime_type,
|
|
427
|
+
"response_modalities": response_modalities,
|
|
428
|
+
"store": store,
|
|
429
|
+
"stream": stream,
|
|
430
|
+
"system_instruction": system_instruction,
|
|
431
|
+
"tools": tools,
|
|
432
|
+
"agent": agent,
|
|
433
|
+
"agent_config": agent_config,
|
|
434
|
+
},
|
|
435
|
+
interaction_create_params.CreateModelInteractionParamsStreaming
|
|
436
|
+
if stream
|
|
437
|
+
else interaction_create_params.CreateModelInteractionParamsNonStreaming,
|
|
438
|
+
),
|
|
439
|
+
options=make_request_options(
|
|
440
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
441
|
+
),
|
|
442
|
+
cast_to=Interaction,
|
|
443
|
+
stream=stream or False,
|
|
444
|
+
stream_cls=Stream[InteractionSSEEvent],
|
|
445
|
+
)
|
|
446
|
+
|
|
447
|
+
def delete(
|
|
448
|
+
self,
|
|
449
|
+
id: str,
|
|
450
|
+
*,
|
|
451
|
+
api_version: str | None = None,
|
|
452
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
453
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
454
|
+
extra_headers: Headers | None = None,
|
|
455
|
+
extra_query: Query | None = None,
|
|
456
|
+
extra_body: Body | None = None,
|
|
457
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
458
|
+
) -> object:
|
|
459
|
+
"""
|
|
460
|
+
Deletes the interaction by id.
|
|
461
|
+
|
|
462
|
+
Args:
|
|
463
|
+
extra_headers: Send extra headers
|
|
464
|
+
|
|
465
|
+
extra_query: Add additional query parameters to the request
|
|
466
|
+
|
|
467
|
+
extra_body: Add additional JSON properties to the request
|
|
468
|
+
|
|
469
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
470
|
+
"""
|
|
471
|
+
if not id:
|
|
472
|
+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
473
|
+
if api_version is None:
|
|
474
|
+
api_version = self._client._get_api_version_path_param()
|
|
475
|
+
if not api_version:
|
|
476
|
+
raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
|
|
477
|
+
return self._delete(
|
|
478
|
+
f"/{api_version}/interactions/{id}",
|
|
479
|
+
options=make_request_options(
|
|
480
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
481
|
+
),
|
|
482
|
+
cast_to=object,
|
|
483
|
+
)
|
|
484
|
+
|
|
485
|
+
def cancel(
|
|
486
|
+
self,
|
|
487
|
+
id: str,
|
|
488
|
+
*,
|
|
489
|
+
api_version: str | None = None,
|
|
490
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
491
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
492
|
+
extra_headers: Headers | None = None,
|
|
493
|
+
extra_query: Query | None = None,
|
|
494
|
+
extra_body: Body | None = None,
|
|
495
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
496
|
+
) -> Interaction:
|
|
497
|
+
"""Cancels an interaction by id.
|
|
498
|
+
|
|
499
|
+
This only applies to background interactions that are still running.
|
|
500
|
+
|
|
501
|
+
Args:
|
|
502
|
+
extra_headers: Send extra headers
|
|
503
|
+
|
|
504
|
+
extra_query: Add additional query parameters to the request
|
|
505
|
+
|
|
506
|
+
extra_body: Add additional JSON properties to the request
|
|
507
|
+
|
|
508
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
509
|
+
"""
|
|
510
|
+
if not id:
|
|
511
|
+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
512
|
+
if api_version is None:
|
|
513
|
+
api_version = self._client._get_api_version_path_param()
|
|
514
|
+
if not api_version:
|
|
515
|
+
raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
|
|
516
|
+
return self._post(
|
|
517
|
+
f"/{api_version}/interactions/{id}/cancel",
|
|
518
|
+
options=make_request_options(
|
|
519
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
520
|
+
),
|
|
521
|
+
cast_to=Interaction,
|
|
522
|
+
)
|
|
523
|
+
|
|
524
|
+
@overload
|
|
525
|
+
def get(
|
|
526
|
+
self,
|
|
527
|
+
id: str,
|
|
528
|
+
*,
|
|
529
|
+
api_version: str | None = None,
|
|
530
|
+
last_event_id: str | Omit = omit,
|
|
531
|
+
stream: Literal[False] | Omit = omit,
|
|
532
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
533
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
534
|
+
extra_headers: Headers | None = None,
|
|
535
|
+
extra_query: Query | None = None,
|
|
536
|
+
extra_body: Body | None = None,
|
|
537
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
538
|
+
) -> Interaction:
|
|
539
|
+
"""
|
|
540
|
+
Retrieves the full details of a single interaction based on its `Interaction.id`.
|
|
541
|
+
|
|
542
|
+
Args:
|
|
543
|
+
last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true.
|
|
544
|
+
|
|
545
|
+
stream: If set to true, the generated content will be streamed incrementally.
|
|
546
|
+
|
|
547
|
+
extra_headers: Send extra headers
|
|
548
|
+
|
|
549
|
+
extra_query: Add additional query parameters to the request
|
|
550
|
+
|
|
551
|
+
extra_body: Add additional JSON properties to the request
|
|
552
|
+
|
|
553
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
554
|
+
"""
|
|
555
|
+
...
|
|
556
|
+
|
|
557
|
+
@overload
|
|
558
|
+
def get(
|
|
559
|
+
self,
|
|
560
|
+
id: str,
|
|
561
|
+
*,
|
|
562
|
+
stream: Literal[True],
|
|
563
|
+
api_version: str | None = None,
|
|
564
|
+
last_event_id: str | Omit = omit,
|
|
565
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
566
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
567
|
+
extra_headers: Headers | None = None,
|
|
568
|
+
extra_query: Query | None = None,
|
|
569
|
+
extra_body: Body | None = None,
|
|
570
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
571
|
+
) -> Stream[InteractionSSEEvent]:
|
|
572
|
+
"""
|
|
573
|
+
Retrieves the full details of a single interaction based on its `Interaction.id`.
|
|
574
|
+
|
|
575
|
+
Args:
|
|
576
|
+
stream: If set to true, the generated content will be streamed incrementally.
|
|
577
|
+
|
|
578
|
+
last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true.
|
|
579
|
+
|
|
580
|
+
extra_headers: Send extra headers
|
|
581
|
+
|
|
582
|
+
extra_query: Add additional query parameters to the request
|
|
583
|
+
|
|
584
|
+
extra_body: Add additional JSON properties to the request
|
|
585
|
+
|
|
586
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
587
|
+
"""
|
|
588
|
+
...
|
|
589
|
+
|
|
590
|
+
@overload
|
|
591
|
+
def get(
|
|
592
|
+
self,
|
|
593
|
+
id: str,
|
|
594
|
+
*,
|
|
595
|
+
stream: bool,
|
|
596
|
+
api_version: str | None = None,
|
|
597
|
+
last_event_id: str | Omit = omit,
|
|
598
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
599
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
600
|
+
extra_headers: Headers | None = None,
|
|
601
|
+
extra_query: Query | None = None,
|
|
602
|
+
extra_body: Body | None = None,
|
|
603
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
604
|
+
) -> Interaction | Stream[InteractionSSEEvent]:
|
|
605
|
+
"""
|
|
606
|
+
Retrieves the full details of a single interaction based on its `Interaction.id`.
|
|
607
|
+
|
|
608
|
+
Args:
|
|
609
|
+
stream: If set to true, the generated content will be streamed incrementally.
|
|
610
|
+
|
|
611
|
+
last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true.
|
|
612
|
+
|
|
613
|
+
extra_headers: Send extra headers
|
|
614
|
+
|
|
615
|
+
extra_query: Add additional query parameters to the request
|
|
616
|
+
|
|
617
|
+
extra_body: Add additional JSON properties to the request
|
|
618
|
+
|
|
619
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
620
|
+
"""
|
|
621
|
+
...
|
|
622
|
+
|
|
623
|
+
def get(
|
|
624
|
+
self,
|
|
625
|
+
id: str,
|
|
626
|
+
*,
|
|
627
|
+
api_version: str | None = None,
|
|
628
|
+
last_event_id: str | Omit = omit,
|
|
629
|
+
stream: Literal[False] | Literal[True] | Omit = omit,
|
|
630
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
631
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
632
|
+
extra_headers: Headers | None = None,
|
|
633
|
+
extra_query: Query | None = None,
|
|
634
|
+
extra_body: Body | None = None,
|
|
635
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
636
|
+
) -> Interaction | Stream[InteractionSSEEvent]:
|
|
637
|
+
if not id:
|
|
638
|
+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
639
|
+
if api_version is None:
|
|
640
|
+
api_version = self._client._get_api_version_path_param()
|
|
641
|
+
if not api_version:
|
|
642
|
+
raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
|
|
643
|
+
return self._get(
|
|
644
|
+
f"/{api_version}/interactions/{id}",
|
|
645
|
+
options=make_request_options(
|
|
646
|
+
extra_headers=extra_headers,
|
|
647
|
+
extra_query=extra_query,
|
|
648
|
+
extra_body=extra_body,
|
|
649
|
+
timeout=timeout,
|
|
650
|
+
query=maybe_transform(
|
|
651
|
+
{
|
|
652
|
+
"last_event_id": last_event_id,
|
|
653
|
+
"stream": stream,
|
|
654
|
+
},
|
|
655
|
+
interaction_get_params.InteractionGetParams,
|
|
656
|
+
),
|
|
657
|
+
),
|
|
658
|
+
cast_to=Interaction,
|
|
659
|
+
stream=stream or False,
|
|
660
|
+
stream_cls=Stream[InteractionSSEEvent],
|
|
661
|
+
)
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
class AsyncInteractionsResource(AsyncAPIResource):
|
|
665
|
+
@cached_property
|
|
666
|
+
def with_raw_response(self) -> AsyncInteractionsResourceWithRawResponse:
|
|
667
|
+
"""
|
|
668
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
669
|
+
the raw response object instead of the parsed content.
|
|
670
|
+
|
|
671
|
+
For more information, see https://www.github.com/stainless-sdks/gemini-next-gen-api-python#accessing-raw-response-data-eg-headers
|
|
672
|
+
"""
|
|
673
|
+
return AsyncInteractionsResourceWithRawResponse(self)
|
|
674
|
+
|
|
675
|
+
@cached_property
|
|
676
|
+
def with_streaming_response(self) -> AsyncInteractionsResourceWithStreamingResponse:
|
|
677
|
+
"""
|
|
678
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
679
|
+
|
|
680
|
+
For more information, see https://www.github.com/stainless-sdks/gemini-next-gen-api-python#with_streaming_response
|
|
681
|
+
"""
|
|
682
|
+
return AsyncInteractionsResourceWithStreamingResponse(self)
|
|
683
|
+
|
|
684
|
+
@overload
|
|
685
|
+
async def create(
|
|
686
|
+
self,
|
|
687
|
+
*,
|
|
688
|
+
input: interaction_create_params.Input,
|
|
689
|
+
model: ModelParam,
|
|
690
|
+
api_version: str | None = None,
|
|
691
|
+
background: bool | Omit = omit,
|
|
692
|
+
generation_config: GenerationConfigParam | Omit = omit,
|
|
693
|
+
previous_interaction_id: str | Omit = omit,
|
|
694
|
+
response_format: object | Omit = omit,
|
|
695
|
+
response_mime_type: str | Omit = omit,
|
|
696
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
697
|
+
store: bool | Omit = omit,
|
|
698
|
+
stream: Literal[False] | Omit = omit,
|
|
699
|
+
system_instruction: str | Omit = omit,
|
|
700
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
701
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
702
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
703
|
+
extra_headers: Headers | None = None,
|
|
704
|
+
extra_query: Query | None = None,
|
|
705
|
+
extra_body: Body | None = None,
|
|
706
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
707
|
+
) -> Interaction:
|
|
708
|
+
"""
|
|
709
|
+
Creates a new interaction.
|
|
710
|
+
|
|
711
|
+
Args:
|
|
712
|
+
input: The inputs for the interaction.
|
|
713
|
+
|
|
714
|
+
model: The name of the `Model` used for generating the interaction.
|
|
715
|
+
|
|
716
|
+
background: Whether to run the model interaction in the background.
|
|
717
|
+
|
|
718
|
+
generation_config: Input only. Configuration parameters for the model interaction.
|
|
719
|
+
|
|
720
|
+
previous_interaction_id: The ID of the previous interaction, if any.
|
|
721
|
+
|
|
722
|
+
response_format: Enforces that the generated response is a JSON object that complies with
|
|
723
|
+
the JSON schema specified in this field.
|
|
724
|
+
|
|
725
|
+
response_mime_type: The mime type of the response. This is required if response_format is set.
|
|
726
|
+
|
|
727
|
+
response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
|
|
728
|
+
|
|
729
|
+
store: Input only. Whether to store the response and request for later retrieval.
|
|
730
|
+
|
|
731
|
+
stream: Input only. Whether the interaction will be streamed.
|
|
732
|
+
|
|
733
|
+
system_instruction: System instruction for the interaction.
|
|
734
|
+
|
|
735
|
+
tools: A list of tool declarations the model may call during interaction.
|
|
736
|
+
|
|
737
|
+
extra_headers: Send extra headers
|
|
738
|
+
|
|
739
|
+
extra_query: Add additional query parameters to the request
|
|
740
|
+
|
|
741
|
+
extra_body: Add additional JSON properties to the request
|
|
742
|
+
|
|
743
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
744
|
+
"""
|
|
745
|
+
...
|
|
746
|
+
|
|
747
|
+
@overload
|
|
748
|
+
async def create(
|
|
749
|
+
self,
|
|
750
|
+
*,
|
|
751
|
+
input: interaction_create_params.Input,
|
|
752
|
+
model: ModelParam,
|
|
753
|
+
stream: Literal[True],
|
|
754
|
+
api_version: str | None = None,
|
|
755
|
+
background: bool | Omit = omit,
|
|
756
|
+
generation_config: GenerationConfigParam | Omit = omit,
|
|
757
|
+
previous_interaction_id: str | Omit = omit,
|
|
758
|
+
response_format: object | Omit = omit,
|
|
759
|
+
response_mime_type: str | Omit = omit,
|
|
760
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
761
|
+
store: bool | Omit = omit,
|
|
762
|
+
system_instruction: str | Omit = omit,
|
|
763
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
764
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
765
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
766
|
+
extra_headers: Headers | None = None,
|
|
767
|
+
extra_query: Query | None = None,
|
|
768
|
+
extra_body: Body | None = None,
|
|
769
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
770
|
+
) -> AsyncStream[InteractionSSEEvent]:
|
|
771
|
+
"""
|
|
772
|
+
Creates a new interaction.
|
|
773
|
+
|
|
774
|
+
Args:
|
|
775
|
+
input: The inputs for the interaction.
|
|
776
|
+
|
|
777
|
+
model: The name of the `Model` used for generating the interaction.
|
|
778
|
+
|
|
779
|
+
stream: Input only. Whether the interaction will be streamed.
|
|
780
|
+
|
|
781
|
+
background: Whether to run the model interaction in the background.
|
|
782
|
+
|
|
783
|
+
generation_config: Input only. Configuration parameters for the model interaction.
|
|
784
|
+
|
|
785
|
+
previous_interaction_id: The ID of the previous interaction, if any.
|
|
786
|
+
|
|
787
|
+
response_format: Enforces that the generated response is a JSON object that complies with
|
|
788
|
+
the JSON schema specified in this field.
|
|
789
|
+
|
|
790
|
+
response_mime_type: The mime type of the response. This is required if response_format is set.
|
|
791
|
+
|
|
792
|
+
response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
|
|
793
|
+
|
|
794
|
+
store: Input only. Whether to store the response and request for later retrieval.
|
|
795
|
+
|
|
796
|
+
system_instruction: System instruction for the interaction.
|
|
797
|
+
|
|
798
|
+
tools: A list of tool declarations the model may call during interaction.
|
|
799
|
+
|
|
800
|
+
extra_headers: Send extra headers
|
|
801
|
+
|
|
802
|
+
extra_query: Add additional query parameters to the request
|
|
803
|
+
|
|
804
|
+
extra_body: Add additional JSON properties to the request
|
|
805
|
+
|
|
806
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
807
|
+
"""
|
|
808
|
+
...
|
|
809
|
+
|
|
810
|
+
@overload
|
|
811
|
+
async def create(
|
|
812
|
+
self,
|
|
813
|
+
*,
|
|
814
|
+
agent: Union[str, Literal["deep-research-pro-preview-12-2025"]],
|
|
815
|
+
input: interaction_create_params.Input,
|
|
816
|
+
api_version: str | None = None,
|
|
817
|
+
agent_config: interaction_create_params.AgentConfig | Omit = omit,
|
|
818
|
+
background: bool | Omit = omit,
|
|
819
|
+
previous_interaction_id: str | Omit = omit,
|
|
820
|
+
response_format: object | Omit = omit,
|
|
821
|
+
response_mime_type: str | Omit = omit,
|
|
822
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
823
|
+
store: bool | Omit = omit,
|
|
824
|
+
stream: Literal[False] | Omit = omit,
|
|
825
|
+
system_instruction: str | Omit = omit,
|
|
826
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
827
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
828
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
829
|
+
extra_headers: Headers | None = None,
|
|
830
|
+
extra_query: Query | None = None,
|
|
831
|
+
extra_body: Body | None = None,
|
|
832
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
833
|
+
) -> Interaction:
|
|
834
|
+
"""
|
|
835
|
+
Creates a new interaction.
|
|
836
|
+
|
|
837
|
+
Args:
|
|
838
|
+
agent: The name of the `Agent` used for generating the interaction.
|
|
839
|
+
|
|
840
|
+
input: The inputs for the interaction.
|
|
841
|
+
|
|
842
|
+
agent_config: Configuration for the agent.
|
|
843
|
+
|
|
844
|
+
background: Whether to run the model interaction in the background.
|
|
845
|
+
|
|
846
|
+
previous_interaction_id: The ID of the previous interaction, if any.
|
|
847
|
+
|
|
848
|
+
response_format: Enforces that the generated response is a JSON object that complies with
|
|
849
|
+
the JSON schema specified in this field.
|
|
850
|
+
|
|
851
|
+
response_mime_type: The mime type of the response. This is required if response_format is set.
|
|
852
|
+
|
|
853
|
+
response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
|
|
854
|
+
|
|
855
|
+
store: Input only. Whether to store the response and request for later retrieval.
|
|
856
|
+
|
|
857
|
+
stream: Input only. Whether the interaction will be streamed.
|
|
858
|
+
|
|
859
|
+
system_instruction: System instruction for the interaction.
|
|
860
|
+
|
|
861
|
+
tools: A list of tool declarations the model may call during interaction.
|
|
862
|
+
|
|
863
|
+
extra_headers: Send extra headers
|
|
864
|
+
|
|
865
|
+
extra_query: Add additional query parameters to the request
|
|
866
|
+
|
|
867
|
+
extra_body: Add additional JSON properties to the request
|
|
868
|
+
|
|
869
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
870
|
+
"""
|
|
871
|
+
...
|
|
872
|
+
|
|
873
|
+
@overload
|
|
874
|
+
async def create(
|
|
875
|
+
self,
|
|
876
|
+
*,
|
|
877
|
+
agent: Union[str, Literal["deep-research-pro-preview-12-2025"]],
|
|
878
|
+
input: interaction_create_params.Input,
|
|
879
|
+
stream: Literal[True],
|
|
880
|
+
api_version: str | None = None,
|
|
881
|
+
agent_config: interaction_create_params.AgentConfig | Omit = omit,
|
|
882
|
+
background: bool | Omit = omit,
|
|
883
|
+
previous_interaction_id: str | Omit = omit,
|
|
884
|
+
response_format: object | Omit = omit,
|
|
885
|
+
response_mime_type: str | Omit = omit,
|
|
886
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
887
|
+
store: bool | Omit = omit,
|
|
888
|
+
system_instruction: str | Omit = omit,
|
|
889
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
890
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
891
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
892
|
+
extra_headers: Headers | None = None,
|
|
893
|
+
extra_query: Query | None = None,
|
|
894
|
+
extra_body: Body | None = None,
|
|
895
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
896
|
+
) -> AsyncStream[InteractionSSEEvent]:
|
|
897
|
+
"""
|
|
898
|
+
Creates a new interaction.
|
|
899
|
+
|
|
900
|
+
Args:
|
|
901
|
+
agent: The name of the `Agent` used for generating the interaction.
|
|
902
|
+
|
|
903
|
+
input: The inputs for the interaction.
|
|
904
|
+
|
|
905
|
+
stream: Input only. Whether the interaction will be streamed.
|
|
906
|
+
|
|
907
|
+
agent_config: Configuration for the agent.
|
|
908
|
+
|
|
909
|
+
background: Whether to run the model interaction in the background.
|
|
910
|
+
|
|
911
|
+
previous_interaction_id: The ID of the previous interaction, if any.
|
|
912
|
+
|
|
913
|
+
response_format: Enforces that the generated response is a JSON object that complies with
|
|
914
|
+
the JSON schema specified in this field.
|
|
915
|
+
|
|
916
|
+
response_mime_type: The mime type of the response. This is required if response_format is set.
|
|
917
|
+
|
|
918
|
+
response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
|
|
919
|
+
|
|
920
|
+
store: Input only. Whether to store the response and request for later retrieval.
|
|
921
|
+
|
|
922
|
+
system_instruction: System instruction for the interaction.
|
|
923
|
+
|
|
924
|
+
tools: A list of tool declarations the model may call during interaction.
|
|
925
|
+
|
|
926
|
+
extra_headers: Send extra headers
|
|
927
|
+
|
|
928
|
+
extra_query: Add additional query parameters to the request
|
|
929
|
+
|
|
930
|
+
extra_body: Add additional JSON properties to the request
|
|
931
|
+
|
|
932
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
933
|
+
"""
|
|
934
|
+
...
|
|
935
|
+
|
|
936
|
+
@overload
|
|
937
|
+
async def create(
|
|
938
|
+
self,
|
|
939
|
+
*,
|
|
940
|
+
input: interaction_create_params.Input,
|
|
941
|
+
model: ModelParam,
|
|
942
|
+
stream: bool,
|
|
943
|
+
api_version: str | None = None,
|
|
944
|
+
background: bool | Omit = omit,
|
|
945
|
+
generation_config: GenerationConfigParam | Omit = omit,
|
|
946
|
+
previous_interaction_id: str | Omit = omit,
|
|
947
|
+
response_format: object | Omit = omit,
|
|
948
|
+
response_mime_type: str | Omit = omit,
|
|
949
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
950
|
+
store: bool | Omit = omit,
|
|
951
|
+
system_instruction: str | Omit = omit,
|
|
952
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
953
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
954
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
955
|
+
extra_headers: Headers | None = None,
|
|
956
|
+
extra_query: Query | None = None,
|
|
957
|
+
extra_body: Body | None = None,
|
|
958
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
959
|
+
) -> Interaction | AsyncStream[InteractionSSEEvent]:
|
|
960
|
+
"""
|
|
961
|
+
Creates a new interaction.
|
|
962
|
+
|
|
963
|
+
Args:
|
|
964
|
+
input: The inputs for the interaction.
|
|
965
|
+
|
|
966
|
+
model: The name of the `Model` used for generating the interaction.
|
|
967
|
+
|
|
968
|
+
stream: Input only. Whether the interaction will be streamed.
|
|
969
|
+
|
|
970
|
+
background: Whether to run the model interaction in the background.
|
|
971
|
+
|
|
972
|
+
generation_config: Input only. Configuration parameters for the model interaction.
|
|
973
|
+
|
|
974
|
+
previous_interaction_id: The ID of the previous interaction, if any.
|
|
975
|
+
|
|
976
|
+
response_format: Enforces that the generated response is a JSON object that complies with
|
|
977
|
+
the JSON schema specified in this field.
|
|
978
|
+
|
|
979
|
+
response_mime_type: The mime type of the response. This is required if response_format is set.
|
|
980
|
+
|
|
981
|
+
response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
|
|
982
|
+
|
|
983
|
+
store: Input only. Whether to store the response and request for later retrieval.
|
|
984
|
+
|
|
985
|
+
system_instruction: System instruction for the interaction.
|
|
986
|
+
|
|
987
|
+
tools: A list of tool declarations the model may call during interaction.
|
|
988
|
+
|
|
989
|
+
extra_headers: Send extra headers
|
|
990
|
+
|
|
991
|
+
extra_query: Add additional query parameters to the request
|
|
992
|
+
|
|
993
|
+
extra_body: Add additional JSON properties to the request
|
|
994
|
+
|
|
995
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
996
|
+
"""
|
|
997
|
+
...
|
|
998
|
+
|
|
999
|
+
@required_args(["input", "model"], ["input", "model", "stream"], ["agent", "input"], ["agent", "input", "stream"])
|
|
1000
|
+
async def create(
|
|
1001
|
+
self,
|
|
1002
|
+
*,
|
|
1003
|
+
input: interaction_create_params.Input,
|
|
1004
|
+
model: ModelParam | Omit = omit,
|
|
1005
|
+
api_version: str | None = None,
|
|
1006
|
+
background: bool | Omit = omit,
|
|
1007
|
+
generation_config: GenerationConfigParam | Omit = omit,
|
|
1008
|
+
previous_interaction_id: str | Omit = omit,
|
|
1009
|
+
response_format: object | Omit = omit,
|
|
1010
|
+
response_mime_type: str | Omit = omit,
|
|
1011
|
+
response_modalities: List[Literal["text", "image", "audio"]] | Omit = omit,
|
|
1012
|
+
store: bool | Omit = omit,
|
|
1013
|
+
stream: Literal[False] | Literal[True] | Omit = omit,
|
|
1014
|
+
system_instruction: str | Omit = omit,
|
|
1015
|
+
tools: Iterable[ToolParam] | Omit = omit,
|
|
1016
|
+
agent: Union[str, Literal["deep-research-pro-preview-12-2025"]] | Omit = omit,
|
|
1017
|
+
agent_config: interaction_create_params.AgentConfig | Omit = omit,
|
|
1018
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1019
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1020
|
+
extra_headers: Headers | None = None,
|
|
1021
|
+
extra_query: Query | None = None,
|
|
1022
|
+
extra_body: Body | None = None,
|
|
1023
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1024
|
+
) -> Interaction | AsyncStream[InteractionSSEEvent]:
|
|
1025
|
+
if api_version is None:
|
|
1026
|
+
api_version = self._client._get_api_version_path_param()
|
|
1027
|
+
if not api_version:
|
|
1028
|
+
raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
|
|
1029
|
+
if model is not omit and agent_config is not omit:
|
|
1030
|
+
raise ValueError("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.")
|
|
1031
|
+
if agent is not omit and generation_config is not omit:
|
|
1032
|
+
raise ValueError("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.")
|
|
1033
|
+
return await self._post(
|
|
1034
|
+
self._client._build_maybe_vertex_path(api_version=api_version, path='interactions'),
|
|
1035
|
+
body=await async_maybe_transform(
|
|
1036
|
+
{
|
|
1037
|
+
"input": input,
|
|
1038
|
+
"model": model,
|
|
1039
|
+
"background": background,
|
|
1040
|
+
"generation_config": generation_config,
|
|
1041
|
+
"previous_interaction_id": previous_interaction_id,
|
|
1042
|
+
"response_format": response_format,
|
|
1043
|
+
"response_mime_type": response_mime_type,
|
|
1044
|
+
"response_modalities": response_modalities,
|
|
1045
|
+
"store": store,
|
|
1046
|
+
"stream": stream,
|
|
1047
|
+
"system_instruction": system_instruction,
|
|
1048
|
+
"tools": tools,
|
|
1049
|
+
"agent": agent,
|
|
1050
|
+
"agent_config": agent_config,
|
|
1051
|
+
},
|
|
1052
|
+
interaction_create_params.CreateModelInteractionParamsStreaming
|
|
1053
|
+
if stream
|
|
1054
|
+
else interaction_create_params.CreateModelInteractionParamsNonStreaming,
|
|
1055
|
+
),
|
|
1056
|
+
options=make_request_options(
|
|
1057
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1058
|
+
),
|
|
1059
|
+
cast_to=Interaction,
|
|
1060
|
+
stream=stream or False,
|
|
1061
|
+
stream_cls=AsyncStream[InteractionSSEEvent],
|
|
1062
|
+
)
|
|
1063
|
+
|
|
1064
|
+
async def delete(
|
|
1065
|
+
self,
|
|
1066
|
+
id: str,
|
|
1067
|
+
*,
|
|
1068
|
+
api_version: str | None = None,
|
|
1069
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1070
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1071
|
+
extra_headers: Headers | None = None,
|
|
1072
|
+
extra_query: Query | None = None,
|
|
1073
|
+
extra_body: Body | None = None,
|
|
1074
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1075
|
+
) -> object:
|
|
1076
|
+
"""
|
|
1077
|
+
Deletes the interaction by id.
|
|
1078
|
+
|
|
1079
|
+
Args:
|
|
1080
|
+
extra_headers: Send extra headers
|
|
1081
|
+
|
|
1082
|
+
extra_query: Add additional query parameters to the request
|
|
1083
|
+
|
|
1084
|
+
extra_body: Add additional JSON properties to the request
|
|
1085
|
+
|
|
1086
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1087
|
+
"""
|
|
1088
|
+
if not id:
|
|
1089
|
+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
1090
|
+
if api_version is None:
|
|
1091
|
+
api_version = self._client._get_api_version_path_param()
|
|
1092
|
+
if not api_version:
|
|
1093
|
+
raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
|
|
1094
|
+
return await self._delete(
|
|
1095
|
+
f"/{api_version}/interactions/{id}",
|
|
1096
|
+
options=make_request_options(
|
|
1097
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1098
|
+
),
|
|
1099
|
+
cast_to=object,
|
|
1100
|
+
)
|
|
1101
|
+
|
|
1102
|
+
async def cancel(
|
|
1103
|
+
self,
|
|
1104
|
+
id: str,
|
|
1105
|
+
*,
|
|
1106
|
+
api_version: str | None = None,
|
|
1107
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1108
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1109
|
+
extra_headers: Headers | None = None,
|
|
1110
|
+
extra_query: Query | None = None,
|
|
1111
|
+
extra_body: Body | None = None,
|
|
1112
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1113
|
+
) -> Interaction:
|
|
1114
|
+
"""Cancels an interaction by id.
|
|
1115
|
+
|
|
1116
|
+
This only applies to background interactions that are still running.
|
|
1117
|
+
|
|
1118
|
+
Args:
|
|
1119
|
+
extra_headers: Send extra headers
|
|
1120
|
+
|
|
1121
|
+
extra_query: Add additional query parameters to the request
|
|
1122
|
+
|
|
1123
|
+
extra_body: Add additional JSON properties to the request
|
|
1124
|
+
|
|
1125
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1126
|
+
"""
|
|
1127
|
+
if not id:
|
|
1128
|
+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
1129
|
+
if api_version is None:
|
|
1130
|
+
api_version = self._client._get_api_version_path_param()
|
|
1131
|
+
if not api_version:
|
|
1132
|
+
raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
|
|
1133
|
+
return await self._post(
|
|
1134
|
+
f"/{api_version}/interactions/{id}/cancel",
|
|
1135
|
+
options=make_request_options(
|
|
1136
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1137
|
+
),
|
|
1138
|
+
cast_to=Interaction,
|
|
1139
|
+
)
|
|
1140
|
+
|
|
1141
|
+
@overload
|
|
1142
|
+
async def get(
|
|
1143
|
+
self,
|
|
1144
|
+
id: str,
|
|
1145
|
+
*,
|
|
1146
|
+
api_version: str | None = None,
|
|
1147
|
+
last_event_id: str | Omit = omit,
|
|
1148
|
+
stream: Literal[False] | Omit = omit,
|
|
1149
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1150
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1151
|
+
extra_headers: Headers | None = None,
|
|
1152
|
+
extra_query: Query | None = None,
|
|
1153
|
+
extra_body: Body | None = None,
|
|
1154
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1155
|
+
) -> Interaction:
|
|
1156
|
+
"""
|
|
1157
|
+
Retrieves the full details of a single interaction based on its `Interaction.id`.
|
|
1158
|
+
|
|
1159
|
+
Args:
|
|
1160
|
+
last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true.
|
|
1161
|
+
|
|
1162
|
+
stream: If set to true, the generated content will be streamed incrementally.
|
|
1163
|
+
|
|
1164
|
+
extra_headers: Send extra headers
|
|
1165
|
+
|
|
1166
|
+
extra_query: Add additional query parameters to the request
|
|
1167
|
+
|
|
1168
|
+
extra_body: Add additional JSON properties to the request
|
|
1169
|
+
|
|
1170
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1171
|
+
"""
|
|
1172
|
+
...
|
|
1173
|
+
|
|
1174
|
+
@overload
|
|
1175
|
+
async def get(
|
|
1176
|
+
self,
|
|
1177
|
+
id: str,
|
|
1178
|
+
*,
|
|
1179
|
+
stream: Literal[True],
|
|
1180
|
+
api_version: str | None = None,
|
|
1181
|
+
last_event_id: str | Omit = omit,
|
|
1182
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1183
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1184
|
+
extra_headers: Headers | None = None,
|
|
1185
|
+
extra_query: Query | None = None,
|
|
1186
|
+
extra_body: Body | None = None,
|
|
1187
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1188
|
+
) -> AsyncStream[InteractionSSEEvent]:
|
|
1189
|
+
"""
|
|
1190
|
+
Retrieves the full details of a single interaction based on its `Interaction.id`.
|
|
1191
|
+
|
|
1192
|
+
Args:
|
|
1193
|
+
stream: If set to true, the generated content will be streamed incrementally.
|
|
1194
|
+
|
|
1195
|
+
last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true.
|
|
1196
|
+
|
|
1197
|
+
extra_headers: Send extra headers
|
|
1198
|
+
|
|
1199
|
+
extra_query: Add additional query parameters to the request
|
|
1200
|
+
|
|
1201
|
+
extra_body: Add additional JSON properties to the request
|
|
1202
|
+
|
|
1203
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1204
|
+
"""
|
|
1205
|
+
...
|
|
1206
|
+
|
|
1207
|
+
@overload
|
|
1208
|
+
async def get(
|
|
1209
|
+
self,
|
|
1210
|
+
id: str,
|
|
1211
|
+
*,
|
|
1212
|
+
stream: bool,
|
|
1213
|
+
api_version: str | None = None,
|
|
1214
|
+
last_event_id: str | Omit = omit,
|
|
1215
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1216
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1217
|
+
extra_headers: Headers | None = None,
|
|
1218
|
+
extra_query: Query | None = None,
|
|
1219
|
+
extra_body: Body | None = None,
|
|
1220
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1221
|
+
) -> Interaction | AsyncStream[InteractionSSEEvent]:
|
|
1222
|
+
"""
|
|
1223
|
+
Retrieves the full details of a single interaction based on its `Interaction.id`.
|
|
1224
|
+
|
|
1225
|
+
Args:
|
|
1226
|
+
stream: If set to true, the generated content will be streamed incrementally.
|
|
1227
|
+
|
|
1228
|
+
last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true.
|
|
1229
|
+
|
|
1230
|
+
extra_headers: Send extra headers
|
|
1231
|
+
|
|
1232
|
+
extra_query: Add additional query parameters to the request
|
|
1233
|
+
|
|
1234
|
+
extra_body: Add additional JSON properties to the request
|
|
1235
|
+
|
|
1236
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1237
|
+
"""
|
|
1238
|
+
...
|
|
1239
|
+
|
|
1240
|
+
async def get(
|
|
1241
|
+
self,
|
|
1242
|
+
id: str,
|
|
1243
|
+
*,
|
|
1244
|
+
api_version: str | None = None,
|
|
1245
|
+
last_event_id: str | Omit = omit,
|
|
1246
|
+
stream: Literal[False] | Literal[True] | Omit = omit,
|
|
1247
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1248
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1249
|
+
extra_headers: Headers | None = None,
|
|
1250
|
+
extra_query: Query | None = None,
|
|
1251
|
+
extra_body: Body | None = None,
|
|
1252
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1253
|
+
) -> Interaction | AsyncStream[InteractionSSEEvent]:
|
|
1254
|
+
if not id:
|
|
1255
|
+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
|
|
1256
|
+
if api_version is None:
|
|
1257
|
+
api_version = self._client._get_api_version_path_param()
|
|
1258
|
+
if not api_version:
|
|
1259
|
+
raise ValueError(f"Expected a non-empty value for `api_version` but received {api_version!r}")
|
|
1260
|
+
return await self._get(
|
|
1261
|
+
f"/{api_version}/interactions/{id}",
|
|
1262
|
+
options=make_request_options(
|
|
1263
|
+
extra_headers=extra_headers,
|
|
1264
|
+
extra_query=extra_query,
|
|
1265
|
+
extra_body=extra_body,
|
|
1266
|
+
timeout=timeout,
|
|
1267
|
+
query=await async_maybe_transform(
|
|
1268
|
+
{
|
|
1269
|
+
"last_event_id": last_event_id,
|
|
1270
|
+
"stream": stream,
|
|
1271
|
+
},
|
|
1272
|
+
interaction_get_params.InteractionGetParams,
|
|
1273
|
+
),
|
|
1274
|
+
),
|
|
1275
|
+
cast_to=Interaction,
|
|
1276
|
+
stream=stream or False,
|
|
1277
|
+
stream_cls=AsyncStream[InteractionSSEEvent],
|
|
1278
|
+
)
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
class InteractionsResourceWithRawResponse:
|
|
1282
|
+
def __init__(self, interactions: InteractionsResource) -> None:
|
|
1283
|
+
self._interactions = interactions
|
|
1284
|
+
|
|
1285
|
+
self.create = to_raw_response_wrapper(
|
|
1286
|
+
interactions.create,
|
|
1287
|
+
)
|
|
1288
|
+
self.delete = to_raw_response_wrapper(
|
|
1289
|
+
interactions.delete,
|
|
1290
|
+
)
|
|
1291
|
+
self.cancel = to_raw_response_wrapper(
|
|
1292
|
+
interactions.cancel,
|
|
1293
|
+
)
|
|
1294
|
+
self.get = to_raw_response_wrapper(
|
|
1295
|
+
interactions.get,
|
|
1296
|
+
)
|
|
1297
|
+
|
|
1298
|
+
|
|
1299
|
+
class AsyncInteractionsResourceWithRawResponse:
|
|
1300
|
+
def __init__(self, interactions: AsyncInteractionsResource) -> None:
|
|
1301
|
+
self._interactions = interactions
|
|
1302
|
+
|
|
1303
|
+
self.create = async_to_raw_response_wrapper(
|
|
1304
|
+
interactions.create,
|
|
1305
|
+
)
|
|
1306
|
+
self.delete = async_to_raw_response_wrapper(
|
|
1307
|
+
interactions.delete,
|
|
1308
|
+
)
|
|
1309
|
+
self.cancel = async_to_raw_response_wrapper(
|
|
1310
|
+
interactions.cancel,
|
|
1311
|
+
)
|
|
1312
|
+
self.get = async_to_raw_response_wrapper(
|
|
1313
|
+
interactions.get,
|
|
1314
|
+
)
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
class InteractionsResourceWithStreamingResponse:
|
|
1318
|
+
def __init__(self, interactions: InteractionsResource) -> None:
|
|
1319
|
+
self._interactions = interactions
|
|
1320
|
+
|
|
1321
|
+
self.create = to_streamed_response_wrapper(
|
|
1322
|
+
interactions.create,
|
|
1323
|
+
)
|
|
1324
|
+
self.delete = to_streamed_response_wrapper(
|
|
1325
|
+
interactions.delete,
|
|
1326
|
+
)
|
|
1327
|
+
self.cancel = to_streamed_response_wrapper(
|
|
1328
|
+
interactions.cancel,
|
|
1329
|
+
)
|
|
1330
|
+
self.get = to_streamed_response_wrapper(
|
|
1331
|
+
interactions.get,
|
|
1332
|
+
)
|
|
1333
|
+
|
|
1334
|
+
|
|
1335
|
+
class AsyncInteractionsResourceWithStreamingResponse:
|
|
1336
|
+
def __init__(self, interactions: AsyncInteractionsResource) -> None:
|
|
1337
|
+
self._interactions = interactions
|
|
1338
|
+
|
|
1339
|
+
self.create = async_to_streamed_response_wrapper(
|
|
1340
|
+
interactions.create,
|
|
1341
|
+
)
|
|
1342
|
+
self.delete = async_to_streamed_response_wrapper(
|
|
1343
|
+
interactions.delete,
|
|
1344
|
+
)
|
|
1345
|
+
self.cancel = async_to_streamed_response_wrapper(
|
|
1346
|
+
interactions.cancel,
|
|
1347
|
+
)
|
|
1348
|
+
self.get = async_to_streamed_response_wrapper(
|
|
1349
|
+
interactions.get,
|
|
1350
|
+
)
|