SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
13 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
861.7 KB · 23,435 lines python
Raw Blame History
1# Copyright 2025 Google LLC2#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 at6#7#     http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# 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 and13# limitations under the License.14#1516# Code generated by the Google Gen AI SDK generator DO NOT EDIT.1718from abc import ABC, abstractmethod19import datetime20from enum import Enum, EnumMeta21import inspect22import io23import json24import logging25import sys26import types as builtin_types27import typing28from typing import Annotated, Any, Callable, Dict, List, Literal, Optional, Sequence, Union, _UnionGenericAlias  # type: ignore29import pydantic30from pydantic import ConfigDict, Field, PrivateAttr, WrapValidator, model_validator31from typing_extensions import Self, TypedDict32from . import _common33from ._operations_converters import (34    _GenerateVideosOperation_from_mldev,35    _GenerateVideosOperation_from_vertex,36    _ImportFileOperation_from_mldev,37    _UploadToFileSearchStoreOperation_from_mldev,38)3940if sys.version_info >= (3, 10):41  # Supports both Union[t1, t2] and t1 | t242  VersionedUnionType = Union[builtin_types.UnionType, _UnionGenericAlias]43  _UNION_TYPES = (typing.Union, builtin_types.UnionType)44else:45  # Supports only Union[t1, t2]46  VersionedUnionType = _UnionGenericAlias47  _UNION_TYPES = (typing.Union,)4849_is_pillow_image_imported = False50if typing.TYPE_CHECKING:51  from ._api_client import BaseApiClient52  import PIL.Image5354  PIL_Image = PIL.Image.Image55  _is_pillow_image_imported = True56else:57  PIL_Image: typing.Type = Any58  try:59    import PIL.Image6061    PIL_Image = PIL.Image.Image62    _is_pillow_image_imported = True63  except ImportError:64    PIL_Image = None6566if typing.TYPE_CHECKING:67  from mcp import types as mcp_types68  from mcp import ClientSession as McpClientSession69  from mcp.types import CallToolResult as McpCallToolResult707172def _is_mcp_imported() -> bool:73  return 'mcp' in sys.modules747576# PEP 562: lazy-resolve mcp symbols on first attribute access so `import77# google.genai` doesn't import `mcp` for users who don't use MCP.78def __getattr__(name: str) -> Any:79  if name == 'McpClientSession':80    try:81      from mcp import ClientSession82    except ImportError:83      globals()[name] = None84      return None85    globals()[name] = ClientSession86    return ClientSession87  if name == 'McpCallToolResult':88    try:89      from mcp.types import CallToolResult90    except ImportError:91      globals()[name] = None92      return None93    globals()[name] = CallToolResult94    return CallToolResult95  if name == 'mcp_types':96    try:97      from mcp import types as mcp_types98    except ImportError:99      globals()[name] = None100      return None101    globals()[name] = mcp_types102    return mcp_types103  raise AttributeError(f'module {__name__!r} has no attribute {name!r}')104105106if typing.TYPE_CHECKING:107  import yaml108109_is_httpx_imported = False110if typing.TYPE_CHECKING:111  import httpx112  import httpx2113114  HttpxClient = Union[httpx.Client, httpx2.Client]115  HttpxAsyncClient = Union[httpx.AsyncClient, httpx2.AsyncClient]116  _is_httpx_imported = True117else:118  HttpxClient: typing.Type = Any119  HttpxAsyncClient: typing.Type = Any120121  try:122    import httpx123124    HttpxClient = httpx.Client125    HttpxAsyncClient = httpx.AsyncClient126    _is_httpx_imported = True127  except ImportError:128    HttpxClient = None129    HttpxAsyncClient = None130131  try:132    import httpx2133134    if _is_httpx_imported:135      HttpxClient = Union[httpx.Client, httpx2.Client]136      HttpxAsyncClient = Union[httpx.AsyncClient, httpx2.AsyncClient]137    else:138      HttpxClient = httpx2.Client139      HttpxAsyncClient = httpx2.AsyncClient140      _is_httpx_imported = True141  except ImportError:142    pass143144_is_aiohttp_imported = False145if typing.TYPE_CHECKING:146  from aiohttp import ClientSession147148  _is_aiohttp_imported = True149else:150  ClientSession: typing.Type = Any151  try:152    from aiohttp import ClientSession153154    _is_aiohttp_imported = True155  except ImportError:156    ClientSession = None157158logger = logging.getLogger('google_genai.types')159_from_json_schema_warning_logged = False160_json_schema_warning_logged = False161_response_text_warning_logged = False162_response_text_non_text_warning_logged = False163_response_parts_warning_logged = False164_response_function_calls_warning_logged = False165_response_executable_code_warning_logged = False166_response_code_execution_warning_logged = False167_live_server_text_warning_logged = False168_live_server_data_warning_logged = False169170171T = typing.TypeVar('T', bound='GenerateContentResponse')172173MetricSubclass = typing.TypeVar('MetricSubclass', bound='Metric')174175176class MediaProcessing(_common.CaseInSensitiveEnum):177  """How the model processes input media for understanding."""178179  MEDIA_PROCESSING_UNSPECIFIED = 'MEDIA_PROCESSING_UNSPECIFIED'180  """Default. Uses model-specific processing"""181  STATIC = 'STATIC'182  """Fixed-rate frame extraction. All frames placed in context."""183  AGENTIC = 'AGENTIC'184  """Model-driven dynamic navigation. Recommended for most use cases."""185186187class Outcome(_common.CaseInSensitiveEnum):188  """Outcome of the code execution."""189190  OUTCOME_UNSPECIFIED = 'OUTCOME_UNSPECIFIED'191  """Unspecified status. This value should not be used."""192  OUTCOME_OK = 'OUTCOME_OK'193  """Code execution completed successfully. `output` contains the stdout, if any."""194  OUTCOME_FAILED = 'OUTCOME_FAILED'195  """Code execution failed. `output` contains the stderr and stdout, if any."""196  OUTCOME_DEADLINE_EXCEEDED = 'OUTCOME_DEADLINE_EXCEEDED'197  """Code execution ran for too long, and was cancelled. There may or may not be a partial `output` present."""198199200class Language(_common.CaseInSensitiveEnum):201  """Programming language of the `code`."""202203  LANGUAGE_UNSPECIFIED = 'LANGUAGE_UNSPECIFIED'204  """Unspecified language. This value should not be used."""205  PYTHON = 'PYTHON'206  """Python >= 3.10, with numpy and simpy available."""207208209class FunctionResponseScheduling(_common.CaseInSensitiveEnum):210  """Specifies how the response should be scheduled in the conversation.211212  Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults213  to WHEN_IDLE.214  """215216  SCHEDULING_UNSPECIFIED = 'SCHEDULING_UNSPECIFIED'217  """This value is unused."""218  SILENT = 'SILENT'219  """Only add the result to the conversation context, do not interrupt or trigger generation."""220  WHEN_IDLE = 'WHEN_IDLE'221  """Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation."""222  INTERRUPT = 'INTERRUPT'223  """Add the result to the conversation context, interrupt ongoing generation and prompt to generate output."""224225226class Type(_common.CaseInSensitiveEnum):227  """Data type of the schema field."""228229  TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED'230  """Not specified, should not be used."""231  STRING = 'STRING'232  """OpenAPI string type"""233  NUMBER = 'NUMBER'234  """OpenAPI number type"""235  INTEGER = 'INTEGER'236  """OpenAPI integer type"""237  BOOLEAN = 'BOOLEAN'238  """OpenAPI boolean type"""239  ARRAY = 'ARRAY'240  """OpenAPI array type"""241  OBJECT = 'OBJECT'242  """OpenAPI object type"""243  NULL = 'NULL'244  """Null type"""245246247class AuthType(_common.CaseInSensitiveEnum):248  """Type of auth scheme. This enum is not supported in Gemini API."""249250  AUTH_TYPE_UNSPECIFIED = 'AUTH_TYPE_UNSPECIFIED'251  NO_AUTH = 'NO_AUTH'252  """No Auth."""253  API_KEY_AUTH = 'API_KEY_AUTH'254  """API Key Auth."""255  HTTP_BASIC_AUTH = 'HTTP_BASIC_AUTH'256  """HTTP Basic Auth."""257  GOOGLE_SERVICE_ACCOUNT_AUTH = 'GOOGLE_SERVICE_ACCOUNT_AUTH'258  """Google Service Account Auth."""259  OAUTH = 'OAUTH'260  """OAuth auth."""261  OIDC_AUTH = 'OIDC_AUTH'262  """OpenID Connect (OIDC) Auth."""263264265class HttpElementLocation(_common.CaseInSensitiveEnum):266  """The location of the API key. This enum is not supported in Gemini API."""267268  HTTP_IN_UNSPECIFIED = 'HTTP_IN_UNSPECIFIED'269  HTTP_IN_QUERY = 'HTTP_IN_QUERY'270  """Element is in the HTTP request query."""271  HTTP_IN_HEADER = 'HTTP_IN_HEADER'272  """Element is in the HTTP request header."""273  HTTP_IN_PATH = 'HTTP_IN_PATH'274  """Element is in the HTTP request path."""275  HTTP_IN_BODY = 'HTTP_IN_BODY'276  """Element is in the HTTP request body."""277  HTTP_IN_COOKIE = 'HTTP_IN_COOKIE'278  """Element is in the HTTP request cookie."""279280281class ApiSpec(_common.CaseInSensitiveEnum):282  """The API spec that the external API implements.283284  This enum is not supported in Gemini API.285  """286287  API_SPEC_UNSPECIFIED = 'API_SPEC_UNSPECIFIED'288  """Unspecified API spec. This value should not be used."""289  SIMPLE_SEARCH = 'SIMPLE_SEARCH'290  """Simple search API spec."""291  ELASTIC_SEARCH = 'ELASTIC_SEARCH'292  """Elastic search API spec."""293294295class Environment(_common.CaseInSensitiveEnum):296  """The environment being operated."""297298  ENVIRONMENT_UNSPECIFIED = 'ENVIRONMENT_UNSPECIFIED'299  """Defaults to browser."""300  ENVIRONMENT_BROWSER = 'ENVIRONMENT_BROWSER'301  """Operates in a web browser."""302  ENVIRONMENT_MOBILE = 'ENVIRONMENT_MOBILE'303  """Operates in a mobile environment."""304  ENVIRONMENT_DESKTOP = 'ENVIRONMENT_DESKTOP'305  """Operates in a desktop environment."""306307308class SafetyPolicy(_common.CaseInSensitiveEnum):309  """SafetyPolicy"""310311  SAFETY_POLICY_UNSPECIFIED = 'SAFETY_POLICY_UNSPECIFIED'312  """Unspecified safety policy."""313  FINANCIAL_TRANSACTIONS = 'FINANCIAL_TRANSACTIONS'314  """Safety policy for financial transactions."""315  SENSITIVE_DATA_MODIFICATION = 'SENSITIVE_DATA_MODIFICATION'316  """Safety policy for sensitive data modification."""317  COMMUNICATION_TOOL = 'COMMUNICATION_TOOL'318  """Safety policy for communication tools (e.g. Gmail, Chat, Meet)."""319  ACCOUNT_CREATION = 'ACCOUNT_CREATION'320  """Safety policy for account creation."""321  DATA_MODIFICATION = 'DATA_MODIFICATION'322  """Safety policy for data modification."""323  USER_CONSENT_MANAGEMENT = 'USER_CONSENT_MANAGEMENT'324  """Safety policy for user consent management."""325  LEGAL_TERMS_AND_AGREEMENTS = 'LEGAL_TERMS_AND_AGREEMENTS'326  """Safety policy for legal terms and agreements."""327328329class PhishBlockThreshold(_common.CaseInSensitiveEnum):330  """Sites with confidence level chosen & above this value will be blocked from the search results.331332  This enum is not supported in Gemini API.333  """334335  PHISH_BLOCK_THRESHOLD_UNSPECIFIED = 'PHISH_BLOCK_THRESHOLD_UNSPECIFIED'336  """Defaults to unspecified."""337  BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE'338  """Blocks Low and above confidence URL that is risky."""339  BLOCK_MEDIUM_AND_ABOVE = 'BLOCK_MEDIUM_AND_ABOVE'340  """Blocks Medium and above confidence URL that is risky."""341  BLOCK_HIGH_AND_ABOVE = 'BLOCK_HIGH_AND_ABOVE'342  """Blocks High and above confidence URL that is risky."""343  BLOCK_HIGHER_AND_ABOVE = 'BLOCK_HIGHER_AND_ABOVE'344  """Blocks Higher and above confidence URL that is risky."""345  BLOCK_VERY_HIGH_AND_ABOVE = 'BLOCK_VERY_HIGH_AND_ABOVE'346  """Blocks Very high and above confidence URL that is risky."""347  BLOCK_ONLY_EXTREMELY_HIGH = 'BLOCK_ONLY_EXTREMELY_HIGH'348  """Blocks Extremely high confidence URL that is risky."""349350351class Behavior(_common.CaseInSensitiveEnum):352  """Specifies the function Behavior.353354  If not specified, the system keeps the current function call behavior. This355  field is currently only supported by the BidiGenerateContent method.356  """357358  UNSPECIFIED = 'UNSPECIFIED'359  """This value is unspecified."""360  BLOCKING = 'BLOCKING'361  """If set, the system will wait to receive the function response before continuing the conversation."""362  NON_BLOCKING = 'NON_BLOCKING'363  """If set, the system will not wait to receive the function response. Instead, it will attempt to handle function responses as they become available while maintaining the conversation between the user and the model."""364365366class DynamicRetrievalConfigMode(_common.CaseInSensitiveEnum):367  """The mode of the predictor to be used in dynamic retrieval."""368369  MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'370  """Always trigger retrieval."""371  MODE_DYNAMIC = 'MODE_DYNAMIC'372  """Run retrieval only when system decides it is necessary."""373374375class ThinkingLevel(_common.CaseInSensitiveEnum):376  """The number of thoughts tokens that the model should generate."""377378  THINKING_LEVEL_UNSPECIFIED = 'THINKING_LEVEL_UNSPECIFIED'379  """Unspecified thinking level."""380  MINIMAL = 'MINIMAL'381  """MINIMAL thinking level."""382  LOW = 'LOW'383  """Low thinking level."""384  MEDIUM = 'MEDIUM'385  """Medium thinking level."""386  HIGH = 'HIGH'387  """High thinking level."""388389390class PersonGeneration(_common.CaseInSensitiveEnum):391  """Enum that controls the generation of people."""392393  DONT_ALLOW = 'DONT_ALLOW'394  """Block generation of images of people."""395  ALLOW_ADULT = 'ALLOW_ADULT'396  """Generate images of adults, but not children."""397  ALLOW_ALL = 'ALLOW_ALL'398  """Generate images that include adults and children."""399400401class ProminentPeople(_common.CaseInSensitiveEnum):402  """Controls whether prominent people (celebrities) generation is allowed.403404  If used with personGeneration, personGeneration enum would take precedence.405  For instance, if ALLOW_NONE is set, all person generation would be blocked. If406  this field is unspecified, the default behavior is to allow prominent people.407  This enum is not supported in Gemini API.408  """409410  PROMINENT_PEOPLE_UNSPECIFIED = 'PROMINENT_PEOPLE_UNSPECIFIED'411  """Unspecified value. The model will proceed with the default behavior, which is to allow generation of prominent people."""412  ALLOW_PROMINENT_PEOPLE = 'ALLOW_PROMINENT_PEOPLE'413  """Allows the model to generate images of prominent people."""414  BLOCK_PROMINENT_PEOPLE = 'BLOCK_PROMINENT_PEOPLE'415  """Prevents the model from generating images of prominent people."""416417418class HarmCategory(_common.CaseInSensitiveEnum):419  """The harm category to be blocked."""420421  HARM_CATEGORY_UNSPECIFIED = 'HARM_CATEGORY_UNSPECIFIED'422  """Default value. This value is unused."""423  HARM_CATEGORY_HARASSMENT = 'HARM_CATEGORY_HARASSMENT'424  """Abusive, threatening, or content intended to bully, torment, or ridicule."""425  HARM_CATEGORY_HATE_SPEECH = 'HARM_CATEGORY_HATE_SPEECH'426  """Content that promotes violence or incites hatred against individuals or groups based on certain attributes."""427  HARM_CATEGORY_SEXUALLY_EXPLICIT = 'HARM_CATEGORY_SEXUALLY_EXPLICIT'428  """Content that contains sexually explicit material."""429  HARM_CATEGORY_DANGEROUS_CONTENT = 'HARM_CATEGORY_DANGEROUS_CONTENT'430  """Content that promotes, facilitates, or enables dangerous activities."""431  HARM_CATEGORY_CIVIC_INTEGRITY = 'HARM_CATEGORY_CIVIC_INTEGRITY'432  """Deprecated: Election filter is not longer supported. The harm category is civic integrity."""433  HARM_CATEGORY_JAILBREAK = 'HARM_CATEGORY_JAILBREAK'434  """Prompts designed to bypass safety filters."""435  HARM_CATEGORY_IMAGE_HATE = 'HARM_CATEGORY_IMAGE_HATE'436  """Images that contain hate speech. This enum value is not supported in Gemini API."""437  HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT = (438      'HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT'439  )440  """Images that contain dangerous content. This enum value is not supported in Gemini API."""441  HARM_CATEGORY_IMAGE_HARASSMENT = 'HARM_CATEGORY_IMAGE_HARASSMENT'442  """Images that contain harassment. This enum value is not supported in Gemini API."""443  HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT = (444      'HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT'445  )446  """Images that contain sexually explicit content. This enum value is not supported in Gemini API."""447448449class HarmBlockMethod(_common.CaseInSensitiveEnum):450  """The method for blocking content.451452  If not specified, the default behavior is to use the probability score. This453  enum is not supported in Gemini API.454  """455456  HARM_BLOCK_METHOD_UNSPECIFIED = 'HARM_BLOCK_METHOD_UNSPECIFIED'457  """The harm block method is unspecified."""458  SEVERITY = 'SEVERITY'459  """The harm block method uses both probability and severity scores."""460  PROBABILITY = 'PROBABILITY'461  """The harm block method uses the probability score."""462463464class HarmBlockThreshold(_common.CaseInSensitiveEnum):465  """The threshold for blocking content.466467  If the harm probability exceeds this threshold, the content will be blocked.468  """469470  HARM_BLOCK_THRESHOLD_UNSPECIFIED = 'HARM_BLOCK_THRESHOLD_UNSPECIFIED'471  """The harm block threshold is unspecified."""472  BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE'473  """Block content with a low harm probability or higher."""474  BLOCK_MEDIUM_AND_ABOVE = 'BLOCK_MEDIUM_AND_ABOVE'475  """Block content with a medium harm probability or higher."""476  BLOCK_ONLY_HIGH = 'BLOCK_ONLY_HIGH'477  """Block content with a high harm probability."""478  BLOCK_NONE = 'BLOCK_NONE'479  """Do not block any content, regardless of its harm probability."""480  OFF = 'OFF'481  """Turn off the safety filter entirely."""482483484class FunctionCallingConfigMode(_common.CaseInSensitiveEnum):485  """Function calling mode."""486487  MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'488  """Unspecified function calling mode. This value should not be used."""489  AUTO = 'AUTO'490  """Default model behavior, model decides to predict either function calls or natural language response."""491  ANY = 'ANY'492  """Model is constrained to always predicting function calls only. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations"."""493  NONE = 'NONE'494  """Model will not predict any function calls. Model behavior is same as when not passing any function declarations."""495  VALIDATED = 'VALIDATED'496  """Model is constrained to predict either function calls or natural language response. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations"."""497498499class AudioTranscriptionConfigMode(_common.CaseInSensitiveEnum):500  """Transcription mode."""501502  MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'503  """Unspecified transcription mode."""504  VERBATIM = 'VERBATIM'505  """Verbatim transcription mode."""506  SMART = 'SMART'507  """Smart transcription mode."""508509510class FinishReason(_common.CaseInSensitiveEnum):511  """Output only. The reason why the model stopped generating tokens.512513  If empty, the model has not stopped generating the tokens.514  """515516  FINISH_REASON_UNSPECIFIED = 'FINISH_REASON_UNSPECIFIED'517  """The finish reason is unspecified."""518  STOP = 'STOP'519  """Token generation reached a natural stopping point or a configured stop sequence."""520  MAX_TOKENS = 'MAX_TOKENS'521  """Token generation reached the configured maximum output tokens."""522  SAFETY = 'SAFETY'523  """Token generation stopped because the content potentially contains safety violations. NOTE: When streaming, [content][] is empty if content filters blocks the output."""524  RECITATION = 'RECITATION'525  """The token generation stopped because of potential recitation."""526  LANGUAGE = 'LANGUAGE'527  """The token generation stopped because of using an unsupported language."""528  OTHER = 'OTHER'529  """All other reasons that stopped the token generation."""530  BLOCKLIST = 'BLOCKLIST'531  """Token generation stopped because the content contains forbidden terms."""532  PROHIBITED_CONTENT = 'PROHIBITED_CONTENT'533  """Token generation stopped for potentially containing prohibited content."""534  SPII = 'SPII'535  """Token generation stopped because the content potentially contains Sensitive Personally Identifiable Information (SPII)."""536  MALFORMED_FUNCTION_CALL = 'MALFORMED_FUNCTION_CALL'537  """The function call generated by the model is invalid."""538  IMAGE_SAFETY = 'IMAGE_SAFETY'539  """Token generation stopped because generated images have safety violations."""540  UNEXPECTED_TOOL_CALL = 'UNEXPECTED_TOOL_CALL'541  """The tool call generated by the model is invalid."""542  TOO_MANY_TOOL_CALLS = 'TOO_MANY_TOOL_CALLS'543  """Model called too many tools consecutively, thus the system exited execution."""544  IMAGE_PROHIBITED_CONTENT = 'IMAGE_PROHIBITED_CONTENT'545  """Image generation stopped because the generated images have prohibited content."""546  NO_IMAGE = 'NO_IMAGE'547  """The model was expected to generate an image, but none was generated."""548  IMAGE_RECITATION = 'IMAGE_RECITATION'549  """Image generation stopped because the generated image may be a recitation from a source."""550  IMAGE_OTHER = 'IMAGE_OTHER'551  """Image generation stopped for a reason not otherwise specified."""552553554class HarmProbability(_common.CaseInSensitiveEnum):555  """Output only. The probability of harm for this category."""556557  HARM_PROBABILITY_UNSPECIFIED = 'HARM_PROBABILITY_UNSPECIFIED'558  """The harm probability is unspecified."""559  NEGLIGIBLE = 'NEGLIGIBLE'560  """The harm probability is negligible."""561  LOW = 'LOW'562  """The harm probability is low."""563  MEDIUM = 'MEDIUM'564  """The harm probability is medium."""565  HIGH = 'HIGH'566  """The harm probability is high."""567568569class HarmSeverity(_common.CaseInSensitiveEnum):570  """Output only.571572  The severity of harm for this category. This enum is not supported in Gemini573  API.574  """575576  HARM_SEVERITY_UNSPECIFIED = 'HARM_SEVERITY_UNSPECIFIED'577  """The harm severity is unspecified."""578  HARM_SEVERITY_NEGLIGIBLE = 'HARM_SEVERITY_NEGLIGIBLE'579  """The harm severity is negligible."""580  HARM_SEVERITY_LOW = 'HARM_SEVERITY_LOW'581  """The harm severity is low."""582  HARM_SEVERITY_MEDIUM = 'HARM_SEVERITY_MEDIUM'583  """The harm severity is medium."""584  HARM_SEVERITY_HIGH = 'HARM_SEVERITY_HIGH'585  """The harm severity is high."""586587588class UrlRetrievalStatus(_common.CaseInSensitiveEnum):589  """The status of the URL retrieval."""590591  URL_RETRIEVAL_STATUS_UNSPECIFIED = 'URL_RETRIEVAL_STATUS_UNSPECIFIED'592  """Default value. This value is unused."""593  URL_RETRIEVAL_STATUS_SUCCESS = 'URL_RETRIEVAL_STATUS_SUCCESS'594  """The URL was retrieved successfully."""595  URL_RETRIEVAL_STATUS_ERROR = 'URL_RETRIEVAL_STATUS_ERROR'596  """The URL retrieval failed."""597  URL_RETRIEVAL_STATUS_PAYWALL = 'URL_RETRIEVAL_STATUS_PAYWALL'598  """Url retrieval is failed because the content is behind paywall. This enum value is not supported in Vertex AI."""599  URL_RETRIEVAL_STATUS_UNSAFE = 'URL_RETRIEVAL_STATUS_UNSAFE'600  """Url retrieval is failed because the content is unsafe. This enum value is not supported in Vertex AI."""601602603class BlockedReason(_common.CaseInSensitiveEnum):604  """Output only. The reason why the prompt was blocked."""605606  BLOCKED_REASON_UNSPECIFIED = 'BLOCKED_REASON_UNSPECIFIED'607  """The blocked reason is unspecified."""608  SAFETY = 'SAFETY'609  """The prompt was blocked for safety reasons."""610  OTHER = 'OTHER'611  """The prompt was blocked for other reasons. For example, it may be due to the prompt's language, or because it contains other harmful content."""612  BLOCKLIST = 'BLOCKLIST'613  """The prompt was blocked because it contains a term from the terminology blocklist."""614  PROHIBITED_CONTENT = 'PROHIBITED_CONTENT'615  """The prompt was blocked because it contains prohibited content."""616  IMAGE_SAFETY = 'IMAGE_SAFETY'617  """The prompt was blocked because it contains content that is unsafe for image generation."""618  MODEL_ARMOR = 'MODEL_ARMOR'619  """The prompt was blocked by Model Armor. This enum value is not supported in Gemini API."""620  JAILBREAK = 'JAILBREAK'621  """The prompt was blocked as a jailbreak attempt. This enum value is not supported in Gemini API."""622623624class TrafficType(_common.CaseInSensitiveEnum):625  """Output only.626627  The traffic type for this request. This enum is not supported in Gemini API.628  """629630  TRAFFIC_TYPE_UNSPECIFIED = 'TRAFFIC_TYPE_UNSPECIFIED'631  """Unspecified request traffic type."""632  ON_DEMAND = 'ON_DEMAND'633  """The request was processed using Pay-As-You-Go quota."""634  ON_DEMAND_PRIORITY = 'ON_DEMAND_PRIORITY'635  """Type for Priority Pay-As-You-Go traffic."""636  ON_DEMAND_FLEX = 'ON_DEMAND_FLEX'637  """Type for Flex traffic."""638  ON_DEMAND_OFFPEAK = 'ON_DEMAND_OFFPEAK'639  """Type for Off-Peak Pay-As-You-Go traffic."""640  PROVISIONED_THROUGHPUT = 'PROVISIONED_THROUGHPUT'641  """Type for Provisioned Throughput traffic."""642643644class MediaModality(_common.CaseInSensitiveEnum):645  """The modality that this token count applies to."""646647  MODALITY_UNSPECIFIED = 'MODALITY_UNSPECIFIED'648  """When a modality is not specified, it is treated as `TEXT`."""649  TEXT = 'TEXT'650  """The `Part` contains plain text."""651  IMAGE = 'IMAGE'652  """The `Part` contains an image."""653  VIDEO = 'VIDEO'654  """The `Part` contains a video."""655  AUDIO = 'AUDIO'656  """The `Part` contains audio."""657  DOCUMENT = 'DOCUMENT'658  """The `Part` contains a document, such as a PDF."""659660661class ModelStage(_common.CaseInSensitiveEnum):662  """The stage of the underlying model.663664  This enum is not supported in Vertex AI.665  """666667  MODEL_STAGE_UNSPECIFIED = 'MODEL_STAGE_UNSPECIFIED'668  """Unspecified model stage."""669  UNSTABLE_EXPERIMENTAL = 'UNSTABLE_EXPERIMENTAL'670  """The underlying model is subject to lots of tunings."""671  EXPERIMENTAL = 'EXPERIMENTAL'672  """Models in this stage are for experimental purposes only."""673  PREVIEW = 'PREVIEW'674  """Models in this stage are more mature than experimental models."""675  STABLE = 'STABLE'676  """Models in this stage are considered stable and ready for production use."""677  LEGACY = 'LEGACY'678  """If the model is on this stage, it means that this model is on the path to deprecation in near future. Only existing customers can use this model."""679  DEPRECATED = 'DEPRECATED'680  """Models in this stage are deprecated. These models cannot be used."""681  RETIRED = 'RETIRED'682  """Models in this stage are retired. These models cannot be used."""683684685class MediaResolution(_common.CaseInSensitiveEnum):686  """The media resolution to use."""687688  MEDIA_RESOLUTION_UNSPECIFIED = 'MEDIA_RESOLUTION_UNSPECIFIED'689  """Media resolution has not been set"""690  MEDIA_RESOLUTION_LOW = 'MEDIA_RESOLUTION_LOW'691  """Media resolution set to low (64 tokens)."""692  MEDIA_RESOLUTION_MEDIUM = 'MEDIA_RESOLUTION_MEDIUM'693  """Media resolution set to medium (256 tokens)."""694  MEDIA_RESOLUTION_HIGH = 'MEDIA_RESOLUTION_HIGH'695  """Media resolution set to high (zoomed reframing with 256 tokens)."""696697698class Modality(_common.CaseInSensitiveEnum):699  """Server content modalities."""700701  MODALITY_UNSPECIFIED = 'MODALITY_UNSPECIFIED'702  """The modality is unspecified."""703  TEXT = 'TEXT'704  """Indicates the model should return text"""705  IMAGE = 'IMAGE'706  """Indicates the model should return images."""707  AUDIO = 'AUDIO'708  """Indicates the model should return audio."""709  VIDEO = 'VIDEO'710  """Indicates the model should return video."""711712713class Delivery(_common.CaseInSensitiveEnum):714  """Delivery mode for the generated content."""715716  DELIVERY_UNSPECIFIED = 'DELIVERY_UNSPECIFIED'717  """Default value. This value is unused."""718  INLINE = 'INLINE'719  """Generated bytes are returned inline in the response."""720  URI = 'URI'721  """Generated content is stored and a URI is returned."""722723724class AspectRatio(_common.CaseInSensitiveEnum):725  """The aspect ratio for the image output."""726727  ASPECT_RATIO_UNSPECIFIED = 'ASPECT_RATIO_UNSPECIFIED'728  """Default value. This value is unused."""729  ASPECT_RATIO_ONE_BY_ONE = 'ASPECT_RATIO_ONE_BY_ONE'730  """1:1 aspect ratio."""731  ASPECT_RATIO_TWO_BY_THREE = 'ASPECT_RATIO_TWO_BY_THREE'732  """2:3 aspect ratio."""733  ASPECT_RATIO_THREE_BY_TWO = 'ASPECT_RATIO_THREE_BY_TWO'734  """3:2 aspect ratio."""735  ASPECT_RATIO_THREE_BY_FOUR = 'ASPECT_RATIO_THREE_BY_FOUR'736  """3:4 aspect ratio."""737  ASPECT_RATIO_FOUR_BY_THREE = 'ASPECT_RATIO_FOUR_BY_THREE'738  """4:3 aspect ratio."""739  ASPECT_RATIO_FOUR_BY_FIVE = 'ASPECT_RATIO_FOUR_BY_FIVE'740  """4:5 aspect ratio."""741  ASPECT_RATIO_FIVE_BY_FOUR = 'ASPECT_RATIO_FIVE_BY_FOUR'742  """5:4 aspect ratio."""743  ASPECT_RATIO_NINE_BY_SIXTEEN = 'ASPECT_RATIO_NINE_BY_SIXTEEN'744  """9:16 aspect ratio."""745  ASPECT_RATIO_SIXTEEN_BY_NINE = 'ASPECT_RATIO_SIXTEEN_BY_NINE'746  """16:9 aspect ratio."""747  ASPECT_RATIO_TWENTY_ONE_BY_NINE = 'ASPECT_RATIO_TWENTY_ONE_BY_NINE'748  """21:9 aspect ratio."""749  ASPECT_RATIO_ONE_BY_EIGHT = 'ASPECT_RATIO_ONE_BY_EIGHT'750  """1:8 aspect ratio."""751  ASPECT_RATIO_EIGHT_BY_ONE = 'ASPECT_RATIO_EIGHT_BY_ONE'752  """8:1 aspect ratio."""753  ASPECT_RATIO_ONE_BY_FOUR = 'ASPECT_RATIO_ONE_BY_FOUR'754  """1:4 aspect ratio."""755  ASPECT_RATIO_FOUR_BY_ONE = 'ASPECT_RATIO_FOUR_BY_ONE'756  """4:1 aspect ratio."""757758759class ImageSize(_common.CaseInSensitiveEnum):760  """The size of the image output."""761762  IMAGE_SIZE_UNSPECIFIED = 'IMAGE_SIZE_UNSPECIFIED'763  """Default value. This value is unused."""764  IMAGE_SIZE_FIVE_TWELVE = 'IMAGE_SIZE_FIVE_TWELVE'765  """512px image size."""766  IMAGE_SIZE_ONE_K = 'IMAGE_SIZE_ONE_K'767  """1K image size."""768  IMAGE_SIZE_TWO_K = 'IMAGE_SIZE_TWO_K'769  """2K image size."""770  IMAGE_SIZE_FOUR_K = 'IMAGE_SIZE_FOUR_K'771  """4K image size."""772773774class TuningMode(_common.CaseInSensitiveEnum):775  """Tuning mode. This enum is not supported in Gemini API."""776777  TUNING_MODE_UNSPECIFIED = 'TUNING_MODE_UNSPECIFIED'778  """Tuning mode is unspecified."""779  TUNING_MODE_FULL = 'TUNING_MODE_FULL'780  """Full fine-tuning mode."""781  TUNING_MODE_PEFT_ADAPTER = 'TUNING_MODE_PEFT_ADAPTER'782  """PEFT adapter tuning mode."""783784785class AdapterSize(_common.CaseInSensitiveEnum):786  """Adapter size for tuning. This enum is not supported in Gemini API."""787788  ADAPTER_SIZE_UNSPECIFIED = 'ADAPTER_SIZE_UNSPECIFIED'789  """Adapter size is unspecified."""790  ADAPTER_SIZE_ONE = 'ADAPTER_SIZE_ONE'791  """Adapter size 1."""792  ADAPTER_SIZE_TWO = 'ADAPTER_SIZE_TWO'793  """Adapter size 2."""794  ADAPTER_SIZE_FOUR = 'ADAPTER_SIZE_FOUR'795  """Adapter size 4."""796  ADAPTER_SIZE_EIGHT = 'ADAPTER_SIZE_EIGHT'797  """Adapter size 8."""798  ADAPTER_SIZE_SIXTEEN = 'ADAPTER_SIZE_SIXTEEN'799  """Adapter size 16."""800  ADAPTER_SIZE_THIRTY_TWO = 'ADAPTER_SIZE_THIRTY_TWO'801  """Adapter size 32."""802803804class ResponseParseType(_common.CaseInSensitiveEnum):805  """Defines the type for parsing sample response.806807  This enum is not supported in Gemini API.808  """809810  RESPONSE_PARSE_TYPE_UNSPECIFIED = 'RESPONSE_PARSE_TYPE_UNSPECIFIED'811  """Default value. Fallback to IDENTITY"""812  IDENTITY = 'IDENTITY'813  """Returns the sample response as is."""814  REGEX_EXTRACT = 'REGEX_EXTRACT'815  """Uses regex to extract the important part of sample response. Similar to [GoogleSQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_extract) `REGEX_EXTRACT(response, regex_extract_expression)`, but different in that if there are multiple matches, the last match will be returned."""816817818class MatchOperation(_common.CaseInSensitiveEnum):819  """Match operation to use for evaluating rewards.820821  This enum is not supported in Gemini API.822  """823824  MATCH_OPERATION_UNSPECIFIED = 'MATCH_OPERATION_UNSPECIFIED'825  """Default value. A user error will be returned if not set."""826  REGEX_CONTAINS = 'REGEX_CONTAINS'827  """Equivalent to [GoogleSQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_contains) `REGEX_CONTAINS(target, expression)`."""828  PARTIAL_MATCH = 'PARTIAL_MATCH'829  """The match operation returns `true` if expression is a substring of the target."""830  EXACT_MATCH = 'EXACT_MATCH'831  """The match operation returns `true` expression is an exact match of the target."""832833834class ReinforcementTuningThinkingLevel(_common.CaseInSensitiveEnum):835  """Represents how much to think for the tuning job."""836837  REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED = (838      'REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED'839  )840  """Unspecified thinking level."""841  MINIMAL = 'MINIMAL'842  """Little to no thinking."""843  HIGH = 'HIGH'844  """High thinking level."""845846847class JobState(_common.CaseInSensitiveEnum):848  """Job state."""849850  JOB_STATE_UNSPECIFIED = 'JOB_STATE_UNSPECIFIED'851  """The job state is unspecified."""852  JOB_STATE_QUEUED = 'JOB_STATE_QUEUED'853  """The job has been just created or resumed and processing has not yet begun."""854  JOB_STATE_PENDING = 'JOB_STATE_PENDING'855  """The service is preparing to run the job."""856  JOB_STATE_RUNNING = 'JOB_STATE_RUNNING'857  """The job is in progress."""858  JOB_STATE_SUCCEEDED = 'JOB_STATE_SUCCEEDED'859  """The job completed successfully."""860  JOB_STATE_FAILED = 'JOB_STATE_FAILED'861  """The job failed."""862  JOB_STATE_CANCELLING = 'JOB_STATE_CANCELLING'863  """The job is being cancelled. From this state the job may only go to either `JOB_STATE_SUCCEEDED`, `JOB_STATE_FAILED` or `JOB_STATE_CANCELLED`."""864  JOB_STATE_CANCELLED = 'JOB_STATE_CANCELLED'865  """The job has been cancelled."""866  JOB_STATE_PAUSED = 'JOB_STATE_PAUSED'867  """The job has been stopped, and can be resumed."""868  JOB_STATE_EXPIRED = 'JOB_STATE_EXPIRED'869  """The job has expired."""870  JOB_STATE_UPDATING = 'JOB_STATE_UPDATING'871  """The job is being updated. Only jobs in the `JOB_STATE_RUNNING` state can be updated. After updating, the job goes back to the `JOB_STATE_RUNNING` state."""872  JOB_STATE_PARTIALLY_SUCCEEDED = 'JOB_STATE_PARTIALLY_SUCCEEDED'873  """The job is partially succeeded, some results may be missing due to errors."""874875876class TuningJobState(_common.CaseInSensitiveEnum):877  """Output only.878879  The detail state of the tuning job (while the overall `JobState` is running).880  This enum is not supported in Gemini API.881  """882883  TUNING_JOB_STATE_UNSPECIFIED = 'TUNING_JOB_STATE_UNSPECIFIED'884  """Default tuning job state."""885  TUNING_JOB_STATE_WAITING_FOR_QUOTA = 'TUNING_JOB_STATE_WAITING_FOR_QUOTA'886  """Tuning job is waiting for job quota."""887  TUNING_JOB_STATE_PROCESSING_DATASET = 'TUNING_JOB_STATE_PROCESSING_DATASET'888  """Tuning job is validating the dataset."""889  TUNING_JOB_STATE_WAITING_FOR_CAPACITY = (890      'TUNING_JOB_STATE_WAITING_FOR_CAPACITY'891  )892  """Tuning job is waiting for hardware capacity."""893  TUNING_JOB_STATE_TUNING = 'TUNING_JOB_STATE_TUNING'894  """Tuning job is running."""895  TUNING_JOB_STATE_POST_PROCESSING = 'TUNING_JOB_STATE_POST_PROCESSING'896  """Tuning job is doing some post processing steps."""897898899class AggregationMetric(_common.CaseInSensitiveEnum):900  """Aggregation metric. This enum is not supported in Gemini API."""901902  AGGREGATION_METRIC_UNSPECIFIED = 'AGGREGATION_METRIC_UNSPECIFIED'903  """Unspecified aggregation metric."""904  AVERAGE = 'AVERAGE'905  """Average aggregation metric. Not supported for Pairwise metric."""906  MODE = 'MODE'907  """Mode aggregation metric."""908  STANDARD_DEVIATION = 'STANDARD_DEVIATION'909  """Standard deviation aggregation metric. Not supported for pairwise metric."""910  VARIANCE = 'VARIANCE'911  """Variance aggregation metric. Not supported for pairwise metric."""912  MINIMUM = 'MINIMUM'913  """Minimum aggregation metric. Not supported for pairwise metric."""914  MAXIMUM = 'MAXIMUM'915  """Maximum aggregation metric. Not supported for pairwise metric."""916  MEDIAN = 'MEDIAN'917  """Median aggregation metric. Not supported for pairwise metric."""918  PERCENTILE_P90 = 'PERCENTILE_P90'919  """90th percentile aggregation metric. Not supported for pairwise metric."""920  PERCENTILE_P95 = 'PERCENTILE_P95'921  """95th percentile aggregation metric. Not supported for pairwise metric."""922  PERCENTILE_P99 = 'PERCENTILE_P99'923  """99th percentile aggregation metric. Not supported for pairwise metric."""924925926class PairwiseChoice(_common.CaseInSensitiveEnum):927  """Output only.928929  Pairwise metric choice. This enum is not supported in Gemini API.930  """931932  PAIRWISE_CHOICE_UNSPECIFIED = 'PAIRWISE_CHOICE_UNSPECIFIED'933  """Unspecified prediction choice."""934  BASELINE = 'BASELINE'935  """Baseline prediction wins"""936  CANDIDATE = 'CANDIDATE'937  """Candidate prediction wins"""938  TIE = 'TIE'939  """Winner cannot be determined"""940941942class TuningSpeed(_common.CaseInSensitiveEnum):943  """The speed of the tuning job.944945  Only supported for Veo 3.0 models. This enum is not supported in Gemini API.946  """947948  TUNING_SPEED_UNSPECIFIED = 'TUNING_SPEED_UNSPECIFIED'949  """The default / unset value. For Veo 3.0 models, this defaults to FAST."""950  REGULAR = 'REGULAR'951  """Regular tuning speed."""952  FAST = 'FAST'953  """Fast tuning speed."""954955956class TuningTask(_common.CaseInSensitiveEnum):957  """The tuning task for Veo. This enum is not supported in Gemini API."""958959  TUNING_TASK_UNSPECIFIED = 'TUNING_TASK_UNSPECIFIED'960  """Default value. This value is unused."""961  TUNING_TASK_I2V = 'TUNING_TASK_I2V'962  """Tuning task for image to video."""963  TUNING_TASK_T2V = 'TUNING_TASK_T2V'964  """Tuning task for text to video."""965  TUNING_TASK_R2V = 'TUNING_TASK_R2V'966  """Tuning task for reference to video."""967968969class VideoOrientation(_common.CaseInSensitiveEnum):970  """The orientation of the video.971972  Defaults to LANDSCAPE. This enum is not supported in Gemini API.973  """974975  VIDEO_ORIENTATION_UNSPECIFIED = 'VIDEO_ORIENTATION_UNSPECIFIED'976  """Unspecified video orientation. Defaults to landscape."""977  LANDSCAPE = 'LANDSCAPE'978  """Landscape orientation (e.g. 16:9, 1280x720)."""979  PORTRAIT = 'PORTRAIT'980  """Portrait orientation (e.g. 9:16, 720x1280)."""981982983class DocumentState(_common.CaseInSensitiveEnum):984  """Output only.985986  Current state of the `Document`. This enum is not supported in Vertex AI.987  """988989  STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'990  """The default value. This value is used if the state is omitted."""991  STATE_PENDING = 'STATE_PENDING'992  """Some `Chunks` of the `Document` are being processed (embedding and vector storage)."""993  STATE_ACTIVE = 'STATE_ACTIVE'994  """All `Chunks` of the `Document` is processed and available for querying."""995  STATE_FAILED = 'STATE_FAILED'996  """Some `Chunks` of the `Document` failed processing."""997998999class ServiceTier(_common.CaseInSensitiveEnum):1000  """Pricing and performance service tier."""10011002  UNSPECIFIED = 'unspecified'1003  """Default service tier, which is standard."""1004  FLEX = 'flex'1005  """Flex service tier."""1006  STANDARD = 'standard'1007  """Standard service tier."""1008  PRIORITY = 'priority'1009  """Priority service tier."""101010111012class RubricContentType(_common.CaseInSensitiveEnum):1013  """Represents the rubric content type."""10141015  RUBRIC_CONTENT_TYPE_UNSPECIFIED = 'RUBRIC_CONTENT_TYPE_UNSPECIFIED'1016  """Rubric content type is unspecified."""1017  PROPERTY = 'PROPERTY'1018  """Generate rubrics based on properties."""1019  NL_QUESTION_ANSWER = 'NL_QUESTION_ANSWER'1020  """Generate rubrics in an NL question answer format."""1021  PYTHON_CODE_ASSERTION = 'PYTHON_CODE_ASSERTION'1022  """Generate rubrics in a unit test format."""102310241025class ComputationBasedMetricType(_common.CaseInSensitiveEnum):1026  """Represents the type of the computation based metric."""10271028  COMPUTATION_BASED_METRIC_TYPE_UNSPECIFIED = (1029      'COMPUTATION_BASED_METRIC_TYPE_UNSPECIFIED'1030  )1031  """Computation based metric type is unspecified."""1032  EXACT_MATCH = 'EXACT_MATCH'1033  """Exact match metric."""1034  BLEU = 'BLEU'1035  """BLEU metric."""1036  ROUGE = 'ROUGE'1037  """ROUGE metric."""103810391040class PartMediaResolutionLevel(_common.CaseInSensitiveEnum):1041  """The tokenization quality used for given media."""10421043  MEDIA_RESOLUTION_UNSPECIFIED = 'MEDIA_RESOLUTION_UNSPECIFIED'1044  """Media resolution has not been set."""1045  MEDIA_RESOLUTION_LOW = 'MEDIA_RESOLUTION_LOW'1046  """Media resolution set to low."""1047  MEDIA_RESOLUTION_MEDIUM = 'MEDIA_RESOLUTION_MEDIUM'1048  """Media resolution set to medium."""1049  MEDIA_RESOLUTION_HIGH = 'MEDIA_RESOLUTION_HIGH'1050  """Media resolution set to high."""1051  MEDIA_RESOLUTION_ULTRA_HIGH = 'MEDIA_RESOLUTION_ULTRA_HIGH'1052  """Media resolution set to ultra high."""105310541055class ToolType(_common.CaseInSensitiveEnum):1056  """The type of tool in the function call."""10571058  TOOL_TYPE_UNSPECIFIED = 'TOOL_TYPE_UNSPECIFIED'1059  """Unspecified tool type."""1060  GOOGLE_SEARCH_WEB = 'GOOGLE_SEARCH_WEB'1061  """Google search tool, maps to Tool.google_search.search_types.web_search."""1062  GOOGLE_SEARCH_IMAGE = 'GOOGLE_SEARCH_IMAGE'1063  """Image search tool, maps to Tool.google_search.search_types.image_search."""1064  URL_CONTEXT = 'URL_CONTEXT'1065  """URL context tool, maps to Tool.url_context."""1066  GOOGLE_MAPS = 'GOOGLE_MAPS'1067  """Google maps tool, maps to Tool.google_maps."""1068  FILE_SEARCH = 'FILE_SEARCH'1069  """File search tool, maps to Tool.file_search."""1070  MEDIA_PROCESSING = 'MEDIA_PROCESSING'1071  """Media processing tool."""107210731074class ResourceScope(_common.CaseInSensitiveEnum):1075  """Resource scope."""10761077  COLLECTION = 'COLLECTION'1078  """When setting base_url, this value configures resource scope to be the collection.1079      The resource name will not include api version, project, or location.1080      For example, if base_url is set to "https://aiplatform.googleapis.com",1081      then the resource name for a Model would be1082      "https://aiplatform.googleapis.com/publishers/google/models/gemini-3-pro-preview"""108310841085class JSONSchemaType(Enum):1086  """The type of the data supported by JSON Schema.10871088  The values of the enums are lower case strings, while the values of the enums1089  for the Type class are upper case strings.1090  """10911092  NULL = 'null'1093  BOOLEAN = 'boolean'1094  OBJECT = 'object'1095  ARRAY = 'array'1096  NUMBER = 'number'1097  INTEGER = 'integer'1098  STRING = 'string'109911001101class FeatureSelectionPreference(_common.CaseInSensitiveEnum):1102  """Options for feature selection preference."""11031104  FEATURE_SELECTION_PREFERENCE_UNSPECIFIED = (1105      'FEATURE_SELECTION_PREFERENCE_UNSPECIFIED'1106  )1107  PRIORITIZE_QUALITY = 'PRIORITIZE_QUALITY'1108  BALANCED = 'BALANCED'1109  PRIORITIZE_COST = 'PRIORITIZE_COST'111011111112class EmbeddingApiType(_common.CaseInSensitiveEnum):1113  """Enum representing the Gemini Enterprise Agent Platform embedding API to use."""11141115  PREDICT = 'PREDICT'1116  """predict API endpoint (default)"""1117  EMBED_CONTENT = 'EMBED_CONTENT'1118  """embedContent API Endpoint"""111911201121class SafetyFilterLevel(_common.CaseInSensitiveEnum):1122  """Enum that controls the safety filter level for objectionable content."""11231124  BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE'1125  BLOCK_MEDIUM_AND_ABOVE = 'BLOCK_MEDIUM_AND_ABOVE'1126  BLOCK_ONLY_HIGH = 'BLOCK_ONLY_HIGH'1127  BLOCK_NONE = 'BLOCK_NONE'112811291130class ImagePromptLanguage(_common.CaseInSensitiveEnum):1131  """Enum that specifies the language of the text in the prompt."""11321133  auto = 'auto'1134  """Auto-detect the language."""1135  en = 'en'1136  """English"""1137  ja = 'ja'1138  """Japanese"""1139  ko = 'ko'1140  """Korean"""1141  hi = 'hi'1142  """Hindi"""1143  zh = 'zh'1144  """Chinese"""1145  pt = 'pt'1146  """Portuguese"""1147  es = 'es'1148  """Spanish"""114911501151class MaskReferenceMode(_common.CaseInSensitiveEnum):1152  """Enum representing the mask mode of a mask reference image."""11531154  MASK_MODE_DEFAULT = 'MASK_MODE_DEFAULT'1155  MASK_MODE_USER_PROVIDED = 'MASK_MODE_USER_PROVIDED'1156  MASK_MODE_BACKGROUND = 'MASK_MODE_BACKGROUND'1157  MASK_MODE_FOREGROUND = 'MASK_MODE_FOREGROUND'1158  MASK_MODE_SEMANTIC = 'MASK_MODE_SEMANTIC'115911601161class ControlReferenceType(_common.CaseInSensitiveEnum):1162  """Enum representing the control type of a control reference image."""11631164  CONTROL_TYPE_DEFAULT = 'CONTROL_TYPE_DEFAULT'1165  CONTROL_TYPE_CANNY = 'CONTROL_TYPE_CANNY'1166  CONTROL_TYPE_SCRIBBLE = 'CONTROL_TYPE_SCRIBBLE'1167  CONTROL_TYPE_FACE_MESH = 'CONTROL_TYPE_FACE_MESH'116811691170class SubjectReferenceType(_common.CaseInSensitiveEnum):1171  """Enum representing the subject type of a subject reference image."""11721173  SUBJECT_TYPE_DEFAULT = 'SUBJECT_TYPE_DEFAULT'1174  SUBJECT_TYPE_PERSON = 'SUBJECT_TYPE_PERSON'1175  SUBJECT_TYPE_ANIMAL = 'SUBJECT_TYPE_ANIMAL'1176  SUBJECT_TYPE_PRODUCT = 'SUBJECT_TYPE_PRODUCT'117711781179class EditMode(_common.CaseInSensitiveEnum):1180  """Enum representing the editing mode."""11811182  EDIT_MODE_DEFAULT = 'EDIT_MODE_DEFAULT'1183  EDIT_MODE_INPAINT_REMOVAL = 'EDIT_MODE_INPAINT_REMOVAL'1184  EDIT_MODE_INPAINT_INSERTION = 'EDIT_MODE_INPAINT_INSERTION'1185  EDIT_MODE_OUTPAINT = 'EDIT_MODE_OUTPAINT'1186  EDIT_MODE_CONTROLLED_EDITING = 'EDIT_MODE_CONTROLLED_EDITING'1187  EDIT_MODE_STYLE = 'EDIT_MODE_STYLE'1188  EDIT_MODE_BGSWAP = 'EDIT_MODE_BGSWAP'1189  EDIT_MODE_PRODUCT_IMAGE = 'EDIT_MODE_PRODUCT_IMAGE'119011911192class SegmentMode(_common.CaseInSensitiveEnum):1193  """Enum that represents the segmentation mode."""11941195  FOREGROUND = 'FOREGROUND'1196  BACKGROUND = 'BACKGROUND'1197  PROMPT = 'PROMPT'1198  SEMANTIC = 'SEMANTIC'1199  INTERACTIVE = 'INTERACTIVE'120012011202class VideoGenerationReferenceType(_common.CaseInSensitiveEnum):1203  """Enum for the reference type of a video generation reference image."""12041205  ASSET = 'ASSET'1206  """A reference image that provides assets to the generated video,1207      such as the scene, an object, a character, etc."""1208  STYLE = 'STYLE'1209  """A reference image that provides aesthetics including colors,1210      lighting, texture, etc., to be used as the style of the generated video,1211      such as 'anime', 'photography', 'origami', etc."""121212131214class VideoGenerationMaskMode(_common.CaseInSensitiveEnum):1215  """Enum for the mask mode of a video generation mask."""12161217  INSERT = 'INSERT'1218  """The image mask contains a masked rectangular region which is1219      applied on the first frame of the input video. The object described in1220      the prompt is inserted into this region and will appear in subsequent1221      frames."""1222  REMOVE = 'REMOVE'1223  """The image mask is used to determine an object in the1224      first video frame to track. This object is removed from the video."""1225  REMOVE_STATIC = 'REMOVE_STATIC'1226  """The image mask is used to determine a region in the1227      video. Objects in this region will be removed."""1228  OUTPAINT = 'OUTPAINT'1229  """The image mask contains a masked rectangular region where1230      the input video will go. The remaining area will be generated. Video1231      masks are not supported."""123212331234class VideoCompressionQuality(_common.CaseInSensitiveEnum):1235  """Enum that controls the compression quality of the generated videos."""12361237  OPTIMIZED = 'OPTIMIZED'1238  """Optimized video compression quality. This will produce videos1239      with a compressed, smaller file size."""1240  LOSSLESS = 'LOSSLESS'1241  """Lossless video compression quality. This will produce videos1242      with a larger file size."""124312441245class ImageResizeMode(_common.CaseInSensitiveEnum):1246  """Resize mode for the image input for video generation."""12471248  CROP = 'CROP'1249  """Crop the image to fit the correct aspect ratio (so we lose parts1250      of the image in the process)."""1251  PAD = 'PAD'1252  """Pad the image to fit the correct aspect ratio (so we don't lose1253      any parts of the image in the process)."""125412551256class TuningMethod(_common.CaseInSensitiveEnum):1257  """Enum representing the tuning method."""12581259  SUPERVISED_FINE_TUNING = 'SUPERVISED_FINE_TUNING'1260  """Supervised fine tuning."""1261  PREFERENCE_TUNING = 'PREFERENCE_TUNING'1262  """Preference optimization tuning."""1263  DISTILLATION = 'DISTILLATION'1264  """Distillation tuning."""1265  REINFORCEMENT_TUNING = 'REINFORCEMENT_TUNING'1266  """Reinforcement tuning."""126712681269class FileState(_common.CaseInSensitiveEnum):1270  """State for the lifecycle of a File."""12711272  STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'1273  PROCESSING = 'PROCESSING'1274  ACTIVE = 'ACTIVE'1275  FAILED = 'FAILED'127612771278class FileSource(_common.CaseInSensitiveEnum):1279  """Source of the File."""12801281  SOURCE_UNSPECIFIED = 'SOURCE_UNSPECIFIED'1282  UPLOADED = 'UPLOADED'1283  GENERATED = 'GENERATED'1284  REGISTERED = 'REGISTERED'128512861287class TurnCompleteReason(_common.CaseInSensitiveEnum):1288  """The reason why the turn is complete."""12891290  TURN_COMPLETE_REASON_UNSPECIFIED = 'TURN_COMPLETE_REASON_UNSPECIFIED'1291  """Default value. Reason is unspecified."""1292  MALFORMED_FUNCTION_CALL = 'MALFORMED_FUNCTION_CALL'1293  """The function call generated by the model is invalid."""1294  RESPONSE_REJECTED = 'RESPONSE_REJECTED'1295  """The response is rejected by the model."""1296  NEED_MORE_INPUT = 'NEED_MORE_INPUT'1297  """Needs more input from the user."""1298  PROHIBITED_INPUT_CONTENT = 'PROHIBITED_INPUT_CONTENT'1299  """Input content is prohibited."""1300  IMAGE_PROHIBITED_INPUT_CONTENT = 'IMAGE_PROHIBITED_INPUT_CONTENT'1301  """Input image contains prohibited content."""1302  INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED = (1303      'INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED'1304  )1305  """Input text contains prominent person reference."""1306  INPUT_IMAGE_CELEBRITY = 'INPUT_IMAGE_CELEBRITY'1307  """Input image contains celebrity."""1308  INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED = (1309      'INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED'1310  )1311  """Input image contains photo realistic child."""1312  INPUT_TEXT_NCII_PROHIBITED = 'INPUT_TEXT_NCII_PROHIBITED'1313  """Input text contains NCII content."""1314  INPUT_OTHER = 'INPUT_OTHER'1315  """Other input safety issue."""1316  INPUT_IP_PROHIBITED = 'INPUT_IP_PROHIBITED'1317  """Input contains IP violation."""1318  BLOCKLIST = 'BLOCKLIST'1319  """Input matched blocklist."""1320  UNSAFE_PROMPT_FOR_IMAGE_GENERATION = 'UNSAFE_PROMPT_FOR_IMAGE_GENERATION'1321  """Input is unsafe for image generation."""1322  GENERATED_IMAGE_SAFETY = 'GENERATED_IMAGE_SAFETY'1323  """Generated image failed safety check."""1324  GENERATED_CONTENT_SAFETY = 'GENERATED_CONTENT_SAFETY'1325  """Generated content failed safety check."""1326  GENERATED_AUDIO_SAFETY = 'GENERATED_AUDIO_SAFETY'1327  """Generated audio failed safety check."""1328  GENERATED_VIDEO_SAFETY = 'GENERATED_VIDEO_SAFETY'1329  """Generated video failed safety check."""1330  GENERATED_CONTENT_PROHIBITED = 'GENERATED_CONTENT_PROHIBITED'1331  """Generated content is prohibited."""1332  GENERATED_CONTENT_BLOCKLIST = 'GENERATED_CONTENT_BLOCKLIST'1333  """Generated content matched blocklist."""1334  GENERATED_IMAGE_PROHIBITED = 'GENERATED_IMAGE_PROHIBITED'1335  """Generated image is prohibited."""1336  GENERATED_IMAGE_CELEBRITY = 'GENERATED_IMAGE_CELEBRITY'1337  """Generated image contains celebrity."""1338  GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER = (1339      'GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER'1340  )1341  """Generated image contains prominent people detected by rewriter."""1342  GENERATED_IMAGE_IDENTIFIABLE_PEOPLE = 'GENERATED_IMAGE_IDENTIFIABLE_PEOPLE'1343  """Generated image contains identifiable people."""1344  GENERATED_IMAGE_MINORS = 'GENERATED_IMAGE_MINORS'1345  """Generated image contains minors."""1346  OUTPUT_IMAGE_IP_PROHIBITED = 'OUTPUT_IMAGE_IP_PROHIBITED'1347  """Generated image contains IP violation."""1348  GENERATED_OTHER = 'GENERATED_OTHER'1349  """Other generated content issue."""1350  MAX_REGENERATION_REACHED = 'MAX_REGENERATION_REACHED'1351  """Max regeneration attempts reached."""135213531354class InteractionStatus(_common.CaseInSensitiveEnum):1355  """The different activity states of the live session."""13561357  INTERACTION_STATUS_UNSPECIFIED = 'INTERACTION_STATUS_UNSPECIFIED'1358  """Unspecified interaction status."""1359  IN_PROGRESS = 'IN_PROGRESS'1360  """The server is still actively processing user input or running background reasoning. More model output may follow."""1361  REQUIRES_ACTION = 'REQUIRES_ACTION'1362  """Deprecated: Use IDLE instead."""1363  IDLE = 'IDLE'1364  """The server has completed all processing and background reasoning."""136513661367class VadSignalType(_common.CaseInSensitiveEnum):1368  """The type of the VAD signal."""13691370  VAD_SIGNAL_TYPE_UNSPECIFIED = 'VAD_SIGNAL_TYPE_UNSPECIFIED'1371  """The default is VAD_SIGNAL_TYPE_UNSPECIFIED."""1372  VAD_SIGNAL_TYPE_SOS = 'VAD_SIGNAL_TYPE_SOS'1373  """Start of sentence signal."""1374  VAD_SIGNAL_TYPE_EOS = 'VAD_SIGNAL_TYPE_EOS'1375  """End of sentence signal."""137613771378class VoiceActivityType(_common.CaseInSensitiveEnum):1379  """The type of the voice activity signal."""13801381  TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED'1382  """The default is VOICE_ACTIVITY_TYPE_UNSPECIFIED."""1383  ACTIVITY_START = 'ACTIVITY_START'1384  """Start of sentence signal."""1385  ACTIVITY_END = 'ACTIVITY_END'1386  """End of sentence signal."""138713881389class StartSensitivity(_common.CaseInSensitiveEnum):1390  """Start of speech sensitivity."""13911392  START_SENSITIVITY_UNSPECIFIED = 'START_SENSITIVITY_UNSPECIFIED'1393  """The default is START_SENSITIVITY_LOW for Gemini Enterprise Agent Platform and START_SENSITIVITY_HIGH for Gemini Live."""1394  START_SENSITIVITY_HIGH = 'START_SENSITIVITY_HIGH'1395  """Automatic detection will detect the start of speech more often."""1396  START_SENSITIVITY_LOW = 'START_SENSITIVITY_LOW'1397  """Automatic detection will detect the start of speech less often."""139813991400class EndSensitivity(_common.CaseInSensitiveEnum):1401  """End of speech sensitivity."""14021403  END_SENSITIVITY_UNSPECIFIED = 'END_SENSITIVITY_UNSPECIFIED'1404  """The default is END_SENSITIVITY_LOW for Gemini Enterprise Agent Platform and END_SENSITIVITY_HIGH for Gemini Live."""1405  END_SENSITIVITY_HIGH = 'END_SENSITIVITY_HIGH'1406  """Automatic detection ends speech more often."""1407  END_SENSITIVITY_LOW = 'END_SENSITIVITY_LOW'1408  """Automatic detection ends speech less often."""140914101411class ActivityHandling(_common.CaseInSensitiveEnum):1412  """The different ways of handling user activity."""14131414  ACTIVITY_HANDLING_UNSPECIFIED = 'ACTIVITY_HANDLING_UNSPECIFIED'1415  """If unspecified, the default behavior is `START_OF_ACTIVITY_INTERRUPTS`."""1416  START_OF_ACTIVITY_INTERRUPTS = 'START_OF_ACTIVITY_INTERRUPTS'1417  """If true, start of activity will interrupt the model's response (also called "barge in"). The model's current response will be cut-off in the moment of the interruption. This is the default behavior."""1418  NO_INTERRUPTION = 'NO_INTERRUPTION'1419  """The model's response will not be interrupted."""142014211422class TurnCoverage(_common.CaseInSensitiveEnum):1423  """Options about which input is included in the user's turn."""14241425  TURN_COVERAGE_UNSPECIFIED = 'TURN_COVERAGE_UNSPECIFIED'1426  """If unspecified, the default behavior is `TURN_INCLUDES_ONLY_ACTIVITY`."""1427  TURN_INCLUDES_ONLY_ACTIVITY = 'TURN_INCLUDES_ONLY_ACTIVITY'1428  """The users turn only includes activity since the last turn, excluding inactivity (e.g. silence on the audio stream). This is the default behavior."""1429  TURN_INCLUDES_ALL_INPUT = 'TURN_INCLUDES_ALL_INPUT'1430  """The users turn includes all realtime input since the last turn, including inactivity (e.g. silence on the audio stream)."""1431  TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO = (1432      'TURN_INCLUDES_AUDIO_ACTIVITY_AND_ALL_VIDEO'1433  )1434  """Includes audio activity and all video since the last turn. With automatic activity detection, audio activity means speech and excludes silence."""143514361437class Scale(_common.CaseInSensitiveEnum):1438  """Scale of the generated music."""14391440  SCALE_UNSPECIFIED = 'SCALE_UNSPECIFIED'1441  """Default value. This value is unused."""1442  C_MAJOR_A_MINOR = 'C_MAJOR_A_MINOR'1443  """C major or A minor."""1444  D_FLAT_MAJOR_B_FLAT_MINOR = 'D_FLAT_MAJOR_B_FLAT_MINOR'1445  """Db major or Bb minor."""1446  D_MAJOR_B_MINOR = 'D_MAJOR_B_MINOR'1447  """D major or B minor."""1448  E_FLAT_MAJOR_C_MINOR = 'E_FLAT_MAJOR_C_MINOR'1449  """Eb major or C minor"""1450  E_MAJOR_D_FLAT_MINOR = 'E_MAJOR_D_FLAT_MINOR'1451  """E major or Db minor."""1452  F_MAJOR_D_MINOR = 'F_MAJOR_D_MINOR'1453  """F major or D minor."""1454  G_FLAT_MAJOR_E_FLAT_MINOR = 'G_FLAT_MAJOR_E_FLAT_MINOR'1455  """Gb major or Eb minor."""1456  G_MAJOR_E_MINOR = 'G_MAJOR_E_MINOR'1457  """G major or E minor."""1458  A_FLAT_MAJOR_F_MINOR = 'A_FLAT_MAJOR_F_MINOR'1459  """Ab major or F minor."""1460  A_MAJOR_G_FLAT_MINOR = 'A_MAJOR_G_FLAT_MINOR'1461  """A major or Gb minor."""1462  B_FLAT_MAJOR_G_MINOR = 'B_FLAT_MAJOR_G_MINOR'1463  """Bb major or G minor."""1464  B_MAJOR_A_FLAT_MINOR = 'B_MAJOR_A_FLAT_MINOR'1465  """B major or Ab minor."""146614671468class MusicGenerationMode(_common.CaseInSensitiveEnum):1469  """The mode of music generation."""14701471  MUSIC_GENERATION_MODE_UNSPECIFIED = 'MUSIC_GENERATION_MODE_UNSPECIFIED'1472  """Rely on the server default generation mode."""1473  QUALITY = 'QUALITY'1474  """Steer text prompts to regions of latent space with higher quality1475      music."""1476  DIVERSITY = 'DIVERSITY'1477  """Steer text prompts to regions of latent space with a larger1478      diversity of music."""1479  VOCALIZATION = 'VOCALIZATION'1480  """Steer text prompts to regions of latent space more likely to1481      generate music with vocals."""148214831484class LiveMusicPlaybackControl(_common.CaseInSensitiveEnum):1485  """The playback control signal to apply to the music generation."""14861487  PLAYBACK_CONTROL_UNSPECIFIED = 'PLAYBACK_CONTROL_UNSPECIFIED'1488  """This value is unused."""1489  PLAY = 'PLAY'1490  """Start generating the music."""1491  PAUSE = 'PAUSE'1492  """Hold the music generation. Use PLAY to resume from the current position."""1493  STOP = 'STOP'1494  """Stop the music generation and reset the context (prompts retained).1495      Use PLAY to restart the music generation."""1496  RESET_CONTEXT = 'RESET_CONTEXT'1497  """Reset the context of the music generation without stopping it.1498      Retains the current prompts and config."""149915001501class PartMediaResolution(_common.BaseModel):1502  """Media resolution for the input media."""15031504  level: Optional[PartMediaResolutionLevel] = Field(1505      default=None,1506      description="""The tokenization quality used for given media.1507    """,1508  )1509  num_tokens: Optional[int] = Field(1510      default=None,1511      description="""Specifies the required sequence length for media tokenization.1512    """,1513  )151415151516class PartMediaResolutionDict(TypedDict, total=False):1517  """Media resolution for the input media."""15181519  level: Optional[PartMediaResolutionLevel]1520  """The tokenization quality used for given media.1521    """15221523  num_tokens: Optional[int]1524  """Specifies the required sequence length for media tokenization.1525    """152615271528PartMediaResolutionOrDict = Union[PartMediaResolution, PartMediaResolutionDict]152915301531class ToolCall(_common.BaseModel):1532  """A predicted server-side `ToolCall` returned from the model.15331534  This message contains information about a tool that the model wants to invoke.1535  The client is NOT expected to execute this `ToolCall`. Instead, the1536  client should pass this `ToolCall` back to the API in a subsequent turn1537  within a `Content` message, along with the corresponding `ToolResponse`.1538  """15391540  id: Optional[str] = Field(1541      default=None,1542      description="""Unique identifier of the tool call. The server returns the tool response with the matching `id`.""",1543  )1544  tool_type: Optional[ToolType] = Field(1545      default=None, description="""The type of tool that was called."""1546  )1547  args: Optional[dict[str, Any]] = Field(1548      default=None,1549      description="""The tool call arguments. Example: {"arg1": "value1", "arg2": "value2"}.""",1550  )155115521553class ToolCallDict(TypedDict, total=False):1554  """A predicted server-side `ToolCall` returned from the model.15551556  This message contains information about a tool that the model wants to invoke.1557  The client is NOT expected to execute this `ToolCall`. Instead, the1558  client should pass this `ToolCall` back to the API in a subsequent turn1559  within a `Content` message, along with the corresponding `ToolResponse`.1560  """15611562  id: Optional[str]1563  """Unique identifier of the tool call. The server returns the tool response with the matching `id`."""15641565  tool_type: Optional[ToolType]1566  """The type of tool that was called."""15671568  args: Optional[dict[str, Any]]1569  """The tool call arguments. Example: {"arg1": "value1", "arg2": "value2"}."""157015711572ToolCallOrDict = Union[ToolCall, ToolCallDict]157315741575class ToolResponse(_common.BaseModel):1576  """The output from a server-side `ToolCall` execution.15771578  This message contains the results of a tool invocation that was initiated by a1579  `ToolCall` from the model. The client should pass this `ToolResponse` back to1580  the API in a subsequent turn within a `Content` message, along with the1581  corresponding `ToolCall`.1582  """15831584  id: Optional[str] = Field(1585      default=None,1586      description="""The identifier of the tool call this response is for.""",1587  )1588  tool_type: Optional[ToolType] = Field(1589      default=None,1590      description="""The type of tool that was called, matching the tool_type in the corresponding ToolCall.""",1591  )1592  response: Optional[dict[str, Any]] = Field(1593      default=None, description="""The tool response."""1594  )159515961597class ToolResponseDict(TypedDict, total=False):1598  """The output from a server-side `ToolCall` execution.15991600  This message contains the results of a tool invocation that was initiated by a1601  `ToolCall` from the model. The client should pass this `ToolResponse` back to1602  the API in a subsequent turn within a `Content` message, along with the1603  corresponding `ToolCall`.1604  """16051606  id: Optional[str]1607  """The identifier of the tool call this response is for."""16081609  tool_type: Optional[ToolType]1610  """The type of tool that was called, matching the tool_type in the corresponding ToolCall."""16111612  response: Optional[dict[str, Any]]1613  """The tool response."""161416151616ToolResponseOrDict = Union[ToolResponse, ToolResponseDict]161716181619class CodeExecutionResult(_common.BaseModel):1620  """Result of executing the ExecutableCode.16211622  Generated only when the `CodeExecution` tool is used.1623  """16241625  outcome: Optional[Outcome] = Field(1626      default=None, description="""Required. Outcome of the code execution."""1627  )1628  output: Optional[str] = Field(1629      default=None,1630      description="""Optional. Contains stdout when code execution is successful, stderr or other description otherwise.""",1631  )1632  id: Optional[str] = Field(1633      default=None,1634      description="""Optional. The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id.""",1635  )163616371638class CodeExecutionResultDict(TypedDict, total=False):1639  """Result of executing the ExecutableCode.16401641  Generated only when the `CodeExecution` tool is used.1642  """16431644  outcome: Optional[Outcome]1645  """Required. Outcome of the code execution."""16461647  output: Optional[str]1648  """Optional. Contains stdout when code execution is successful, stderr or other description otherwise."""16491650  id: Optional[str]1651  """Optional. The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id."""165216531654CodeExecutionResultOrDict = Union[CodeExecutionResult, CodeExecutionResultDict]165516561657class ExecutableCode(_common.BaseModel):1658  """Code generated by the model that is meant to be executed, and the result returned to the model.16591660  Generated when using the `CodeExecution` tool, in which the code will be1661  automatically executed, and a corresponding CodeExecutionResult will also be1662  generated.1663  """16641665  code: Optional[str] = Field(1666      default=None, description="""Required. The code to be executed."""1667  )1668  language: Optional[Language] = Field(1669      default=None,1670      description="""Required. Programming language of the `code`.""",1671  )1672  id: Optional[str] = Field(1673      default=None,1674      description="""Optional. Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`.""",1675  )167616771678class ExecutableCodeDict(TypedDict, total=False):1679  """Code generated by the model that is meant to be executed, and the result returned to the model.16801681  Generated when using the `CodeExecution` tool, in which the code will be1682  automatically executed, and a corresponding CodeExecutionResult will also be1683  generated.1684  """16851686  code: Optional[str]1687  """Required. The code to be executed."""16881689  language: Optional[Language]1690  """Required. Programming language of the `code`."""16911692  id: Optional[str]1693  """Optional. Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`."""169416951696ExecutableCodeOrDict = Union[ExecutableCode, ExecutableCodeDict]169716981699class FileData(_common.BaseModel):1700  """URI-based data.17011702  A FileData message contains a URI pointing to data of a specific media type.1703  It is used to represent images, audio, and video stored in Google Cloud1704  Storage.1705  """17061707  display_name: Optional[str] = Field(1708      default=None,1709      description="""Optional. The display name of the file. Used to provide a label or filename to distinguish files. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server side tools (`code_execution`, `google_search`, and `url_context`) are enabled.""",1710  )1711  file_uri: Optional[str] = Field(1712      default=None,1713      description="""Required. The URI of the file in Google Cloud Storage.""",1714  )1715  mime_type: Optional[str] = Field(1716      default=None,1717      description="""Required. The IANA standard MIME type of the source data.""",1718  )171917201721class FileDataDict(TypedDict, total=False):1722  """URI-based data.17231724  A FileData message contains a URI pointing to data of a specific media type.1725  It is used to represent images, audio, and video stored in Google Cloud1726  Storage.1727  """17281729  display_name: Optional[str]1730  """Optional. The display name of the file. Used to provide a label or filename to distinguish files. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server side tools (`code_execution`, `google_search`, and `url_context`) are enabled."""17311732  file_uri: Optional[str]1733  """Required. The URI of the file in Google Cloud Storage."""17341735  mime_type: Optional[str]1736  """Required. The IANA standard MIME type of the source data."""173717381739FileDataOrDict = Union[FileData, FileDataDict]174017411742class PartialArg(_common.BaseModel):1743  """Partial argument value of the function call.17441745  This data type is not supported in Gemini API.1746  """17471748  bool_value: Optional[bool] = Field(1749      default=None, description="""Optional. Represents a boolean value."""1750  )1751  json_path: Optional[str] = Field(1752      default=None,1753      description="""Required. A JSON Path (RFC 9535) to the argument being streamed. https://datatracker.ietf.org/doc/html/rfc9535. e.g. "$.foo.bar[0].data".""",1754  )1755  null_value: Optional[Literal['NULL_VALUE']] = Field(1756      default=None, description="""Optional. Represents a null value."""1757  )1758  number_value: Optional[float] = Field(1759      default=None, description="""Optional. Represents a double value."""1760  )1761  string_value: Optional[str] = Field(1762      default=None, description="""Optional. Represents a string value."""1763  )1764  will_continue: Optional[bool] = Field(1765      default=None,1766      description="""Optional. Whether this is not the last part of the same json_path. If true, another PartialArg message for the current json_path is expected to follow.""",1767  )176817691770class PartialArgDict(TypedDict, total=False):1771  """Partial argument value of the function call.17721773  This data type is not supported in Gemini API.1774  """17751776  bool_value: Optional[bool]1777  """Optional. Represents a boolean value."""17781779  json_path: Optional[str]1780  """Required. A JSON Path (RFC 9535) to the argument being streamed. https://datatracker.ietf.org/doc/html/rfc9535. e.g. "$.foo.bar[0].data"."""17811782  null_value: Optional[Literal['NULL_VALUE']]1783  """Optional. Represents a null value."""17841785  number_value: Optional[float]1786  """Optional. Represents a double value."""17871788  string_value: Optional[str]1789  """Optional. Represents a string value."""17901791  will_continue: Optional[bool]1792  """Optional. Whether this is not the last part of the same json_path. If true, another PartialArg message for the current json_path is expected to follow."""179317941795PartialArgOrDict = Union[PartialArg, PartialArgDict]179617971798class FunctionCall(_common.BaseModel):1799  """A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values."""18001801  id: Optional[str] = Field(1802      default=None,1803      description="""Optional. The unique id of the function call. If populated, the client to execute the `function_call` and return the response with the matching `id`.""",1804  )1805  args: Optional[dict[str, Any]] = Field(1806      default=None,1807      description="""Optional. The function parameters and values in JSON object format. See FunctionDeclaration.parameters for parameter details.""",1808  )1809  name: Optional[str] = Field(1810      default=None,1811      description="""Optional. The name of the function to call. Matches FunctionDeclaration.name.""",1812  )1813  partial_args: Optional[list[PartialArg]] = Field(1814      default=None,1815      description="""Optional. The partial argument value of the function call. If provided, represents the arguments/fields that are streamed incrementally. This field is not supported in Gemini API.""",1816  )1817  will_continue: Optional[bool] = Field(1818      default=None,1819      description="""Optional. Whether this is the last part of the FunctionCall. If true, another partial message for the current FunctionCall is expected to follow. This field is not supported in Gemini API.""",1820  )182118221823class FunctionCallDict(TypedDict, total=False):1824  """A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values."""18251826  id: Optional[str]1827  """Optional. The unique id of the function call. If populated, the client to execute the `function_call` and return the response with the matching `id`."""18281829  args: Optional[dict[str, Any]]1830  """Optional. The function parameters and values in JSON object format. See FunctionDeclaration.parameters for parameter details."""18311832  name: Optional[str]1833  """Optional. The name of the function to call. Matches FunctionDeclaration.name."""18341835  partial_args: Optional[list[PartialArgDict]]1836  """Optional. The partial argument value of the function call. If provided, represents the arguments/fields that are streamed incrementally. This field is not supported in Gemini API."""18371838  will_continue: Optional[bool]1839  """Optional. Whether this is the last part of the FunctionCall. If true, another partial message for the current FunctionCall is expected to follow. This field is not supported in Gemini API."""184018411842FunctionCallOrDict = Union[FunctionCall, FunctionCallDict]184318441845class FunctionResponseBlob(_common.BaseModel):1846  """Raw media bytes for function response.18471848  Text should not be sent as raw bytes, use the 'text' field.1849  """18501851  mime_type: Optional[str] = Field(1852      default=None,1853      description="""Required. The IANA standard MIME type of the source data.""",1854  )1855  data: Optional[bytes] = Field(1856      default=None, description="""Required. Raw bytes."""1857  )1858  display_name: Optional[str] = Field(1859      default=None,1860      description="""Optional. Display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. This field is not supported in Gemini API.""",1861  )186218631864class FunctionResponseBlobDict(TypedDict, total=False):1865  """Raw media bytes for function response.18661867  Text should not be sent as raw bytes, use the 'text' field.1868  """18691870  mime_type: Optional[str]1871  """Required. The IANA standard MIME type of the source data."""18721873  data: Optional[bytes]1874  """Required. Raw bytes."""18751876  display_name: Optional[str]1877  """Optional. Display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. This field is not supported in Gemini API."""187818791880FunctionResponseBlobOrDict = Union[1881    FunctionResponseBlob, FunctionResponseBlobDict1882]188318841885class FunctionResponseFileData(_common.BaseModel):1886  """URI based data for function response.18871888  This data type is not supported in Gemini API.1889  """18901891  file_uri: Optional[str] = Field(1892      default=None, description="""Required. URI."""1893  )1894  mime_type: Optional[str] = Field(1895      default=None,1896      description="""Required. The IANA standard MIME type of the source data.""",1897  )1898  display_name: Optional[str] = Field(1899      default=None,1900      description="""Optional. Display name of the file data. Used to provide a label or filename to distinguish file datas. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled.""",1901  )190219031904class FunctionResponseFileDataDict(TypedDict, total=False):1905  """URI based data for function response.19061907  This data type is not supported in Gemini API.1908  """19091910  file_uri: Optional[str]1911  """Required. URI."""19121913  mime_type: Optional[str]1914  """Required. The IANA standard MIME type of the source data."""19151916  display_name: Optional[str]1917  """Optional. Display name of the file data. Used to provide a label or filename to distinguish file datas. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled."""191819191920FunctionResponseFileDataOrDict = Union[1921    FunctionResponseFileData, FunctionResponseFileDataDict1922]192319241925class FunctionResponsePart(_common.BaseModel):1926  """A datatype containing media that is part of a `FunctionResponse` message.19271928  A `FunctionResponsePart` consists of data which has an associated datatype. A1929  `FunctionResponsePart` can only contain one of the accepted types in1930  `FunctionResponsePart.data`. A `FunctionResponsePart` must have a fixed IANA1931  MIME type identifying the type and subtype of the media if the `inline_data`1932  field is filled with raw bytes.1933  """19341935  inline_data: Optional[FunctionResponseBlob] = Field(1936      default=None, description="""Inline media bytes."""1937  )1938  file_data: Optional[FunctionResponseFileData] = Field(1939      default=None,1940      description="""URI based data. This field is not supported in Gemini API.""",1941  )19421943  @classmethod1944  def from_bytes(cls, *, data: bytes, mime_type: str) -> 'FunctionResponsePart':1945    """Creates a FunctionResponsePart from bytes and mime type.19461947    Args:1948      data (bytes): The bytes of the data1949      mime_type (str): mime_type: The MIME type of the data.1950    """1951    inline_data = FunctionResponseBlob(1952        data=data,1953        mime_type=mime_type,1954    )1955    return cls(inline_data=inline_data)19561957  @classmethod1958  def from_uri(1959      cls, *, file_uri: str, mime_type: Optional[str] = None1960  ) -> 'FunctionResponsePart':1961    """Creates a FunctionResponsePart from a file uri.19621963    Args:1964      file_uri (str): The uri of the file1965      mime_type (str): mime_type: The MIME type of the file. If not provided,1966        the MIME type will be automatically determined.1967    """1968    if mime_type is None:1969      import mimetypes19701971      mime_type, _ = mimetypes.guess_type(file_uri)1972      if not mime_type:1973        raise ValueError(f'Failed to determine mime type for file: {file_uri}')1974    file_data = FunctionResponseFileData(file_uri=file_uri, mime_type=mime_type)1975    return cls(file_data=file_data)197619771978class FunctionResponsePartDict(TypedDict, total=False):1979  """A datatype containing media that is part of a `FunctionResponse` message.19801981  A `FunctionResponsePart` consists of data which has an associated datatype. A1982  `FunctionResponsePart` can only contain one of the accepted types in1983  `FunctionResponsePart.data`. A `FunctionResponsePart` must have a fixed IANA1984  MIME type identifying the type and subtype of the media if the `inline_data`1985  field is filled with raw bytes.1986  """19871988  inline_data: Optional[FunctionResponseBlobDict]1989  """Inline media bytes."""19901991  file_data: Optional[FunctionResponseFileDataDict]1992  """URI based data. This field is not supported in Gemini API."""199319941995FunctionResponsePartOrDict = Union[1996    FunctionResponsePart, FunctionResponsePartDict1997]199819992000class FunctionResponse(_common.BaseModel):2001  """The result output from a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model.20022003  This should contain the result of a `FunctionCall` made based on model2004  prediction.2005  """20062007  will_continue: Optional[bool] = Field(2008      default=None,2009      description="""Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished. This may still trigger the model generation. To avoid triggering the generation and finish the function call, additionally set `scheduling` to `SILENT`. This field is not supported in Vertex AI.""",2010  )2011  scheduling: Optional[FunctionResponseScheduling] = Field(2012      default=None,2013      description="""Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE.""",2014  )2015  parts: Optional[list[FunctionResponsePart]] = Field(2016      default=None,2017      description="""Optional. Ordered `Parts` that constitute a function response. Parts may have different IANA MIME types.""",2018  )2019  id: Optional[str] = Field(2020      default=None,2021      description="""Optional. The id of the function call this response is for. Populated by the client to match the corresponding function call `id`.""",2022  )2023  name: Optional[str] = Field(2024      default=None,2025      description="""Required. The name of the function to call. Matches FunctionDeclaration.name and FunctionCall.name.""",2026  )2027  response: Optional[dict[str, Any]] = Field(2028      default=None,2029      description="""Required. The function response in JSON object format. Use "output" key to specify function output and "error" key to specify error details (if any). If "output" and "error" keys are not specified, then whole "response" is treated as function output.""",2030  )20312032  @classmethod2033  def from_mcp_response(2034      cls, *, name: str, response: 'McpCallToolResult'2035  ) -> 'FunctionResponse':2036    if not _is_mcp_imported():2037      raise ValueError(2038          'MCP response is not supported. Please ensure that the MCP library is'2039          ' imported.'2040      )20412042    is_error = getattr(2043        response, 'isError', getattr(response, 'is_error', False)2044    )2045    if is_error:2046      return cls(name=name, response={'error': 'MCP response is error.'})2047    else:2048      return cls(name=name, response={'result': response.content})204920502051class FunctionResponseDict(TypedDict, total=False):2052  """The result output from a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model.20532054  This should contain the result of a `FunctionCall` made based on model2055  prediction.2056  """20572058  will_continue: Optional[bool]2059  """Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished. This may still trigger the model generation. To avoid triggering the generation and finish the function call, additionally set `scheduling` to `SILENT`. This field is not supported in Vertex AI."""20602061  scheduling: Optional[FunctionResponseScheduling]2062  """Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE."""20632064  parts: Optional[list[FunctionResponsePartDict]]2065  """Optional. Ordered `Parts` that constitute a function response. Parts may have different IANA MIME types."""20662067  id: Optional[str]2068  """Optional. The id of the function call this response is for. Populated by the client to match the corresponding function call `id`."""20692070  name: Optional[str]2071  """Required. The name of the function to call. Matches FunctionDeclaration.name and FunctionCall.name."""20722073  response: Optional[dict[str, Any]]2074  """Required. The function response in JSON object format. Use "output" key to specify function output and "error" key to specify error details (if any). If "output" and "error" keys are not specified, then whole "response" is treated as function output."""207520762077FunctionResponseOrDict = Union[FunctionResponse, FunctionResponseDict]207820792080class Blob(_common.BaseModel):2081  """A content blob.20822083  A Blob contains data of a specific media type. It is used to represent images,2084  audio, and video.2085  """20862087  data: Optional[bytes] = Field(2088      default=None, description="""Required. The raw bytes of the data."""2089  )2090  display_name: Optional[str] = Field(2091      default=None,2092      description="""Optional. The display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server-side tools (`code_execution`, `google_search`, and `url_context`) are enabled.""",2093  )2094  mime_type: Optional[str] = Field(2095      default=None,2096      description="""Required. The IANA standard MIME type of the source data.""",2097  )20982099  def as_image(self) -> Optional['Image']:2100    """Returns the Blob as a Image, or None if the Blob is not an image."""2101    if (2102        not self.data2103        or not self.mime_type2104        or not self.mime_type.startswith('image/')2105    ):2106      return None2107    return Image(2108        image_bytes=self.data,2109        mime_type=self.mime_type,2110    )211121122113class BlobDict(TypedDict, total=False):2114  """A content blob.21152116  A Blob contains data of a specific media type. It is used to represent images,2117  audio, and video.2118  """21192120  data: Optional[bytes]2121  """Required. The raw bytes of the data."""21222123  display_name: Optional[str]2124  """Optional. The display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server-side tools (`code_execution`, `google_search`, and `url_context`) are enabled."""21252126  mime_type: Optional[str]2127  """Required. The IANA standard MIME type of the source data."""212821292130BlobOrDict = Union[Blob, BlobDict]213121322133class VideoMetadata(_common.BaseModel):2134  """Provides metadata for a video, including the start and end offsets for clipping and the frame rate."""21352136  end_offset: Optional[str] = Field(2137      default=None, description="""Optional. The end offset of the video."""2138  )2139  fps: Optional[float] = Field(2140      default=None,2141      description="""Optional. The frame rate of the video sent to the model. If not specified, the default value is 1.0. The valid range is (0.0, 24.0].""",2142  )2143  start_offset: Optional[str] = Field(2144      default=None, description="""Optional. The start offset of the video."""2145  )214621472148class VideoMetadataDict(TypedDict, total=False):2149  """Provides metadata for a video, including the start and end offsets for clipping and the frame rate."""21502151  end_offset: Optional[str]2152  """Optional. The end offset of the video."""21532154  fps: Optional[float]2155  """Optional. The frame rate of the video sent to the model. If not specified, the default value is 1.0. The valid range is (0.0, 24.0]."""21562157  start_offset: Optional[str]2158  """Optional. The start offset of the video."""215921602161VideoMetadataOrDict = Union[VideoMetadata, VideoMetadataDict]216221632164class WordInfo(_common.BaseModel):2165  """Information about a single recognized word."""21662167  word: Optional[str] = Field(2168      default=None,2169      description="""Transcript of the word.2170      """,2171  )2172  start_offset: Optional[str] = Field(2173      default=None,2174      description="""Start offset in time of the word relative to the start of the audio.2175      """,2176  )2177  end_offset: Optional[str] = Field(2178      default=None,2179      description="""End offset in time of the word relative to the start of the audio.2180      """,2181  )218221832184class WordInfoDict(TypedDict, total=False):2185  """Information about a single recognized word."""21862187  word: Optional[str]2188  """Transcript of the word.2189      """21902191  start_offset: Optional[str]2192  """Start offset in time of the word relative to the start of the audio.2193      """21942195  end_offset: Optional[str]2196  """End offset in time of the word relative to the start of the audio.2197      """219821992200WordInfoOrDict = Union[WordInfo, WordInfoDict]220122022203class Transcription(_common.BaseModel):2204  """Audio transcription in Server Content."""22052206  text: Optional[str] = Field(2207      default=None, description="""Optional. Transcription text."""2208  )2209  finished: Optional[bool] = Field(2210      default=None,2211      description="""Optional. The bool indicates the end of the transcription.""",2212  )2213  language_code: Optional[str] = Field(2214      default=None,2215      description="""The BCP-47 language code of the transcription.""",2216  )2217  speaker_label: Optional[str] = Field(2218      default=None,2219      description="""A label identifying the speaker of this audio segment (e.g. "spk_1", "spk_2").2220      """,2221  )2222  words: Optional[list[WordInfo]] = Field(2223      default=None,2224      description="""Detailed word-level transcriptions and timing details.2225      """,2226  )222722282229class TranscriptionDict(TypedDict, total=False):2230  """Audio transcription in Server Content."""22312232  text: Optional[str]2233  """Optional. Transcription text."""22342235  finished: Optional[bool]2236  """Optional. The bool indicates the end of the transcription."""22372238  language_code: Optional[str]2239  """The BCP-47 language code of the transcription."""22402241  speaker_label: Optional[str]2242  """A label identifying the speaker of this audio segment (e.g. "spk_1", "spk_2").2243      """22442245  words: Optional[list[WordInfoDict]]2246  """Detailed word-level transcriptions and timing details.2247      """224822492250TranscriptionOrDict = Union[Transcription, TranscriptionDict]225122522253class Part(_common.BaseModel):2254  """A datatype containing media content.22552256  Exactly one field within a Part should be set, representing the specific type2257  of content being conveyed. Using multiple fields within the same `Part`2258  instance is considered invalid.2259  """22602261  media_resolution: Optional[PartMediaResolution] = Field(2262      default=None,2263      description="""Media resolution for the input media.2264    """,2265  )2266  code_execution_result: Optional[CodeExecutionResult] = Field(2267      default=None,2268      description="""Optional. The result of executing the ExecutableCode.""",2269  )2270  executable_code: Optional[ExecutableCode] = Field(2271      default=None,2272      description="""Optional. Code generated by the model that is intended to be executed.""",2273  )2274  file_data: Optional[FileData] = Field(2275      default=None,2276      description="""Optional. The URI-based data of the part. This can be used to include files from Google Cloud Storage.""",2277  )2278  function_call: Optional[FunctionCall] = Field(2279      default=None,2280      description="""Optional. A predicted function call returned from the model. This contains the name of the function to call and the arguments to pass to the function.""",2281  )2282  function_response: Optional[FunctionResponse] = Field(2283      default=None,2284      description="""Optional. The result of a function call. This is used to provide the model with the result of a function call that it predicted.""",2285  )2286  inline_data: Optional[Blob] = Field(2287      default=None,2288      description="""Optional. The inline data content of the part. This can be used to include images, audio, or video in a request.""",2289  )2290  text: Optional[str] = Field(2291      default=None,2292      description="""Optional. The text content of the part. When sent from the VSCode Gemini Code Assist extension, references to @mentioned items will be converted to markdown boldface text. For example `@my-repo` will be converted to and sent as `**my-repo**` by the IDE agent.""",2293  )2294  thought: Optional[bool] = Field(2295      default=None,2296      description="""Optional. Indicates whether the `part` represents the model's thought process or reasoning.""",2297  )2298  thought_signature: Optional[bytes] = Field(2299      default=None,2300      description="""Optional. An opaque signature for the thought so it can be reused in subsequent requests.""",2301  )2302  video_metadata: Optional[VideoMetadata] = Field(2303      default=None,2304      description="""Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data.""",2305  )2306  tool_call: Optional[ToolCall] = Field(2307      default=None,2308      description="""Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API.""",2309  )2310  tool_response: Optional[ToolResponse] = Field(2311      default=None,2312      description="""The output from a server-side ToolCall execution. This field is populated by the client with the results of executing the corresponding ToolCall.""",2313  )2314  part_metadata: Optional[dict[str, Any]] = Field(2315      default=None,2316      description="""Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams. This field is not supported in Vertex AI.""",2317  )2318  audio_transcription: Optional[Transcription] = Field(2319      default=None,2320      description="""Output only. The transcription of the audio part.""",2321  )2322  media_processing: Optional[MediaProcessing] = Field(2323      default=None,2324      description="""How the model processes this part's media for understanding.""",2325  )23262327  def __init__(2328      self,2329      value: Optional['PartUnionDict'] = None,2330      /,2331      *,2332      video_metadata: Optional[VideoMetadata] = None,2333      thought: Optional[bool] = None,2334      inline_data: Optional[Blob] = None,2335      file_data: Optional[FileData] = None,2336      thought_signature: Optional[bytes] = None,2337      function_call: Optional[FunctionCall] = None,2338      code_execution_result: Optional[CodeExecutionResult] = None,2339      executable_code: Optional[ExecutableCode] = None,2340      function_response: Optional[FunctionResponse] = None,2341      text: Optional[str] = None,2342      # Pydantic allows CamelCase in addition to snake_case attribute2343      # names. kwargs here catch these aliases.2344      **kwargs: Any,2345  ):2346    part_dict = dict(2347        video_metadata=video_metadata,2348        thought=thought,2349        inline_data=inline_data,2350        file_data=file_data,2351        thought_signature=thought_signature,2352        function_call=function_call,2353        code_execution_result=code_execution_result,2354        executable_code=executable_code,2355        function_response=function_response,2356        text=text,2357    )2358    part_dict = {k: v for k, v in part_dict.items() if v is not None}23592360    if part_dict and value is not None:2361      raise ValueError(2362          'Positional and keyword arguments can not be combined when '2363          'initializing a Part.'2364      )23652366    if value is None:2367      pass2368    elif isinstance(value, str):2369      part_dict['text'] = value2370    elif isinstance(value, File):2371      if not value.uri or not value.mime_type:2372        raise ValueError('file uri and mime_type are required.')2373      part_dict['file_data'] = FileData(2374          file_uri=value.uri,2375          mime_type=value.mime_type,2376          display_name=value.display_name,2377      )2378    elif isinstance(value, dict):2379      try:2380        Part.model_validate(value)2381        part_dict.update(value)  # type: ignore[arg-type]2382      except pydantic.ValidationError:2383        part_dict['file_data'] = FileData.model_validate(value)2384    elif isinstance(value, Part):2385      part_dict.update(value.dict())2386    elif 'image' in value.__class__.__name__.lower():2387      # PIL.Image case.23882389      suffix = value.format.lower() if value.format else 'jpeg'2390      mimetype = f'image/{suffix}'2391      bytes_io = io.BytesIO()2392      value.save(bytes_io, suffix.upper())23932394      part_dict['inline_data'] = Blob(2395          data=bytes_io.getvalue(), mime_type=mimetype2396      )2397    else:2398      raise ValueError(f'Unsupported content part type: {type(value)}')23992400    super().__init__(**part_dict, **kwargs)24012402  def as_image(self) -> Optional['Image']:2403    """Returns the part as a PIL Image, or None if the part is not an image."""2404    if not self.inline_data:2405      return None2406    return self.inline_data.as_image()24072408  @classmethod2409  def _t_part_media_resolution(2410      cls,2411      part_media_resolution: Union[2412          'PartMediaResolutionOrDict', 'PartMediaResolutionLevel', str2413      ],2414  ) -> PartMediaResolution:2415    if isinstance(part_media_resolution, str):2416      part_media_resolution = PartMediaResolution(level=part_media_resolution)2417    elif isinstance(part_media_resolution, PartMediaResolutionLevel):2418      part_media_resolution = PartMediaResolution(level=part_media_resolution)2419    elif isinstance(part_media_resolution, dict):2420      part_media_resolution = PartMediaResolution(**part_media_resolution)24212422    return part_media_resolution24232424  @classmethod2425  def from_uri(2426      cls,2427      *,2428      file_uri: str,2429      mime_type: Optional[str] = None,2430      media_resolution: Optional[2431          Union['PartMediaResolutionOrDict', 'PartMediaResolutionLevel', str]2432      ] = None,2433  ) -> 'Part':2434    """Creates a Part from a file uri.24352436    Args:2437      file_uri (str): The uri of the file2438      mime_type (str): mime_type: The MIME type of the file. If not provided,2439        the MIME type will be automatically determined.2440    """2441    if mime_type is None:2442      import mimetypes24432444      mime_type, _ = mimetypes.guess_type(file_uri)2445      if not mime_type:2446        raise ValueError(f'Failed to determine mime type for file: {file_uri}')2447    if media_resolution is not None:2448      media_resolution = cls._t_part_media_resolution(media_resolution)2449    file_data = FileData(file_uri=file_uri, mime_type=mime_type)2450    return cls(file_data=file_data, media_resolution=media_resolution)24512452  @classmethod2453  def from_text(cls, *, text: str) -> 'Part':2454    return cls(text=text)24552456  @classmethod2457  def from_bytes(2458      cls,2459      *,2460      data: bytes,2461      mime_type: str,2462      media_resolution: Optional[2463          Union['PartMediaResolutionOrDict', 'PartMediaResolutionLevel', str]2464      ] = None,2465  ) -> 'Part':2466    inline_data = Blob(2467        data=data,2468        mime_type=mime_type,2469    )2470    if media_resolution is not None:2471      media_resolution = cls._t_part_media_resolution(media_resolution)24722473    return cls(inline_data=inline_data, media_resolution=media_resolution)24742475  @classmethod2476  def from_function_call(cls, *, name: str, args: dict[str, Any]) -> 'Part':2477    function_call = FunctionCall(name=name, args=args)2478    return cls(function_call=function_call)24792480  @classmethod2481  def from_function_response(2482      cls,2483      *,2484      name: str,2485      response: dict[str, Any],2486      parts: Optional[list[FunctionResponsePart]] = None,2487  ) -> 'Part':2488    function_response = FunctionResponse(2489        name=name, response=response, parts=parts2490    )2491    return cls(function_response=function_response)24922493  @classmethod2494  def from_executable_code(cls, *, code: str, language: Language) -> 'Part':2495    executable_code = ExecutableCode(code=code, language=language)2496    return cls(executable_code=executable_code)24972498  @classmethod2499  def from_code_execution_result(2500      cls, *, outcome: Outcome, output: str2501  ) -> 'Part':2502    code_execution_result = CodeExecutionResult(outcome=outcome, output=output)2503    return cls(code_execution_result=code_execution_result)250425052506class PartDict(TypedDict, total=False):2507  """A datatype containing media content.25082509  Exactly one field within a Part should be set, representing the specific type2510  of content being conveyed. Using multiple fields within the same `Part`2511  instance is considered invalid.2512  """25132514  media_resolution: Optional[PartMediaResolutionDict]2515  """Media resolution for the input media.2516    """25172518  code_execution_result: Optional[CodeExecutionResultDict]2519  """Optional. The result of executing the ExecutableCode."""25202521  executable_code: Optional[ExecutableCodeDict]2522  """Optional. Code generated by the model that is intended to be executed."""25232524  file_data: Optional[FileDataDict]2525  """Optional. The URI-based data of the part. This can be used to include files from Google Cloud Storage."""25262527  function_call: Optional[FunctionCallDict]2528  """Optional. A predicted function call returned from the model. This contains the name of the function to call and the arguments to pass to the function."""25292530  function_response: Optional[FunctionResponseDict]2531  """Optional. The result of a function call. This is used to provide the model with the result of a function call that it predicted."""25322533  inline_data: Optional[BlobDict]2534  """Optional. The inline data content of the part. This can be used to include images, audio, or video in a request."""25352536  text: Optional[str]2537  """Optional. The text content of the part. When sent from the VSCode Gemini Code Assist extension, references to @mentioned items will be converted to markdown boldface text. For example `@my-repo` will be converted to and sent as `**my-repo**` by the IDE agent."""25382539  thought: Optional[bool]2540  """Optional. Indicates whether the `part` represents the model's thought process or reasoning."""25412542  thought_signature: Optional[bytes]2543  """Optional. An opaque signature for the thought so it can be reused in subsequent requests."""25442545  video_metadata: Optional[VideoMetadataDict]2546  """Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data."""25472548  tool_call: Optional[ToolCallDict]2549  """Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API."""25502551  tool_response: Optional[ToolResponseDict]2552  """The output from a server-side ToolCall execution. This field is populated by the client with the results of executing the corresponding ToolCall."""25532554  part_metadata: Optional[dict[str, Any]]2555  """Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams. This field is not supported in Vertex AI."""25562557  audio_transcription: Optional[TranscriptionDict]2558  """Output only. The transcription of the audio part."""25592560  media_processing: Optional[MediaProcessing]2561  """How the model processes this part's media for understanding."""256225632564PartOrDict = Union[Part, PartDict]256525662567class Content(_common.BaseModel):2568  """Contains the multi-part content of a message."""25692570  parts: Optional[list[Part]] = Field(2571      default=None,2572      description="""List of parts that constitute a single message. Each part may have2573      a different IANA MIME type.""",2574  )2575  role: Optional[str] = Field(2576      default=None,2577      description="""Optional. The producer of the content. Must be either 'user' or 'model'. If not set, the service will default to 'user'.""",2578  )257925802581class ContentDict(TypedDict, total=False):2582  """Contains the multi-part content of a message."""25832584  parts: Optional[list[PartDict]]2585  """List of parts that constitute a single message. Each part may have2586      a different IANA MIME type."""25872588  role: Optional[str]2589  """Optional. The producer of the content. Must be either 'user' or 'model'. If not set, the service will default to 'user'."""259025912592ContentOrDict = Union[Content, ContentDict]259325942595class HttpRetryOptions(_common.BaseModel):2596  """HTTP retry options to be used in each of the requests."""25972598  attempts: Optional[int] = Field(2599      default=None,2600      description="""Maximum number of attempts, including the original request.2601      If 0 or 1, it means no retries. If not specified, default to 5.""",2602  )2603  initial_delay: Optional[float] = Field(2604      default=None,2605      description="""Initial delay before the first retry, in fractions of a second. If not specified, default to 1.0 second.""",2606  )2607  max_delay: Optional[float] = Field(2608      default=None,2609      description="""Maximum delay between retries, in fractions of a second. If not specified, default to 60.0 seconds.""",2610  )2611  exp_base: Optional[float] = Field(2612      default=None,2613      description="""Multiplier by which the delay increases after each attempt. If not specified, default to 2.0.""",2614  )2615  jitter: Optional[float] = Field(2616      default=None,2617      description="""Randomness factor for the delay. If not specified, default to 1.0.""",2618  )2619  http_status_codes: Optional[list[int]] = Field(2620      default=None,2621      description="""List of HTTP status codes that should trigger a retry.2622      If not specified, a default set of retryable codes (408, 429, and 5xx) may be used.""",2623  )262426252626class HttpRetryOptionsDict(TypedDict, total=False):2627  """HTTP retry options to be used in each of the requests."""26282629  attempts: Optional[int]2630  """Maximum number of attempts, including the original request.2631      If 0 or 1, it means no retries. If not specified, default to 5."""26322633  initial_delay: Optional[float]2634  """Initial delay before the first retry, in fractions of a second. If not specified, default to 1.0 second."""26352636  max_delay: Optional[float]2637  """Maximum delay between retries, in fractions of a second. If not specified, default to 60.0 seconds."""26382639  exp_base: Optional[float]2640  """Multiplier by which the delay increases after each attempt. If not specified, default to 2.0."""26412642  jitter: Optional[float]2643  """Randomness factor for the delay. If not specified, default to 1.0."""26442645  http_status_codes: Optional[list[int]]2646  """List of HTTP status codes that should trigger a retry.2647      If not specified, a default set of retryable codes (408, 429, and 5xx) may be used."""264826492650HttpRetryOptionsOrDict = Union[HttpRetryOptions, HttpRetryOptionsDict]265126522653class HttpOptions(_common.BaseModel):2654  """HTTP options to be used in each of the requests."""26552656  base_url: Optional[str] = Field(2657      default=None,2658      description="""The base URL for the AI platform service endpoint.""",2659  )2660  base_url_resource_scope: Optional[ResourceScope] = Field(2661      default=None,2662      description="""The resource scope used to constructing the resource name when base_url is set""",2663  )2664  api_version: Optional[str] = Field(2665      default=None, description="""Specifies the version of the API to use."""2666  )2667  headers: Optional[dict[str, str]] = Field(2668      default=None,2669      description="""Additional HTTP headers to be sent with the request.""",2670  )2671  timeout: Optional[int] = Field(2672      default=None, description="""Timeout for the request in milliseconds."""2673  )2674  client_args: Optional[dict[str, Any]] = Field(2675      default=None, description="""Args passed to the HTTP client."""2676  )2677  async_client_args: Optional[dict[str, Any]] = Field(2678      default=None, description="""Args passed to the async HTTP client."""2679  )2680  extra_body: Optional[dict[str, Any]] = Field(2681      default=None,2682      description="""Extra parameters to add to the request body.2683      The structure must match the backend API's request structure.2684      - Gemini Enterprise Agent Platform backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest2685      - GeminiAPI backend API docs: https://ai.google.dev/api/rest""",2686  )2687  retry_options: Optional[HttpRetryOptions] = Field(2688      default=None, description="""HTTP retry options for the request."""2689  )26902691  httpx_client: Optional['HttpxClient'] = Field(2692      default=None,2693      description="""A custom httpx client to be used for the request.""",2694  )2695  httpx_async_client: Optional['HttpxAsyncClient'] = Field(2696      default=None,2697      description="""A custom httpx async client to be used for the request.""",2698  )2699  aiohttp_client: Optional['ClientSession'] = Field(2700      default=None,2701      description="""A custom aiohttp client session to be used for the request.""",2702  )270327042705class HttpOptionsDict(TypedDict, total=False):2706  """HTTP options to be used in each of the requests."""27072708  base_url: Optional[str]2709  """The base URL for the AI platform service endpoint."""27102711  base_url_resource_scope: Optional[ResourceScope]2712  """The resource scope used to constructing the resource name when base_url is set"""27132714  api_version: Optional[str]2715  """Specifies the version of the API to use."""27162717  headers: Optional[dict[str, str]]2718  """Additional HTTP headers to be sent with the request."""27192720  timeout: Optional[int]2721  """Timeout for the request in milliseconds."""27222723  client_args: Optional[dict[str, Any]]2724  """Args passed to the HTTP client."""27252726  async_client_args: Optional[dict[str, Any]]2727  """Args passed to the async HTTP client."""27282729  extra_body: Optional[dict[str, Any]]2730  """Extra parameters to add to the request body.2731      The structure must match the backend API's request structure.2732      - Gemini Enterprise Agent Platform backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest2733      - GeminiAPI backend API docs: https://ai.google.dev/api/rest"""27342735  retry_options: Optional[HttpRetryOptionsDict]2736  """HTTP retry options for the request."""273727382739HttpOptionsOrDict = Union[HttpOptions, HttpOptionsDict]274027412742class JSONSchema(_common.BaseModel):2743  """A subset of JSON Schema according to 2020-12 JSON Schema draft.27442745  Represents a subset of a JSON Schema object that is used by the Gemini model.2746  The difference between this class and the Schema class is that this class is2747  compatible with OpenAPI 3.1 schema objects. And the Schema class is used to2748  make API call to Gemini model.2749  """27502751  type: Optional[Union[JSONSchemaType, list[JSONSchemaType]]] = Field(2752      default=None,2753      description="""Validation succeeds if the type of the instance matches the type represented by the given type, or matches at least one of the given types.""",2754  )2755  format: Optional[str] = Field(2756      default=None,2757      description='Define semantic information about a string instance.',2758  )2759  title: Optional[str] = Field(2760      default=None,2761      description=(2762          'A preferably short description about the purpose of the instance'2763          ' described by the schema.'2764      ),2765  )2766  description: Optional[str] = Field(2767      default=None,2768      description=(2769          'An explanation about the purpose of the instance described by the'2770          ' schema.'2771      ),2772  )2773  default: Optional[Any] = Field(2774      default=None,2775      description=(2776          'This keyword can be used to supply a default JSON value associated'2777          ' with a particular schema.'2778      ),2779  )2780  items: Optional['JSONSchema'] = Field(2781      default=None,2782      description=(2783          'Validation succeeds if each element of the instance not covered by'2784          ' prefixItems validates against this schema.'2785      ),2786  )2787  min_items: Optional[int] = Field(2788      default=None,2789      description=(2790          'An array instance is valid if its size is greater than, or equal to,'2791          ' the value of this keyword.'2792      ),2793  )2794  max_items: Optional[int] = Field(2795      default=None,2796      description=(2797          'An array instance is valid if its size is less than, or equal to,'2798          ' the value of this keyword.'2799      ),2800  )2801  enum: Optional[list[Any]] = Field(2802      default=None,2803      description=(2804          'Validation succeeds if the instance is equal to one of the elements'2805          ' in this keyword’s array value.'2806      ),2807  )2808  properties: Optional[dict[str, 'JSONSchema']] = Field(2809      default=None,2810      description=(2811          'Validation succeeds if, for each name that appears in both the'2812          ' instance and as a name within this keyword’s value, the child'2813          ' instance for that name successfully validates against the'2814          ' corresponding schema.'2815      ),2816  )2817  required: Optional[list[str]] = Field(2818      default=None,2819      description=(2820          'An object instance is valid against this keyword if every item in'2821          ' the array is the name of a property in the instance.'2822      ),2823  )2824  min_properties: Optional[int] = Field(2825      default=None,2826      description=(2827          'An object instance is valid if its number of properties is greater'2828          ' than, or equal to, the value of this keyword.'2829      ),2830  )2831  max_properties: Optional[int] = Field(2832      default=None,2833      description=(2834          'An object instance is valid if its number of properties is less'2835          ' than, or equal to, the value of this keyword.'2836      ),2837  )2838  minimum: Optional[float] = Field(2839      default=None,2840      description=(2841          'Validation succeeds if the numeric instance is greater than or equal'2842          ' to the given number.'2843      ),2844  )2845  maximum: Optional[float] = Field(2846      default=None,2847      description=(2848          'Validation succeeds if the numeric instance is less than or equal to'2849          ' the given number.'2850      ),2851  )2852  min_length: Optional[int] = Field(2853      default=None,2854      description=(2855          'A string instance is valid against this keyword if its length is'2856          ' greater than, or equal to, the value of this keyword.'2857      ),2858  )2859  max_length: Optional[int] = Field(2860      default=None,2861      description=(2862          'A string instance is valid against this keyword if its length is'2863          ' less than, or equal to, the value of this keyword.'2864      ),2865  )2866  pattern: Optional[str] = Field(2867      default=None,2868      description=(2869          'A string instance is considered valid if the regular expression'2870          ' matches the instance successfully.'2871      ),2872  )2873  additional_properties: Optional[Any] = Field(2874      default=None,2875      description="""Can either be a boolean or an object; controls the presence of additional properties.""",2876  )2877  any_of: Optional[list['JSONSchema']] = Field(2878      default=None,2879      description=(2880          'An instance validates successfully against this keyword if it'2881          ' validates successfully against at least one schema defined by this'2882          ' keyword’s value.'2883      ),2884  )2885  unique_items: Optional[bool] = Field(2886      default=None,2887      description="""Boolean value that indicates whether the items in an array are unique.""",2888  )2889  ref: Optional[str] = Field(2890      default=None,2891      alias='$ref',2892      description="""Allows indirect references between schema nodes.""",2893  )2894  defs: Optional[dict[str, 'JSONSchema']] = Field(2895      default=None,2896      alias='$defs',2897      description="""Schema definitions to be used with $ref.""",2898  )2899  one_of: Optional[list['JSONSchema']] = Field(2900      default=None,2901      description=(2902          'An instance validates successfully against this keyword if it'2903          ' validates successfully against exactly one schema defined by this'2904          " keyword's value."2905      ),2906  )290729082909class Schema(_common.BaseModel):2910  """Schema is used to define the format of input/output data.29112912  Represents a select subset of an [OpenAPI 3.0 schema2913  object](https://spec.openapis.org/oas/v3.0.3#schema-object). More fields may2914  be added in the future as needed.2915  """29162917  additional_properties: Optional[Any] = Field(2918      default=None,2919      description="""Optional. Can either be a boolean or an object; controls the presence of additional properties.""",2920  )2921  defs: Optional[dict[str, 'Schema']] = Field(2922      default=None,2923      description="""Optional. A map of definitions for use by `ref` Only allowed at the root of the schema.""",2924  )2925  ref: Optional[str] = Field(2926      default=None,2927      description="""Optional. Allows indirect references between schema nodes. The value should be a valid reference to a child of the root `defs`. For example, the following schema defines a reference to a schema node named "Pet": type: object properties: pet: ref: #/defs/Pet defs: Pet: type: object properties: name: type: string The value of the "pet" property is a reference to the schema node named "Pet". See details in https://json-schema.org/understanding-json-schema/structuring""",2928  )2929  any_of: Optional[list['Schema']] = Field(2930      default=None,2931      description="""Optional. The instance must be valid against any (one or more) of the subschemas listed in `any_of`.""",2932  )2933  default: Optional[Any] = Field(2934      default=None,2935      description="""Optional. Default value to use if the field is not specified.""",2936  )2937  description: Optional[str] = Field(2938      default=None,2939      description="""Optional. Describes the data. The model uses this field to understand the purpose of the schema and how to use it. It is a best practice to provide a clear and descriptive explanation for the schema and its properties here, rather than in the prompt.""",2940  )2941  enum: Optional[list[str]] = Field(2942      default=None,2943      description="""Optional. Possible values of the field. This field can be used to restrict a value to a fixed set of values. To mark a field as an enum, set `format` to `enum` and provide the list of possible values in `enum`. For example: 1. To define directions: `{type:STRING, format:enum, enum:["EAST", "NORTH", "SOUTH", "WEST"]}` 2. To define apartment numbers: `{type:INTEGER, format:enum, enum:["101", "201", "301"]}`""",2944  )2945  example: Optional[Any] = Field(2946      default=None,2947      description="""Optional. Example of an instance of this schema.""",2948  )2949  format: Optional[str] = Field(2950      default=None,2951      description="""Optional. The format of the data. For `NUMBER` type, format can be `float` or `double`. For `INTEGER` type, format can be `int32` or `int64`. For `STRING` type, format can be `email`, `byte`, `date`, `date-time`, `password`, and other formats to further refine the data type.""",2952  )2953  items: Optional['Schema'] = Field(2954      default=None,2955      description="""Optional. If type is `ARRAY`, `items` specifies the schema of elements in the array.""",2956  )2957  max_items: Optional[int] = Field(2958      default=None,2959      description="""Optional. If type is `ARRAY`, `max_items` specifies the maximum number of items in an array.""",2960  )2961  max_length: Optional[int] = Field(2962      default=None,2963      description="""Optional. If type is `STRING`, `max_length` specifies the maximum length of the string.""",2964  )2965  max_properties: Optional[int] = Field(2966      default=None,2967      description="""Optional. If type is `OBJECT`, `max_properties` specifies the maximum number of properties that can be provided.""",2968  )2969  maximum: Optional[float] = Field(2970      default=None,2971      description="""Optional. If type is `INTEGER` or `NUMBER`, `maximum` specifies the maximum allowed value.""",2972  )2973  min_items: Optional[int] = Field(2974      default=None,2975      description="""Optional. If type is `ARRAY`, `min_items` specifies the minimum number of items in an array.""",2976  )2977  min_length: Optional[int] = Field(2978      default=None,2979      description="""Optional. If type is `STRING`, `min_length` specifies the minimum length of the string.""",2980  )2981  min_properties: Optional[int] = Field(2982      default=None,2983      description="""Optional. If type is `OBJECT`, `min_properties` specifies the minimum number of properties that can be provided.""",2984  )2985  minimum: Optional[float] = Field(2986      default=None,2987      description="""Optional. If type is `INTEGER` or `NUMBER`, `minimum` specifies the minimum allowed value.""",2988  )2989  nullable: Optional[bool] = Field(2990      default=None,2991      description="""Optional. Indicates if the value of this field can be null.""",2992  )2993  pattern: Optional[str] = Field(2994      default=None,2995      description="""Optional. If type is `STRING`, `pattern` specifies a regular expression that the string must match.""",2996  )2997  properties: Optional[dict[str, 'Schema']] = Field(2998      default=None,2999      description="""Optional. If type is `OBJECT`, `properties` is a map of property names to schema definitions for each property of the object.""",3000  )3001  property_ordering: Optional[list[str]] = Field(3002      default=None,3003      description="""Optional. Order of properties displayed or used where order matters. This is not a standard field in OpenAPI specification, but can be used to control the order of properties.""",3004  )3005  required: Optional[list[str]] = Field(3006      default=None,3007      description="""Optional. If type is `OBJECT`, `required` lists the names of properties that must be present.""",3008  )3009  title: Optional[str] = Field(3010      default=None, description="""Optional. Title for the schema."""3011  )3012  type: Optional[Type] = Field(3013      default=None, description="""Optional. Data type of the schema field."""3014  )30153016  @property3017  def json_schema(self) -> 'JSONSchema':3018    """Converts the Schema object to a JSONSchema object, that is compatible with 2020-12 JSON Schema draft.30193020     Note: Conversion of fields that are not included in the JSONSchema class3021     are ignored.3022     Json Schema is now supported natively by both Gemini Enterprise Agent3023     Platform and Gemini API. Users3024     are recommended to pass/receive Json Schema directly to/from the API. For3025     example:3026     1. the counter part of GenerateContentConfig.response_schema is3027        GenerateContentConfig.response_json_schema, which accepts [JSON3028       Schema](https://json-schema.org/)3029     2. the counter part of FunctionDeclaration.parameters is3030        FunctionDeclaration.parameters_json_schema, which accepts [JSON3031        Schema](https://json-schema.org/)3032     3. the counter part of FunctionDeclaration.response is3033        FunctionDeclaration.response_json_schema, which accepts [JSON3034    Schema](https://json-schema.org/)3035    """30363037    global _json_schema_warning_logged3038    if not _json_schema_warning_logged:3039      info_message = """3040Note: Conversion of fields that are not included in the JSONSchema class are3041ignored.3042Json Schema is now supported natively by both Gemini Enterprise Agent Platform and Gemini API. Users3043are recommended to pass/receive Json Schema directly to/from the API. For example:30441. the counter part of GenerateContentConfig.response_schema is3045   GenerateContentConfig.response_json_schema, which accepts [JSON3046  Schema](https://json-schema.org/)30472. the counter part of FunctionDeclaration.parameters is3048   FunctionDeclaration.parameters_json_schema, which accepts [JSON3049   Schema](https://json-schema.org/)30503. the counter part of FunctionDeclaration.response is3051   FunctionDeclaration.response_json_schema, which accepts [JSON3052   Schema](https://json-schema.org/)3053"""3054      logger.info(info_message)3055      _json_schema_warning_logged = True30563057    json_schema_field_names: set[str] = set(JSONSchema.model_fields.keys())3058    schema_field_names: tuple[str] = (3059        'items',3060    )  # 'additional_properties' to come3061    list_schema_field_names: tuple[str] = (3062        'any_of',  # 'one_of', 'all_of', 'not' to come3063    )3064    dict_schema_field_names: tuple[str] = ('properties',)  # 'defs' to come30653066    def convert_schema(schema: Union['Schema', dict[str, Any]]) -> 'JSONSchema':3067      if isinstance(schema, pydantic.BaseModel):3068        schema_dict = schema.model_dump(exclude_none=True)3069      else:3070        schema_dict = schema3071      json_schema = JSONSchema()3072      for field_name, field_value in schema_dict.items():3073        if field_value is None:3074          continue3075        elif field_name == 'nullable':3076          if json_schema.type is None:3077            json_schema.type = JSONSchemaType.NULL3078          elif isinstance(json_schema.type, JSONSchemaType):3079            current_type: JSONSchemaType = json_schema.type3080            json_schema.type = [current_type, JSONSchemaType.NULL]3081          elif isinstance(json_schema.type, list):3082            json_schema.type.append(JSONSchemaType.NULL)3083        elif field_name not in json_schema_field_names:3084          continue3085        elif field_name == 'type':3086          if field_value == Type.TYPE_UNSPECIFIED:3087            continue3088          json_schema_type = JSONSchemaType(field_value.lower())3089          if json_schema.type is None:3090            json_schema.type = json_schema_type3091          elif isinstance(json_schema.type, JSONSchemaType):3092            existing_type: JSONSchemaType = json_schema.type3093            json_schema.type = [existing_type, json_schema_type]3094          elif isinstance(json_schema.type, list):3095            json_schema.type.append(json_schema_type)3096        elif field_name in schema_field_names:3097          schema_field_value: 'JSONSchema' = convert_schema(field_value)3098          setattr(json_schema, field_name, schema_field_value)3099        elif field_name in list_schema_field_names:3100          list_schema_field_value: list['JSONSchema'] = [3101              convert_schema(this_field_value)3102              for this_field_value in field_value3103          ]3104          setattr(json_schema, field_name, list_schema_field_value)3105        elif field_name in dict_schema_field_names:3106          dict_schema_field_value: dict[str, 'JSONSchema'] = {3107              key: convert_schema(value) for key, value in field_value.items()3108          }3109          setattr(json_schema, field_name, dict_schema_field_value)3110        else:3111          setattr(json_schema, field_name, field_value)31123113      return json_schema31143115    return convert_schema(self)31163117  @classmethod3118  def from_json_schema(3119      cls,3120      *,3121      json_schema: 'JSONSchema',3122      api_option: Literal['ENTERPRISE', 'GEMINI_API', 'VERTEX_AI'] = (3123          'GEMINI_API'3124      ),3125      raise_error_on_unsupported_field: bool = False,3126  ) -> 'Schema':3127    """Converts a JSONSchema object to a Schema object.31283129     Note: Conversion of fields that are not included in the JSONSchema class3130     are ignored.3131     Json Schema is now supported natively by both Gemini Enterprise Agent3132     Platform and Gemini API. Users3133     are recommended to pass/receive Json Schema directly to/from the API. For3134     example:3135     1. the counter part of GenerateContentConfig.response_schema is3136        GenerateContentConfig.response_json_schema, which accepts [JSON3137       Schema](https://json-schema.org/)3138     2. the counter part of FunctionDeclaration.parameters is3139        FunctionDeclaration.parameters_json_schema, which accepts [JSON3140        Schema](https://json-schema.org/)3141     3. the counter part of FunctionDeclaration.response is3142        FunctionDeclaration.response_json_schema, which accepts [JSON3143    Schema](https://json-schema.org/)3144     The JSONSchema is compatible with 2020-12 JSON Schema draft, specified by3145     OpenAPI 3.1.31463147     Args:3148         json_schema: JSONSchema object to be converted.3149         api_option: API option to be used. If set to 'VERTEX_AI', the3150           JSONSchema will be converted to a Schema object that is compatible3151           with Gemini Enterprise Agent Platform API. If set to 'GEMINI_API',3152           the JSONSchema will be converted to a Schema object that is3153           compatible with Gemini API. Default is 'GEMINI_API'.3154         raise_error_on_unsupported_field: If set to True, an error will be3155           raised if the JSONSchema contains any unsupported fields. Default is3156           False.31573158     Returns:3159         Schema object that is compatible with the specified API option.3160     Raises:3161         ValueError: If the JSONSchema contains any unsupported fields and3162           raise_error_on_unsupported_field is set to True. Or if the JSONSchema3163           is not compatible with the specified API option.3164    """3165    global _from_json_schema_warning_logged3166    if not _from_json_schema_warning_logged:3167      info_message = """3168Note: Conversion of fields that are not included in the JSONSchema class are ignored.3169Json Schema is now supported natively by both Gemini Enterprise Agent Platform and Gemini API. Users3170are recommended to pass/receive Json Schema directly to/from the API. For example:31711. the counter part of GenerateContentConfig.response_schema is3172   GenerateContentConfig.response_json_schema, which accepts [JSON3173  Schema](https://json-schema.org/)31742. the counter part of FunctionDeclaration.parameters is3175   FunctionDeclaration.parameters_json_schema, which accepts [JSON3176   Schema](https://json-schema.org/)31773. the counter part of FunctionDeclaration.response is3178   FunctionDeclaration.response_json_schema, which accepts [JSON3179   Schema](https://json-schema.org/)3180"""3181      logger.info(info_message)3182      _from_json_schema_warning_logged = True31833184    google_schema_field_names: set[str] = set(cls.model_fields.keys())3185    schema_field_names: tuple[str, ...] = (3186        'items',3187    )  # 'additional_properties' to come3188    list_schema_field_names: tuple[str, ...] = (3189        'any_of',  # 'one_of', 'all_of', 'not' to come3190    )3191    dict_schema_field_names: tuple[str, ...] = ('properties',)31923193    related_field_names_by_type: dict[str, tuple[str, ...]] = {3194        JSONSchemaType.NUMBER.value: (3195            'description',3196            'enum',3197            'format',3198            'maximum',3199            'minimum',3200            'title',3201        ),3202        JSONSchemaType.STRING.value: (3203            'description',3204            'enum',3205            'format',3206            'max_length',3207            'min_length',3208            'pattern',3209            'title',3210        ),3211        JSONSchemaType.OBJECT.value: (3212            'any_of',3213            'description',3214            'max_properties',3215            'min_properties',3216            'properties',3217            'required',3218            'title',3219        ),3220        JSONSchemaType.ARRAY.value: (3221            'description',3222            'items',3223            'max_items',3224            'min_items',3225            'title',3226        ),3227        JSONSchemaType.BOOLEAN.value: (3228            'description',3229            'title',3230        ),3231    }3232    # Treat `INTEGER` like `NUMBER`.3233    related_field_names_by_type[JSONSchemaType.INTEGER.value] = (3234        related_field_names_by_type[JSONSchemaType.NUMBER.value]3235    )32363237    # placeholder for potential gemini api unsupported fields3238    gemini_api_unsupported_field_names: tuple[str, ...] = ()32393240    def _resolve_ref(3241        ref_path: str, root_schema_dict: dict[str, Any]3242    ) -> dict[str, Any]:3243      """Helper to resolve a $ref path."""3244      current = root_schema_dict3245      for part in ref_path.lstrip('#/').split('/'):3246        if part == '$defs':3247          part = 'defs'3248        current = current[part]3249      current.pop('title', None)3250      if 'properties' in current and current['properties'] is not None:3251        for prop_schema in current['properties'].values():3252          if isinstance(prop_schema, dict):3253            prop_schema.pop('title', None)32543255      return current32563257    def normalize_json_schema_type(3258        json_schema_type: Optional[3259            Union[JSONSchemaType, Sequence[JSONSchemaType], str, Sequence[str]]3260        ],3261    ) -> tuple[list[str], bool]:3262      """Returns (non_null_types, nullable)"""3263      if json_schema_type is None:3264        return [], False3265      type_sequence: Sequence[Union[JSONSchemaType, str]]3266      if isinstance(json_schema_type, str) or not isinstance(3267          json_schema_type, Sequence3268      ):3269        type_sequence = [json_schema_type]3270      else:3271        type_sequence = json_schema_type3272      non_null_types = []3273      nullable = False3274      for type_value in type_sequence:3275        if isinstance(type_value, JSONSchemaType):3276          type_value = type_value.value3277        if type_value == JSONSchemaType.NULL.value:3278          nullable = True3279        else:3280          non_null_types.append(type_value)3281      return non_null_types, nullable32823283    def raise_error_if_cannot_convert(3284        json_schema_dict: dict[str, Any],3285        api_option: Literal['ENTERPRISE', 'GEMINI_API', 'VERTEX_AI'],3286        raise_error_on_unsupported_field: bool,3287    ) -> None:3288      """Raises an error if the JSONSchema cannot be converted to the specified Schema object."""3289      if not raise_error_on_unsupported_field:3290        return3291      for field_name, field_value in json_schema_dict.items():3292        if field_value is None:3293          continue3294        if field_name not in google_schema_field_names and field_name not in [3295            'ref',3296            'defs',3297        ]:3298          raise ValueError(3299              f'JSONSchema field "{field_name}" is not supported by the Schema'3300              ' object. And the "raise_error_on_unsupported_field" argument is'3301              ' set to True. If you still want to convert it into the Schema'3302              f' object, please either remove the field "{field_name}" from the'3303              ' JSONSchema object, leave the'3304              ' "raise_error_on_unsupported_field" unset, or try using'3305              ' response_json_schema instead.'3306          )3307        if (3308            field_name in gemini_api_unsupported_field_names3309            and api_option == 'GEMINI_API'3310        ):3311          raise ValueError(3312              f'The "{field_name}" field is not supported by the Schema '3313              'object for GEMINI_API.'3314          )33153316    def copy_schema_fields(3317        json_schema_dict: dict[str, Any],3318        related_fields_to_copy: tuple[str, ...],3319        sub_schema_in_any_of: dict[str, Any],3320    ) -> None:3321      """Copies the fields from json_schema_dict to sub_schema_in_any_of."""3322      for field_name in related_fields_to_copy:3323        sub_schema_in_any_of[field_name] = json_schema_dict.get(3324            field_name, None3325        )33263327    def convert_json_schema(3328        current_json_schema: 'JSONSchema',3329        root_json_schema_dict: dict[str, Any],3330        api_option: Literal['ENTERPRISE', 'GEMINI_API', 'VERTEX_AI'],3331        raise_error_on_unsupported_field: bool,3332        visited_refs: Optional[set[str]] = None,3333    ) -> 'Schema':3334      if visited_refs is None:3335        visited_refs = set()33363337      schema = Schema()3338      json_schema_dict = current_json_schema.model_dump()33393340      ref = json_schema_dict.get('ref')3341      if ref:3342        if ref in visited_refs:3343          return Schema()3344        visited_refs.add(ref)3345        json_schema_dict = _resolve_ref(ref, root_json_schema_dict)33463347      raise_error_if_cannot_convert(3348          json_schema_dict=json_schema_dict,3349          api_option=api_option,3350          raise_error_on_unsupported_field=raise_error_on_unsupported_field,3351      )33523353      # At the highest level of the logic, there are two passes:3354      # Pass 1: the JSONSchema.type is union-like,3355      #         e.g. ['null', 'string', 'array'].3356      #         for this case, we need to split the JSONSchema into multiple3357      #         sub-schemas, and copy them into the any_of field of the Schema.3358      #         And when we copy the non-type fields into any_of field,3359      #         we only copy the fields related to the specific type.3360      #         Detailed logic is commented below with `Pass 1` keyword tag.3361      # Pass 2: the JSONSchema.type is not union-like,3362      #         e.g. 'string', ['string'], ['null', 'string'].3363      #         for this case, no splitting is needed. Detailed3364      #         logic is commented below with `Pass 2` keyword tag.3365      #3366      #3367      # Pass 1: the JSONSchema.type is union-like3368      #         e.g. ['null', 'string', 'array'].3369      non_null_types, nullable = normalize_json_schema_type(3370          json_schema_dict.get('type', None)3371      )3372      is_union_like_type = len(non_null_types) > 13373      if len(non_null_types) > 1:3374        logger.warning(3375            'JSONSchema type is union-like, e.g. ["null", "string", "array"]. '3376            'Converting it into multiple sub-schemas, and copying them into '3377            'the any_of field of the Schema. The value of `default` field is '3378            'ignored because it is ambiguous to tell which sub-schema it '3379            'belongs to.'3380        )3381        reformed_json_schema = JSONSchema()3382        # start splitting the JSONSchema into multiple sub-schemas3383        any_of = []3384        if nullable:3385          schema.nullable = True3386        for normalized_type in non_null_types:3387          sub_schema_in_any_of = {'type': normalized_type}3388          related_field_names = related_field_names_by_type.get(normalized_type)3389          if related_field_names is not None:3390            copy_schema_fields(3391                json_schema_dict=json_schema_dict,3392                related_fields_to_copy=related_field_names,3393                sub_schema_in_any_of=sub_schema_in_any_of,3394            )3395          any_of.append(JSONSchema(**sub_schema_in_any_of))3396        reformed_json_schema.any_of = any_of3397        json_schema_dict = reformed_json_schema.model_dump()33983399      # Pass 2: the JSONSchema.type is not union-like,3400      # e.g. 'string', ['string'], ['null', 'string'].3401      for field_name, field_value in json_schema_dict.items():3402        if field_value is None or field_name == 'defs':3403          continue3404        if field_name in schema_field_names:3405          if field_name == 'items' and not field_value:3406            continue3407          schema_field_value: 'Schema' = convert_json_schema(3408              current_json_schema=JSONSchema(**field_value),3409              root_json_schema_dict=root_json_schema_dict,3410              api_option=api_option,3411              raise_error_on_unsupported_field=raise_error_on_unsupported_field,3412              visited_refs=visited_refs,3413          )3414          setattr(schema, field_name, schema_field_value)3415        elif field_name in list_schema_field_names:3416          list_schema_field_value: list['Schema'] = [3417              convert_json_schema(3418                  current_json_schema=JSONSchema(**this_field_value),3419                  root_json_schema_dict=root_json_schema_dict,3420                  api_option=api_option,3421                  raise_error_on_unsupported_field=raise_error_on_unsupported_field,3422                  visited_refs=visited_refs,3423              )3424              for this_field_value in field_value3425          ]3426          setattr(schema, field_name, list_schema_field_value)3427          if not schema.type and not is_union_like_type and not schema.any_of:3428            schema.type = Type('OBJECT')3429        elif field_name in dict_schema_field_names:3430          dict_schema_field_value: dict[str, 'Schema'] = {3431              key: convert_json_schema(3432                  current_json_schema=JSONSchema(**value),3433                  root_json_schema_dict=root_json_schema_dict,3434                  api_option=api_option,3435                  raise_error_on_unsupported_field=raise_error_on_unsupported_field,3436                  visited_refs=visited_refs,3437              )3438              for key, value in field_value.items()3439          }3440          setattr(schema, field_name, dict_schema_field_value)3441        elif field_name == 'type':3442          non_null_types, nullable = normalize_json_schema_type(field_value)3443          if nullable:3444            schema.nullable = True3445          if non_null_types:3446            schema.type = Type(non_null_types[0])3447        else:3448          if (3449              hasattr(schema, field_name)3450              and field_name != 'additional_properties'3451          ):3452            setattr(schema, field_name, field_value)34533454      if (3455          schema.type == 'ARRAY'3456          and schema.items3457          and not schema.items.model_dump(exclude_unset=True)3458      ):3459        schema.items = None34603461      if schema.any_of and len(schema.any_of) == 2:3462        nullable_part = None3463        type_part = None3464        for part in schema.any_of:3465          # A schema representing `None` will either be of type NULL or just be nullable.3466          part_dict = part.model_dump(exclude_unset=True)3467          if part_dict == {'nullable': True} or part_dict == {'type': 'NULL'}:3468            nullable_part = part3469          else:3470            type_part = part34713472        # If we found both parts, unwrap them into a single schema.3473        if nullable_part and type_part:3474          default_value = schema.default3475          schema = type_part3476          schema.nullable = True3477          # Carry the default value over to the unwrapped schema3478          if default_value is not None:3479            schema.default = default_value34803481      if ref:3482        visited_refs.remove(ref)3483      return schema34843485    # This is the initial call to the recursive function.3486    root_schema_dict = json_schema.model_dump()3487    return convert_json_schema(3488        current_json_schema=json_schema,3489        root_json_schema_dict=root_schema_dict,3490        api_option=api_option,3491        raise_error_on_unsupported_field=raise_error_on_unsupported_field,3492    )349334943495class SchemaDict(TypedDict, total=False):3496  """Schema is used to define the format of input/output data.34973498  Represents a select subset of an [OpenAPI 3.0 schema3499  object](https://spec.openapis.org/oas/v3.0.3#schema-object). More fields may3500  be added in the future as needed.3501  """35023503  additional_properties: Optional[Any]3504  """Optional. Can either be a boolean or an object; controls the presence of additional properties."""35053506  defs: Optional[dict[str, 'SchemaDict']]3507  """Optional. A map of definitions for use by `ref` Only allowed at the root of the schema."""35083509  ref: Optional[str]3510  """Optional. Allows indirect references between schema nodes. The value should be a valid reference to a child of the root `defs`. For example, the following schema defines a reference to a schema node named "Pet": type: object properties: pet: ref: #/defs/Pet defs: Pet: type: object properties: name: type: string The value of the "pet" property is a reference to the schema node named "Pet". See details in https://json-schema.org/understanding-json-schema/structuring"""35113512  any_of: Optional[list['SchemaDict']]3513  """Optional. The instance must be valid against any (one or more) of the subschemas listed in `any_of`."""35143515  default: Optional[Any]3516  """Optional. Default value to use if the field is not specified."""35173518  description: Optional[str]3519  """Optional. Describes the data. The model uses this field to understand the purpose of the schema and how to use it. It is a best practice to provide a clear and descriptive explanation for the schema and its properties here, rather than in the prompt."""35203521  enum: Optional[list[str]]3522  """Optional. Possible values of the field. This field can be used to restrict a value to a fixed set of values. To mark a field as an enum, set `format` to `enum` and provide the list of possible values in `enum`. For example: 1. To define directions: `{type:STRING, format:enum, enum:["EAST", "NORTH", "SOUTH", "WEST"]}` 2. To define apartment numbers: `{type:INTEGER, format:enum, enum:["101", "201", "301"]}`"""35233524  example: Optional[Any]3525  """Optional. Example of an instance of this schema."""35263527  format: Optional[str]3528  """Optional. The format of the data. For `NUMBER` type, format can be `float` or `double`. For `INTEGER` type, format can be `int32` or `int64`. For `STRING` type, format can be `email`, `byte`, `date`, `date-time`, `password`, and other formats to further refine the data type."""35293530  items: Optional['SchemaDict']3531  """Optional. If type is `ARRAY`, `items` specifies the schema of elements in the array."""35323533  max_items: Optional[int]3534  """Optional. If type is `ARRAY`, `max_items` specifies the maximum number of items in an array."""35353536  max_length: Optional[int]3537  """Optional. If type is `STRING`, `max_length` specifies the maximum length of the string."""35383539  max_properties: Optional[int]3540  """Optional. If type is `OBJECT`, `max_properties` specifies the maximum number of properties that can be provided."""35413542  maximum: Optional[float]3543  """Optional. If type is `INTEGER` or `NUMBER`, `maximum` specifies the maximum allowed value."""35443545  min_items: Optional[int]3546  """Optional. If type is `ARRAY`, `min_items` specifies the minimum number of items in an array."""35473548  min_length: Optional[int]3549  """Optional. If type is `STRING`, `min_length` specifies the minimum length of the string."""35503551  min_properties: Optional[int]3552  """Optional. If type is `OBJECT`, `min_properties` specifies the minimum number of properties that can be provided."""35533554  minimum: Optional[float]3555  """Optional. If type is `INTEGER` or `NUMBER`, `minimum` specifies the minimum allowed value."""35563557  nullable: Optional[bool]3558  """Optional. Indicates if the value of this field can be null."""35593560  pattern: Optional[str]3561  """Optional. If type is `STRING`, `pattern` specifies a regular expression that the string must match."""35623563  properties: Optional[dict[str, 'SchemaDict']]3564  """Optional. If type is `OBJECT`, `properties` is a map of property names to schema definitions for each property of the object."""35653566  property_ordering: Optional[list[str]]3567  """Optional. Order of properties displayed or used where order matters. This is not a standard field in OpenAPI specification, but can be used to control the order of properties."""35683569  required: Optional[list[str]]3570  """Optional. If type is `OBJECT`, `required` lists the names of properties that must be present."""35713572  title: Optional[str]3573  """Optional. Title for the schema."""35743575  type: Optional[Type]3576  """Optional. Data type of the schema field."""357735783579SchemaOrDict = Union[Schema, SchemaDict]358035813582class ModelSelectionConfig(_common.BaseModel):3583  """Config for model selection."""35843585  feature_selection_preference: Optional[FeatureSelectionPreference] = Field(3586      default=None, description="""Options for feature selection preference."""3587  )358835893590class ModelSelectionConfigDict(TypedDict, total=False):3591  """Config for model selection."""35923593  feature_selection_preference: Optional[FeatureSelectionPreference]3594  """Options for feature selection preference."""359535963597ModelSelectionConfigOrDict = Union[3598    ModelSelectionConfig, ModelSelectionConfigDict3599]360036013602class ApiKeyConfig(_common.BaseModel):3603  """Config for authentication with API key.36043605  This data type is not supported in Gemini API.3606  """36073608  api_key_secret: Optional[str] = Field(3609      default=None,3610      description="""Optional. The name of the SecretManager secret version resource storing the API key. Format: `projects/{project}/secrets/{secrete}/versions/{version}` - If both `api_key_secret` and `api_key_string` are specified, this field takes precedence over `api_key_string`. - If specified, the `secretmanager.versions.access` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified resource.""",3611  )3612  api_key_string: Optional[str] = Field(3613      default=None,3614      description="""Optional. The API key to be used in the request directly.""",3615  )3616  http_element_location: Optional[HttpElementLocation] = Field(3617      default=None, description="""Optional. The location of the API key."""3618  )3619  name: Optional[str] = Field(3620      default=None,3621      description="""Optional. The parameter name of the API key. E.g. If the API request is "https://example.com/act?api_key=", "api_key" would be the parameter name.""",3622  )362336243625class ApiKeyConfigDict(TypedDict, total=False):3626  """Config for authentication with API key.36273628  This data type is not supported in Gemini API.3629  """36303631  api_key_secret: Optional[str]3632  """Optional. The name of the SecretManager secret version resource storing the API key. Format: `projects/{project}/secrets/{secrete}/versions/{version}` - If both `api_key_secret` and `api_key_string` are specified, this field takes precedence over `api_key_string`. - If specified, the `secretmanager.versions.access` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified resource."""36333634  api_key_string: Optional[str]3635  """Optional. The API key to be used in the request directly."""36363637  http_element_location: Optional[HttpElementLocation]3638  """Optional. The location of the API key."""36393640  name: Optional[str]3641  """Optional. The parameter name of the API key. E.g. If the API request is "https://example.com/act?api_key=", "api_key" would be the parameter name."""364236433644ApiKeyConfigOrDict = Union[ApiKeyConfig, ApiKeyConfigDict]364536463647class AuthConfigGoogleServiceAccountConfig(_common.BaseModel):3648  """Config for Google Service Account Authentication.36493650  This data type is not supported in Gemini API.3651  """36523653  service_account: Optional[str] = Field(3654      default=None,3655      description="""Optional. The service account that the extension execution service runs as. - If the service account is specified, the `iam.serviceAccounts.getAccessToken` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified service account. - If not specified, the Vertex AI Extension Service Agent will be used to execute the Extension.""",3656  )365736583659class AuthConfigGoogleServiceAccountConfigDict(TypedDict, total=False):3660  """Config for Google Service Account Authentication.36613662  This data type is not supported in Gemini API.3663  """36643665  service_account: Optional[str]3666  """Optional. The service account that the extension execution service runs as. - If the service account is specified, the `iam.serviceAccounts.getAccessToken` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified service account. - If not specified, the Vertex AI Extension Service Agent will be used to execute the Extension."""366736683669AuthConfigGoogleServiceAccountConfigOrDict = Union[3670    AuthConfigGoogleServiceAccountConfig,3671    AuthConfigGoogleServiceAccountConfigDict,3672]367336743675class AuthConfigHttpBasicAuthConfig(_common.BaseModel):3676  """Config for HTTP Basic Authentication.36773678  This data type is not supported in Gemini API.3679  """36803681  credential_secret: Optional[str] = Field(3682      default=None,3683      description="""Required. The name of the SecretManager secret version resource storing the base64 encoded credentials. Format: `projects/{project}/secrets/{secrete}/versions/{version}` - If specified, the `secretmanager.versions.access` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified resource.""",3684  )368536863687class AuthConfigHttpBasicAuthConfigDict(TypedDict, total=False):3688  """Config for HTTP Basic Authentication.36893690  This data type is not supported in Gemini API.3691  """36923693  credential_secret: Optional[str]3694  """Required. The name of the SecretManager secret version resource storing the base64 encoded credentials. Format: `projects/{project}/secrets/{secrete}/versions/{version}` - If specified, the `secretmanager.versions.access` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified resource."""369536963697AuthConfigHttpBasicAuthConfigOrDict = Union[3698    AuthConfigHttpBasicAuthConfig, AuthConfigHttpBasicAuthConfigDict3699]370037013702class AuthConfigOauthConfig(_common.BaseModel):3703  """Config for user oauth. This data type is not supported in Gemini API."""37043705  access_token: Optional[str] = Field(3706      default=None,3707      description="""Access token for extension endpoint. Only used to propagate token from [[ExecuteExtensionRequest.runtime_auth_config]] at request time.""",3708  )3709  service_account: Optional[str] = Field(3710      default=None,3711      description="""The service account used to generate access tokens for executing the Extension. - If the service account is specified, the `iam.serviceAccounts.getAccessToken` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the provided service account.""",3712  )371337143715class AuthConfigOauthConfigDict(TypedDict, total=False):3716  """Config for user oauth. This data type is not supported in Gemini API."""37173718  access_token: Optional[str]3719  """Access token for extension endpoint. Only used to propagate token from [[ExecuteExtensionRequest.runtime_auth_config]] at request time."""37203721  service_account: Optional[str]3722  """The service account used to generate access tokens for executing the Extension. - If the service account is specified, the `iam.serviceAccounts.getAccessToken` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the provided service account."""372337243725AuthConfigOauthConfigOrDict = Union[3726    AuthConfigOauthConfig, AuthConfigOauthConfigDict3727]372837293730class AuthConfigOidcConfig(_common.BaseModel):3731  """Config for user OIDC auth.37323733  This data type is not supported in Gemini API.3734  """37353736  id_token: Optional[str] = Field(3737      default=None,3738      description="""OpenID Connect formatted ID token for extension endpoint. Only used to propagate token from [[ExecuteExtensionRequest.runtime_auth_config]] at request time.""",3739  )3740  service_account: Optional[str] = Field(3741      default=None,3742      description="""The service account used to generate an OpenID Connect (OIDC)-compatible JWT token signed by the Google OIDC Provider (accounts.google.com) for extension endpoint (https://cloud.google.com/iam/docs/create-short-lived-credentials-direct#sa-credentials-oidc). - The audience for the token will be set to the URL in the server url defined in the OpenApi spec. - If the service account is provided, the service account should grant `iam.serviceAccounts.getOpenIdToken` permission to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents).""",3743  )374437453746class AuthConfigOidcConfigDict(TypedDict, total=False):3747  """Config for user OIDC auth.37483749  This data type is not supported in Gemini API.3750  """37513752  id_token: Optional[str]3753  """OpenID Connect formatted ID token for extension endpoint. Only used to propagate token from [[ExecuteExtensionRequest.runtime_auth_config]] at request time."""37543755  service_account: Optional[str]3756  """The service account used to generate an OpenID Connect (OIDC)-compatible JWT token signed by the Google OIDC Provider (accounts.google.com) for extension endpoint (https://cloud.google.com/iam/docs/create-short-lived-credentials-direct#sa-credentials-oidc). - The audience for the token will be set to the URL in the server url defined in the OpenApi spec. - If the service account is provided, the service account should grant `iam.serviceAccounts.getOpenIdToken` permission to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents)."""375737583759AuthConfigOidcConfigOrDict = Union[3760    AuthConfigOidcConfig, AuthConfigOidcConfigDict3761]376237633764class AuthConfig(_common.BaseModel):3765  """The authentication config to access the API."""37663767  api_key: Optional[str] = Field(3768      default=None,3769      description="""The authentication config to access the API. Only API key is supported. This field is not supported in Gemini API.""",3770  )3771  api_key_config: Optional[ApiKeyConfig] = Field(3772      default=None, description="""Config for API key auth."""3773  )3774  auth_type: Optional[AuthType] = Field(3775      default=None, description="""Type of auth scheme."""3776  )3777  google_service_account_config: Optional[3778      AuthConfigGoogleServiceAccountConfig3779  ] = Field(3780      default=None, description="""Config for Google Service Account auth."""3781  )3782  http_basic_auth_config: Optional[AuthConfigHttpBasicAuthConfig] = Field(3783      default=None, description="""Config for HTTP Basic auth."""3784  )3785  oauth_config: Optional[AuthConfigOauthConfig] = Field(3786      default=None, description="""Config for user oauth."""3787  )3788  oidc_config: Optional[AuthConfigOidcConfig] = Field(3789      default=None, description="""Config for user OIDC auth."""3790  )379137923793class AuthConfigDict(TypedDict, total=False):3794  """The authentication config to access the API."""37953796  api_key: Optional[str]3797  """The authentication config to access the API. Only API key is supported. This field is not supported in Gemini API."""37983799  api_key_config: Optional[ApiKeyConfigDict]3800  """Config for API key auth."""38013802  auth_type: Optional[AuthType]3803  """Type of auth scheme."""38043805  google_service_account_config: Optional[3806      AuthConfigGoogleServiceAccountConfigDict3807  ]3808  """Config for Google Service Account auth."""38093810  http_basic_auth_config: Optional[AuthConfigHttpBasicAuthConfigDict]3811  """Config for HTTP Basic auth."""38123813  oauth_config: Optional[AuthConfigOauthConfigDict]3814  """Config for user oauth."""38153816  oidc_config: Optional[AuthConfigOidcConfigDict]3817  """Config for user OIDC auth."""381838193820AuthConfigOrDict = Union[AuthConfig, AuthConfigDict]382138223823class GoogleMapsPlaces(_common.BaseModel):3824  """Grounding with Google Maps Places data (e.g.38253826  QueryPlaces). This is the default Google Maps grounding type when no other3827  type is specified. This data type is not supported in Gemini API.3828  """38293830  pass383138323833class GoogleMapsPlacesDict(TypedDict, total=False):3834  """Grounding with Google Maps Places data (e.g.38353836  QueryPlaces). This is the default Google Maps grounding type when no other3837  type is specified. This data type is not supported in Gemini API.3838  """38393840  pass384138423843GoogleMapsPlacesOrDict = Union[GoogleMapsPlaces, GoogleMapsPlacesDict]384438453846class GoogleMapsRouting(_common.BaseModel):3847  """Grounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute).38483849  This data type is not supported in Gemini API.3850  """38513852  pass385338543855class GoogleMapsRoutingDict(TypedDict, total=False):3856  """Grounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute).38573858  This data type is not supported in Gemini API.3859  """38603861  pass386238633864GoogleMapsRoutingOrDict = Union[GoogleMapsRouting, GoogleMapsRoutingDict]386538663867class GoogleMapsGroundingTypes(_common.BaseModel):3868  """Defines the types of Google Maps grounding that can be enabled and their configurations.38693870  This data type is not supported in Gemini API.3871  """38723873  places: Optional[GoogleMapsPlaces] = Field(3874      default=None,3875      description="""Optional. Enables grounding with Google Maps Places. This is the default grounding type when no `GroundingTypes` are specified.""",3876  )3877  routing: Optional[GoogleMapsRouting] = Field(3878      default=None,3879      description="""Optional. Enables grounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute).""",3880  )388138823883class GoogleMapsGroundingTypesDict(TypedDict, total=False):3884  """Defines the types of Google Maps grounding that can be enabled and their configurations.38853886  This data type is not supported in Gemini API.3887  """38883889  places: Optional[GoogleMapsPlacesDict]3890  """Optional. Enables grounding with Google Maps Places. This is the default grounding type when no `GroundingTypes` are specified."""38913892  routing: Optional[GoogleMapsRoutingDict]3893  """Optional. Enables grounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute)."""389438953896GoogleMapsGroundingTypesOrDict = Union[3897    GoogleMapsGroundingTypes, GoogleMapsGroundingTypesDict3898]389939003901class GoogleMaps(_common.BaseModel):3902  """Tool to retrieve knowledge from Google Maps."""39033904  auth_config: Optional[AuthConfig] = Field(3905      default=None,3906      description="""The authentication config to access the API. Only API key is supported. This field is not supported in Gemini API.""",3907  )3908  enable_widget: Optional[bool] = Field(3909      default=None,3910      description="""Deprecated. The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and no longer has any effect once removed. Optional. Whether to return a widget context token in the GroundingMetadata of the response.""",3911  )3912  grounding_types: Optional[GoogleMapsGroundingTypes] = Field(3913      default=None,3914      description="""Optional. Specifies the types of Google Maps grounding to enable. Defaults to `places` when unset. This field is not supported in Gemini API.""",3915  )391639173918class GoogleMapsDict(TypedDict, total=False):3919  """Tool to retrieve knowledge from Google Maps."""39203921  auth_config: Optional[AuthConfigDict]3922  """The authentication config to access the API. Only API key is supported. This field is not supported in Gemini API."""39233924  enable_widget: Optional[bool]3925  """Deprecated. The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and no longer has any effect once removed. Optional. Whether to return a widget context token in the GroundingMetadata of the response."""39263927  grounding_types: Optional[GoogleMapsGroundingTypesDict]3928  """Optional. Specifies the types of Google Maps grounding to enable. Defaults to `places` when unset. This field is not supported in Gemini API."""392939303931GoogleMapsOrDict = Union[GoogleMaps, GoogleMapsDict]393239333934class ApiAuthApiKeyConfig(_common.BaseModel):3935  """The API secret. This data type is not supported in Gemini API."""39363937  api_key_secret_version: Optional[str] = Field(3938      default=None,3939      description="""Required. The SecretManager secret version resource name storing API key. e.g. projects/{project}/secrets/{secret}/versions/{version}""",3940  )3941  api_key_string: Optional[str] = Field(3942      default=None,3943      description="""The API key string. Either this or `api_key_secret_version` must be set.""",3944  )394539463947class ApiAuthApiKeyConfigDict(TypedDict, total=False):3948  """The API secret. This data type is not supported in Gemini API."""39493950  api_key_secret_version: Optional[str]3951  """Required. The SecretManager secret version resource name storing API key. e.g. projects/{project}/secrets/{secret}/versions/{version}"""39523953  api_key_string: Optional[str]3954  """The API key string. Either this or `api_key_secret_version` must be set."""395539563957ApiAuthApiKeyConfigOrDict = Union[ApiAuthApiKeyConfig, ApiAuthApiKeyConfigDict]395839593960class ApiAuth(_common.BaseModel):3961  """The generic reusable api auth config.39623963  Deprecated. Please use AuthConfig (google/cloud/aiplatform/master/auth.proto)3964  instead. This data type is not supported in Gemini API.3965  """39663967  api_key_config: Optional[ApiAuthApiKeyConfig] = Field(3968      default=None, description="""The API secret."""3969  )397039713972class ApiAuthDict(TypedDict, total=False):3973  """The generic reusable api auth config.39743975  Deprecated. Please use AuthConfig (google/cloud/aiplatform/master/auth.proto)3976  instead. This data type is not supported in Gemini API.3977  """39783979  api_key_config: Optional[ApiAuthApiKeyConfigDict]3980  """The API secret."""398139823983ApiAuthOrDict = Union[ApiAuth, ApiAuthDict]398439853986class ExternalApiElasticSearchParams(_common.BaseModel):3987  """The search parameters to use for the ELASTIC_SEARCH spec.39883989  This data type is not supported in Gemini API.3990  """39913992  index: Optional[str] = Field(3993      default=None, description="""The ElasticSearch index to use."""3994  )3995  num_hits: Optional[int] = Field(3996      default=None,3997      description="""Optional. Number of hits (chunks) to request. When specified, it is passed to Elasticsearch as the `num_hits` param.""",3998  )3999  search_template: Optional[str] = Field(4000      default=None, description="""The ElasticSearch search template to use."""4001  )400240034004class ExternalApiElasticSearchParamsDict(TypedDict, total=False):4005  """The search parameters to use for the ELASTIC_SEARCH spec.40064007  This data type is not supported in Gemini API.4008  """40094010  index: Optional[str]4011  """The ElasticSearch index to use."""40124013  num_hits: Optional[int]4014  """Optional. Number of hits (chunks) to request. When specified, it is passed to Elasticsearch as the `num_hits` param."""40154016  search_template: Optional[str]4017  """The ElasticSearch search template to use."""401840194020ExternalApiElasticSearchParamsOrDict = Union[4021    ExternalApiElasticSearchParams, ExternalApiElasticSearchParamsDict4022]402340244025class ExternalApiSimpleSearchParams(_common.BaseModel):4026  """The search parameters to use for SIMPLE_SEARCH spec.40274028  This data type is not supported in Gemini API.4029  """40304031  pass403240334034class ExternalApiSimpleSearchParamsDict(TypedDict, total=False):4035  """The search parameters to use for SIMPLE_SEARCH spec.40364037  This data type is not supported in Gemini API.4038  """40394040  pass404140424043ExternalApiSimpleSearchParamsOrDict = Union[4044    ExternalApiSimpleSearchParams, ExternalApiSimpleSearchParamsDict4045]404640474048class ExternalApi(_common.BaseModel):4049  """Retrieve from data source powered by external API for grounding.40504051  The external API is not owned by Google, but need to follow the pre-defined4052  API spec. This data type is not supported in Gemini API.4053  """40544055  api_auth: Optional[ApiAuth] = Field(4056      default=None,4057      description="""The authentication config to access the API. Deprecated. Please use auth_config instead.""",4058  )4059  api_spec: Optional[ApiSpec] = Field(4060      default=None,4061      description="""The API spec that the external API implements.""",4062  )4063  auth_config: Optional[AuthConfig] = Field(4064      default=None,4065      description="""The authentication config to access the API.""",4066  )4067  elastic_search_params: Optional[ExternalApiElasticSearchParams] = Field(4068      default=None, description="""Parameters for the elastic search API."""4069  )4070  endpoint: Optional[str] = Field(4071      default=None,4072      description="""The endpoint of the external API. The system will call the API at this endpoint to retrieve the data for grounding. Example: https://acme.com:443/search""",4073  )4074  simple_search_params: Optional[ExternalApiSimpleSearchParams] = Field(4075      default=None, description="""Parameters for the simple search API."""4076  )407740784079class ExternalApiDict(TypedDict, total=False):4080  """Retrieve from data source powered by external API for grounding.40814082  The external API is not owned by Google, but need to follow the pre-defined4083  API spec. This data type is not supported in Gemini API.4084  """40854086  api_auth: Optional[ApiAuthDict]4087  """The authentication config to access the API. Deprecated. Please use auth_config instead."""40884089  api_spec: Optional[ApiSpec]4090  """The API spec that the external API implements."""40914092  auth_config: Optional[AuthConfigDict]4093  """The authentication config to access the API."""40944095  elastic_search_params: Optional[ExternalApiElasticSearchParamsDict]4096  """Parameters for the elastic search API."""40974098  endpoint: Optional[str]4099  """The endpoint of the external API. The system will call the API at this endpoint to retrieve the data for grounding. Example: https://acme.com:443/search"""41004101  simple_search_params: Optional[ExternalApiSimpleSearchParamsDict]4102  """Parameters for the simple search API."""410341044105ExternalApiOrDict = Union[ExternalApi, ExternalApiDict]410641074108class VertexAISearchDataStoreSpec(_common.BaseModel):4109  """Define data stores within engine to filter on in a search call and configurations for those data stores.41104111  For more information, see4112  https://cloud.google.com/generative-ai-app-builder/docs/reference/rpc/google.cloud.discoveryengine.v1#datastorespec.4113  This data type is not supported in Gemini API.4114  """41154116  data_store: Optional[str] = Field(4117      default=None,4118      description="""Full resource name of DataStore, such as Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}`""",4119  )4120  filter: Optional[str] = Field(4121      default=None,4122      description="""Optional. Filter specification to filter documents in the data store specified by data_store field. For more information on filtering, see [Filtering](https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata)""",4123  )412441254126class VertexAISearchDataStoreSpecDict(TypedDict, total=False):4127  """Define data stores within engine to filter on in a search call and configurations for those data stores.41284129  For more information, see4130  https://cloud.google.com/generative-ai-app-builder/docs/reference/rpc/google.cloud.discoveryengine.v1#datastorespec.4131  This data type is not supported in Gemini API.4132  """41334134  data_store: Optional[str]4135  """Full resource name of DataStore, such as Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}`"""41364137  filter: Optional[str]4138  """Optional. Filter specification to filter documents in the data store specified by data_store field. For more information on filtering, see [Filtering](https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata)"""413941404141VertexAISearchDataStoreSpecOrDict = Union[4142    VertexAISearchDataStoreSpec, VertexAISearchDataStoreSpecDict4143]414441454146class VertexAISearch(_common.BaseModel):4147  """Retrieve from Vertex AI Search datastore or engine for grounding.41484149  datastore and engine are mutually exclusive. See4150  https://cloud.google.com/products/agent-builder. This data type is not4151  supported in Gemini API.4152  """41534154  data_store_specs: Optional[list[VertexAISearchDataStoreSpec]] = Field(4155      default=None,4156      description="""Specifications that define the specific DataStores to be searched, along with configurations for those data stores. This is only considered for Engines with multiple data stores. It should only be set if engine is used.""",4157  )4158  datastore: Optional[str] = Field(4159      default=None,4160      description="""Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}`""",4161  )4162  engine: Optional[str] = Field(4163      default=None,4164      description="""Optional. Fully-qualified Vertex AI Search engine resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}`""",4165  )4166  filter: Optional[str] = Field(4167      default=None,4168      description="""Optional. Filter strings to be passed to the search API.""",4169  )4170  max_results: Optional[int] = Field(4171      default=None,4172      description="""Optional. Number of search results to return per query. The default value is 10. The maximumm allowed value is 10.""",4173  )417441754176class VertexAISearchDict(TypedDict, total=False):4177  """Retrieve from Vertex AI Search datastore or engine for grounding.41784179  datastore and engine are mutually exclusive. See4180  https://cloud.google.com/products/agent-builder. This data type is not4181  supported in Gemini API.4182  """41834184  data_store_specs: Optional[list[VertexAISearchDataStoreSpecDict]]4185  """Specifications that define the specific DataStores to be searched, along with configurations for those data stores. This is only considered for Engines with multiple data stores. It should only be set if engine is used."""41864187  datastore: Optional[str]4188  """Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}`"""41894190  engine: Optional[str]4191  """Optional. Fully-qualified Vertex AI Search engine resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}`"""41924193  filter: Optional[str]4194  """Optional. Filter strings to be passed to the search API."""41954196  max_results: Optional[int]4197  """Optional. Number of search results to return per query. The default value is 10. The maximumm allowed value is 10."""419841994200VertexAISearchOrDict = Union[VertexAISearch, VertexAISearchDict]420142024203class VertexRagStoreRagResource(_common.BaseModel):4204  """The definition of the Rag resource.42054206  This data type is not supported in Gemini API.4207  """42084209  rag_corpus: Optional[str] = Field(4210      default=None,4211      description="""Optional. RagCorpora resource name. Format: `projects/{project}/locations/{location}/ragCorpora/{rag_corpus}`""",4212  )4213  rag_file_ids: Optional[list[str]] = Field(4214      default=None,4215      description="""Optional. rag_file_id. The files should be in the same rag_corpus set in rag_corpus field.""",4216  )421742184219class VertexRagStoreRagResourceDict(TypedDict, total=False):4220  """The definition of the Rag resource.42214222  This data type is not supported in Gemini API.4223  """42244225  rag_corpus: Optional[str]4226  """Optional. RagCorpora resource name. Format: `projects/{project}/locations/{location}/ragCorpora/{rag_corpus}`"""42274228  rag_file_ids: Optional[list[str]]4229  """Optional. rag_file_id. The files should be in the same rag_corpus set in rag_corpus field."""423042314232VertexRagStoreRagResourceOrDict = Union[4233    VertexRagStoreRagResource, VertexRagStoreRagResourceDict4234]423542364237class RagRetrievalConfigFilter(_common.BaseModel):4238  """Config for filters. This data type is not supported in Gemini API."""42394240  metadata_filter: Optional[str] = Field(4241      default=None, description="""Optional. String for metadata filtering."""4242  )4243  vector_distance_threshold: Optional[float] = Field(4244      default=None,4245      description="""Optional. Only returns contexts with vector distance smaller than the threshold.""",4246  )4247  vector_similarity_threshold: Optional[float] = Field(4248      default=None,4249      description="""Optional. Only returns contexts with vector similarity larger than the threshold.""",4250  )425142524253class RagRetrievalConfigFilterDict(TypedDict, total=False):4254  """Config for filters. This data type is not supported in Gemini API."""42554256  metadata_filter: Optional[str]4257  """Optional. String for metadata filtering."""42584259  vector_distance_threshold: Optional[float]4260  """Optional. Only returns contexts with vector distance smaller than the threshold."""42614262  vector_similarity_threshold: Optional[float]4263  """Optional. Only returns contexts with vector similarity larger than the threshold."""426442654266RagRetrievalConfigFilterOrDict = Union[4267    RagRetrievalConfigFilter, RagRetrievalConfigFilterDict4268]426942704271class RagRetrievalConfigHybridSearch(_common.BaseModel):4272  """Config for Hybrid Search. This data type is not supported in Gemini API."""42734274  alpha: Optional[float] = Field(4275      default=None,4276      description="""Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally.""",4277  )427842794280class RagRetrievalConfigHybridSearchDict(TypedDict, total=False):4281  """Config for Hybrid Search. This data type is not supported in Gemini API."""42824283  alpha: Optional[float]4284  """Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally."""428542864287RagRetrievalConfigHybridSearchOrDict = Union[4288    RagRetrievalConfigHybridSearch, RagRetrievalConfigHybridSearchDict4289]429042914292class RagRetrievalConfigRankingLlmRanker(_common.BaseModel):4293  """Config for LlmRanker. This data type is not supported in Gemini API."""42944295  model_name: Optional[str] = Field(4296      default=None,4297      description="""Optional. The model name used for ranking. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#supported-models).""",4298  )429943004301class RagRetrievalConfigRankingLlmRankerDict(TypedDict, total=False):4302  """Config for LlmRanker. This data type is not supported in Gemini API."""43034304  model_name: Optional[str]4305  """Optional. The model name used for ranking. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#supported-models)."""430643074308RagRetrievalConfigRankingLlmRankerOrDict = Union[4309    RagRetrievalConfigRankingLlmRanker, RagRetrievalConfigRankingLlmRankerDict4310]431143124313class RagRetrievalConfigRankingRankService(_common.BaseModel):4314  """Config for Rank Service. This data type is not supported in Gemini API."""43154316  model_name: Optional[str] = Field(4317      default=None,4318      description="""Optional. The model name of the rank service. Format: `semantic-ranker-512@latest`""",4319  )432043214322class RagRetrievalConfigRankingRankServiceDict(TypedDict, total=False):4323  """Config for Rank Service. This data type is not supported in Gemini API."""43244325  model_name: Optional[str]4326  """Optional. The model name of the rank service. Format: `semantic-ranker-512@latest`"""432743284329RagRetrievalConfigRankingRankServiceOrDict = Union[4330    RagRetrievalConfigRankingRankService,4331    RagRetrievalConfigRankingRankServiceDict,4332]433343344335class RagRetrievalConfigRanking(_common.BaseModel):4336  """Config for ranking and reranking.43374338  This data type is not supported in Gemini API.4339  """43404341  llm_ranker: Optional[RagRetrievalConfigRankingLlmRanker] = Field(4342      default=None, description="""Optional. Config for LlmRanker."""4343  )4344  rank_service: Optional[RagRetrievalConfigRankingRankService] = Field(4345      default=None, description="""Optional. Config for Rank Service."""4346  )434743484349class RagRetrievalConfigRankingDict(TypedDict, total=False):4350  """Config for ranking and reranking.43514352  This data type is not supported in Gemini API.4353  """43544355  llm_ranker: Optional[RagRetrievalConfigRankingLlmRankerDict]4356  """Optional. Config for LlmRanker."""43574358  rank_service: Optional[RagRetrievalConfigRankingRankServiceDict]4359  """Optional. Config for Rank Service."""436043614362RagRetrievalConfigRankingOrDict = Union[4363    RagRetrievalConfigRanking, RagRetrievalConfigRankingDict4364]436543664367class RagRetrievalConfig(_common.BaseModel):4368  """Specifies the context retrieval config.43694370  This data type is not supported in Gemini API.4371  """43724373  filter: Optional[RagRetrievalConfigFilter] = Field(4374      default=None, description="""Optional. Config for filters."""4375  )4376  hybrid_search: Optional[RagRetrievalConfigHybridSearch] = Field(4377      default=None, description="""Optional. Config for Hybrid Search."""4378  )4379  ranking: Optional[RagRetrievalConfigRanking] = Field(4380      default=None,4381      description="""Optional. Config for ranking and reranking.""",4382  )4383  top_k: Optional[int] = Field(4384      default=None,4385      description="""Optional. The number of contexts to retrieve.""",4386  )438743884389class RagRetrievalConfigDict(TypedDict, total=False):4390  """Specifies the context retrieval config.43914392  This data type is not supported in Gemini API.4393  """43944395  filter: Optional[RagRetrievalConfigFilterDict]4396  """Optional. Config for filters."""43974398  hybrid_search: Optional[RagRetrievalConfigHybridSearchDict]4399  """Optional. Config for Hybrid Search."""44004401  ranking: Optional[RagRetrievalConfigRankingDict]4402  """Optional. Config for ranking and reranking."""44034404  top_k: Optional[int]4405  """Optional. The number of contexts to retrieve."""440644074408RagRetrievalConfigOrDict = Union[RagRetrievalConfig, RagRetrievalConfigDict]440944104411class VertexRagStore(_common.BaseModel):4412  """Retrieve from Vertex RAG Store for grounding.44134414  This data type is not supported in Gemini API.4415  """44164417  rag_corpora: Optional[list[str]] = Field(4418      default=None,4419      description="""Optional. Deprecated. Please use rag_resources instead.""",4420  )4421  rag_resources: Optional[list[VertexRagStoreRagResource]] = Field(4422      default=None,4423      description="""Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support.""",4424  )4425  rag_retrieval_config: Optional[RagRetrievalConfig] = Field(4426      default=None,4427      description="""Optional. The retrieval config for the Rag query.""",4428  )4429  similarity_top_k: Optional[int] = Field(4430      default=None,4431      description="""Optional. Number of top k results to return from the selected corpora.""",4432  )4433  store_context: Optional[bool] = Field(4434      default=None,4435      description="""Optional. Currently only supported for Gemini Multimodal Live API. In Gemini Multimodal Live API, if `store_context` bool is specified, Gemini will leverage it to automatically memorize the interactions between the client and Gemini, and retrieve context when needed to augment the response generation for users' ongoing and future interactions.""",4436  )4437  vector_distance_threshold: Optional[float] = Field(4438      default=None,4439      description="""Optional. Only return results with vector distance smaller than the threshold.""",4440  )444144424443class VertexRagStoreDict(TypedDict, total=False):4444  """Retrieve from Vertex RAG Store for grounding.44454446  This data type is not supported in Gemini API.4447  """44484449  rag_corpora: Optional[list[str]]4450  """Optional. Deprecated. Please use rag_resources instead."""44514452  rag_resources: Optional[list[VertexRagStoreRagResourceDict]]4453  """Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support."""44544455  rag_retrieval_config: Optional[RagRetrievalConfigDict]4456  """Optional. The retrieval config for the Rag query."""44574458  similarity_top_k: Optional[int]4459  """Optional. Number of top k results to return from the selected corpora."""44604461  store_context: Optional[bool]4462  """Optional. Currently only supported for Gemini Multimodal Live API. In Gemini Multimodal Live API, if `store_context` bool is specified, Gemini will leverage it to automatically memorize the interactions between the client and Gemini, and retrieve context when needed to augment the response generation for users' ongoing and future interactions."""44634464  vector_distance_threshold: Optional[float]4465  """Optional. Only return results with vector distance smaller than the threshold."""446644674468VertexRagStoreOrDict = Union[VertexRagStore, VertexRagStoreDict]446944704471class Retrieval(_common.BaseModel):4472  """Defines a retrieval tool that model can call to access external knowledge.44734474  This data type is not supported in Gemini API.4475  """44764477  disable_attribution: Optional[bool] = Field(4478      default=None,4479      description="""Optional. Deprecated. This option is no longer supported.""",4480  )4481  external_api: Optional[ExternalApi] = Field(4482      default=None,4483      description="""Use data source powered by external API for grounding.""",4484  )4485  vertex_ai_search: Optional[VertexAISearch] = Field(4486      default=None,4487      description="""Set to use data source powered by Vertex AI Search.""",4488  )4489  vertex_rag_store: Optional[VertexRagStore] = Field(4490      default=None,4491      description="""Set to use data source powered by Vertex RAG store. User data is uploaded via the VertexRagDataService.""",4492  )449344944495class RetrievalDict(TypedDict, total=False):4496  """Defines a retrieval tool that model can call to access external knowledge.44974498  This data type is not supported in Gemini API.4499  """45004501  disable_attribution: Optional[bool]4502  """Optional. Deprecated. This option is no longer supported."""45034504  external_api: Optional[ExternalApiDict]4505  """Use data source powered by external API for grounding."""45064507  vertex_ai_search: Optional[VertexAISearchDict]4508  """Set to use data source powered by Vertex AI Search."""45094510  vertex_rag_store: Optional[VertexRagStoreDict]4511  """Set to use data source powered by Vertex RAG store. User data is uploaded via the VertexRagDataService."""451245134514RetrievalOrDict = Union[Retrieval, RetrievalDict]451545164517class ComputerUse(_common.BaseModel):4518  """Tool to support computer use."""45194520  environment: Optional[Environment] = Field(4521      default=None, description="""Required. The environment being operated."""4522  )4523  excluded_predefined_functions: Optional[list[str]] = Field(4524      default=None,4525      description="""Optional. By default, [predefined functions](https://cloud.google.com/vertex-ai/generative-ai/docs/computer-use#supported-actions) are included in the final model call. Some of them can be explicitly excluded from being automatically included. This can serve two purposes: 1. Using a more restricted / different action space. 2. Improving the definitions / instructions of predefined functions.""",4526  )4527  enable_prompt_injection_detection: Optional[bool] = Field(4528      default=None,4529      description="""Optional. Enables the prompt injection detection check on computer-use request.""",4530  )4531  disabled_safety_policies: Optional[list[SafetyPolicy]] = Field(4532      default=None,4533      description="""Optional. Disabled safety policies for computer use. This field is not supported in Vertex AI.""",4534  )453545364537class ComputerUseDict(TypedDict, total=False):4538  """Tool to support computer use."""45394540  environment: Optional[Environment]4541  """Required. The environment being operated."""45424543  excluded_predefined_functions: Optional[list[str]]4544  """Optional. By default, [predefined functions](https://cloud.google.com/vertex-ai/generative-ai/docs/computer-use#supported-actions) are included in the final model call. Some of them can be explicitly excluded from being automatically included. This can serve two purposes: 1. Using a more restricted / different action space. 2. Improving the definitions / instructions of predefined functions."""45454546  enable_prompt_injection_detection: Optional[bool]4547  """Optional. Enables the prompt injection detection check on computer-use request."""45484549  disabled_safety_policies: Optional[list[SafetyPolicy]]4550  """Optional. Disabled safety policies for computer use. This field is not supported in Vertex AI."""455145524553ComputerUseOrDict = Union[ComputerUse, ComputerUseDict]455445554556class FileSearch(_common.BaseModel):4557  """The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora.45584559  Files are imported to Semantic Retrieval corpora using the ImportFile API.4560  This data type is not supported in Vertex AI.4561  """45624563  file_search_store_names: Optional[list[str]] = Field(4564      default=None,4565      description="""Required. The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`""",4566  )4567  top_k: Optional[int] = Field(4568      default=None,4569      description="""Optional. The number of semantic retrieval chunks to retrieve.""",4570  )4571  metadata_filter: Optional[str] = Field(4572      default=None,4573      description="""Optional. Metadata filter to apply to the semantic retrieval documents and chunks.""",4574  )457545764577class FileSearchDict(TypedDict, total=False):4578  """The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora.45794580  Files are imported to Semantic Retrieval corpora using the ImportFile API.4581  This data type is not supported in Vertex AI.4582  """45834584  file_search_store_names: Optional[list[str]]4585  """Required. The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`"""45864587  top_k: Optional[int]4588  """Optional. The number of semantic retrieval chunks to retrieve."""45894590  metadata_filter: Optional[str]4591  """Optional. Metadata filter to apply to the semantic retrieval documents and chunks."""459245934594FileSearchOrDict = Union[FileSearch, FileSearchDict]459545964597class WebSearch(_common.BaseModel):4598  """Standard web search for grounding and related configurations.45994600  Only text results are returned.4601  """46024603  pass460446054606class WebSearchDict(TypedDict, total=False):4607  """Standard web search for grounding and related configurations.46084609  Only text results are returned.4610  """46114612  pass461346144615WebSearchOrDict = Union[WebSearch, WebSearchDict]461646174618class ImageSearch(_common.BaseModel):4619  """Image search for grounding and related configurations."""46204621  pass462246234624class ImageSearchDict(TypedDict, total=False):4625  """Image search for grounding and related configurations."""46264627  pass462846294630ImageSearchOrDict = Union[ImageSearch, ImageSearchDict]463146324633class SearchTypes(_common.BaseModel):4634  """Different types of search that can be enabled on the GoogleSearch tool."""46354636  web_search: Optional[WebSearch] = Field(4637      default=None,4638      description="""Optional. Setting this field enables web search. Only text results are returned.""",4639  )4640  image_search: Optional[ImageSearch] = Field(4641      default=None,4642      description="""Optional. Setting this field enables image search. Image bytes are returned.""",4643  )464446454646class SearchTypesDict(TypedDict, total=False):4647  """Different types of search that can be enabled on the GoogleSearch tool."""46484649  web_search: Optional[WebSearchDict]4650  """Optional. Setting this field enables web search. Only text results are returned."""46514652  image_search: Optional[ImageSearchDict]4653  """Optional. Setting this field enables image search. Image bytes are returned."""465446554656SearchTypesOrDict = Union[SearchTypes, SearchTypesDict]465746584659class Interval(_common.BaseModel):4660  """Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive).46614662  The start must be less than or equal to the end. When the start equals the4663  end, the interval is empty (matches no time). When both start and end are4664  unspecified, the interval matches any time.4665  """46664667  end_time: Optional[datetime.datetime] = Field(4668      default=None,4669      description="""Optional. Exclusive end of the interval. If specified, a Timestamp matching this interval will have to be before the end.""",4670  )4671  start_time: Optional[datetime.datetime] = Field(4672      default=None,4673      description="""Optional. Inclusive start of the interval. If specified, a Timestamp matching this interval will have to be the same or after the start.""",4674  )467546764677class IntervalDict(TypedDict, total=False):4678  """Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive).46794680  The start must be less than or equal to the end. When the start equals the4681  end, the interval is empty (matches no time). When both start and end are4682  unspecified, the interval matches any time.4683  """46844685  end_time: Optional[datetime.datetime]4686  """Optional. Exclusive end of the interval. If specified, a Timestamp matching this interval will have to be before the end."""46874688  start_time: Optional[datetime.datetime]4689  """Optional. Inclusive start of the interval. If specified, a Timestamp matching this interval will have to be the same or after the start."""469046914692IntervalOrDict = Union[Interval, IntervalDict]469346944695class GoogleSearch(_common.BaseModel):4696  """GoogleSearch tool type.46974698  Tool to support Google Search in Model. Powered by Google.4699  """47004701  search_types: Optional[SearchTypes] = Field(4702      default=None,4703      description="""Optional. The set of search types to enable. If not set, web search is enabled by default.""",4704  )4705  blocking_confidence: Optional[PhishBlockThreshold] = Field(4706      default=None,4707      description="""Optional. Sites with confidence level chosen & above this value will be blocked from the search results. This field is not supported in Gemini API.""",4708  )4709  exclude_domains: Optional[list[str]] = Field(4710      default=None,4711      description="""Optional. List of domains to be excluded from the search results. The default limit is 2000 domains. Example: ["amazon.com", "facebook.com"]. This field is not supported in Gemini API.""",4712  )4713  time_range_filter: Optional[Interval] = Field(4714      default=None,4715      description="""Optional. Filter search results to a specific time range. If customers set a start time, they must set an end time (and vice versa). This field is not supported in Vertex AI.""",4716  )471747184719class GoogleSearchDict(TypedDict, total=False):4720  """GoogleSearch tool type.47214722  Tool to support Google Search in Model. Powered by Google.4723  """47244725  search_types: Optional[SearchTypesDict]4726  """Optional. The set of search types to enable. If not set, web search is enabled by default."""47274728  blocking_confidence: Optional[PhishBlockThreshold]4729  """Optional. Sites with confidence level chosen & above this value will be blocked from the search results. This field is not supported in Gemini API."""47304731  exclude_domains: Optional[list[str]]4732  """Optional. List of domains to be excluded from the search results. The default limit is 2000 domains. Example: ["amazon.com", "facebook.com"]. This field is not supported in Gemini API."""47334734  time_range_filter: Optional[IntervalDict]4735  """Optional. Filter search results to a specific time range. If customers set a start time, they must set an end time (and vice versa). This field is not supported in Vertex AI."""473647374738GoogleSearchOrDict = Union[GoogleSearch, GoogleSearchDict]473947404741class ToolCodeExecution(_common.BaseModel):4742  """Tool that executes code generated by the model, and automatically returns the result to the model.47434744  See also ExecutableCode and CodeExecutionResult, which are input and output to4745  this tool. This data type is not supported in Gemini API.4746  """47474748  pass474947504751class ToolCodeExecutionDict(TypedDict, total=False):4752  """Tool that executes code generated by the model, and automatically returns the result to the model.47534754  See also ExecutableCode and CodeExecutionResult, which are input and output to4755  this tool. This data type is not supported in Gemini API.4756  """47574758  pass475947604761ToolCodeExecutionOrDict = Union[ToolCodeExecution, ToolCodeExecutionDict]476247634764class EnterpriseWebSearch(_common.BaseModel):4765  """Tool to search public web data, powered by Vertex AI Search and Sec4 compliance.47664767  This data type is not supported in Gemini API.4768  """47694770  blocking_confidence: Optional[PhishBlockThreshold] = Field(4771      default=None,4772      description="""Optional. Sites with confidence level chosen & above this value will be blocked from the search results.""",4773  )4774  exclude_domains: Optional[list[str]] = Field(4775      default=None,4776      description="""Optional. List of domains to be excluded from the search results. The default limit is 2000 domains.""",4777  )477847794780class EnterpriseWebSearchDict(TypedDict, total=False):4781  """Tool to search public web data, powered by Vertex AI Search and Sec4 compliance.47824783  This data type is not supported in Gemini API.4784  """47854786  blocking_confidence: Optional[PhishBlockThreshold]4787  """Optional. Sites with confidence level chosen & above this value will be blocked from the search results."""47884789  exclude_domains: Optional[list[str]]4790  """Optional. List of domains to be excluded from the search results. The default limit is 2000 domains."""479147924793EnterpriseWebSearchOrDict = Union[EnterpriseWebSearch, EnterpriseWebSearchDict]479447954796class FunctionDeclaration(_common.BaseModel):4797  """Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3).47984799  Included in this declaration are the function name, description, parameters4800  and response type. This FunctionDeclaration is a representation of a block of4801  code that can be used as a `Tool` by the model and executed by the client.4802  """48034804  description: Optional[str] = Field(4805      default=None,4806      description="""Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function.""",4807  )4808  name: Optional[str] = Field(4809      default=None,4810      description="""Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots, colons and dashes, with a maximum length of 128.""",4811  )4812  parameters: Optional[Schema] = Field(4813      default=None,4814      description="""Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1""",4815  )4816  parameters_json_schema: Optional[Any] = Field(4817      default=None,4818      description="""Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: ``` { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } ``` This field is mutually exclusive with `parameters`.""",4819  )4820  response: Optional[Schema] = Field(4821      default=None,4822      description="""Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function.""",4823  )4824  response_json_schema: Optional[Any] = Field(4825      default=None,4826      description="""Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with `response`.""",4827  )4828  behavior: Optional[Behavior] = Field(4829      default=None,4830      description="""Optional. Specifies the function Behavior. If not specified, the system keeps the current function call behavior. This field is currently only supported by the BidiGenerateContent method.""",4831  )48324833  @classmethod4834  def from_callable_with_api_option(4835      cls,4836      *,4837      callable: Callable[..., Any],4838      api_option: Literal[4839          'ENTERPRISE', 'GEMINI_API', 'VERTEX_AI'4840      ] = 'GEMINI_API',4841      behavior: Optional[Behavior] = None,4842      use_json_schema: bool = False,4843  ) -> 'FunctionDeclaration':4844    """Converts a Callable to a FunctionDeclaration based on the API option.48454846    Supported API option is 'ENTERPRISE', 'GEMINI_API' or 'VERTEX_AI'. If4847    api_option is unset, it will default to 'GEMINI_API'. If unsupported4848    api_option is provided, it will raise ValueError.4849    Note: 'VERTEX_AI' is to be deprecated, please use 'ENTERPRISE' instead.4850    """4851    supported_api_options = ['ENTERPRISE', 'GEMINI_API', 'VERTEX_AI']4852    if api_option not in supported_api_options:4853      raise ValueError(4854          f'Unsupported api_option value: {api_option}. Supported api_option'4855          f' value is one of: {supported_api_options}.'4856      )4857    from . import _automatic_function_calling_util48584859    if use_json_schema:4860      return _automatic_function_calling_util.parse_function_declaration_json_schema(4861          callable=callable,4862          behavior=behavior,4863      )48644865    parameters_properties = {}4866    parameters_json_schema = {}4867    annotation_under_future = typing.get_type_hints(callable)4868    try:4869      for name, param in inspect.signature(callable).parameters.items():4870        if param.kind in (4871            inspect.Parameter.POSITIONAL_OR_KEYWORD,4872            inspect.Parameter.KEYWORD_ONLY,4873            inspect.Parameter.POSITIONAL_ONLY,4874        ):4875          param = _automatic_function_calling_util._handle_params_as_deferred_annotations(4876              param, annotation_under_future, name4877          )4878          schema = (4879              _automatic_function_calling_util._parse_schema_from_parameter(4880                  api_option, param, callable.__name__4881              )4882          )4883          parameters_properties[name] = schema4884    except ValueError:4885      parameters_properties = {}4886      for name, param in inspect.signature(callable).parameters.items():4887        if param.kind in (4888            inspect.Parameter.POSITIONAL_OR_KEYWORD,4889            inspect.Parameter.KEYWORD_ONLY,4890            inspect.Parameter.POSITIONAL_ONLY,4891        ):4892          try:4893            param = _automatic_function_calling_util._handle_params_as_deferred_annotations(4894                param, annotation_under_future, name4895            )4896            param_schema_adapter = pydantic.TypeAdapter(4897                param.annotation,4898                config=pydantic.ConfigDict(arbitrary_types_allowed=True),4899            )4900            json_schema_dict = param_schema_adapter.json_schema()4901            json_schema_dict = _automatic_function_calling_util._add_unevaluated_items_to_fixed_len_tuple_schema(4902                json_schema_dict4903            )4904            if 'prefixItems' in json_schema_dict:4905              parameters_json_schema[name] = json_schema_dict4906              continue49074908            union_args = typing.get_args(param.annotation)4909            has_primitive = any(4910                _automatic_function_calling_util._is_builtin_primitive_or_compound(4911                    arg4912                )4913                for arg in union_args4914            )4915            if (4916                '$ref' in json_schema_dict or '$defs' in json_schema_dict4917            ) and has_primitive:4918              # This is a complex schema with a primitive (e.g., str | MyModel)4919              # that is better represented by raw JSON schema.4920              parameters_json_schema[name] = json_schema_dict4921              continue49224923            schema = Schema.from_json_schema(4924                json_schema=JSONSchema(**json_schema_dict),4925                api_option=api_option,4926            )4927            if param.default is not inspect.Parameter.empty:4928              schema.default = param.default4929            parameters_properties[name] = schema4930          except Exception as e:4931            _automatic_function_calling_util._raise_for_unsupported_param(4932                param, callable.__name__, e4933            )49344935    declaration = FunctionDeclaration(4936        name=callable.__name__,4937        description=inspect.cleandoc(callable.__doc__)4938        if callable.__doc__4939        else callable.__doc__,4940        behavior=behavior,4941    )4942    if parameters_properties:4943      declaration.parameters = Schema(4944          type='OBJECT',4945          properties=parameters_properties,4946      )4947      declaration.parameters.required = (4948          _automatic_function_calling_util._get_required_fields(4949              declaration.parameters4950          )4951      )4952    elif parameters_json_schema:4953      declaration.parameters_json_schema = parameters_json_schema4954    # TODO: b/421991354 - Remove this check once the bug is fixed.4955    if api_option == 'GEMINI_API':4956      return declaration49574958    return_annotation = inspect.signature(callable).return_annotation4959    if return_annotation is inspect._empty:4960      return declaration49614962    return_value = inspect.Parameter(4963        'return_value',4964        inspect.Parameter.POSITIONAL_OR_KEYWORD,4965        annotation=return_annotation,4966    )49674968    # This snippet catches the case when type hints are stored as strings4969    if isinstance(return_value.annotation, str):4970      return_value = return_value.replace(4971          annotation=annotation_under_future['return']4972      )4973    response_schema: Optional[Schema] = None4974    response_json_schema: Optional[Union[dict[str, Any], Schema]] = {}4975    try:4976      response_schema = (4977          _automatic_function_calling_util._parse_schema_from_parameter(4978              api_option,4979              return_value,4980              callable.__name__,4981          )4982      )4983      if response_schema.any_of is not None:4984        # To handle any_of, we need to use responseJsonSchema4985        response_json_schema = response_schema4986        response_schema = None4987    except ValueError:4988      try:4989        return_value_schema_adapter = pydantic.TypeAdapter(4990            return_value.annotation,4991            config=pydantic.ConfigDict(arbitrary_types_allowed=True),4992        )4993        response_json_schema = return_value_schema_adapter.json_schema()4994        response_json_schema = _automatic_function_calling_util._add_unevaluated_items_to_fixed_len_tuple_schema(4995            response_json_schema4996        )4997      except Exception as e:4998        _automatic_function_calling_util._raise_for_unsupported_param(4999            return_value, callable.__name__, e5000        )50015002    if response_schema:5003      declaration.response = response_schema5004    elif response_json_schema:5005      declaration.response_json_schema = response_json_schema5006    return declaration50075008  @classmethod5009  def from_callable(5010      cls,5011      *,5012      client: 'BaseApiClient',5013      callable: Callable[..., Any],5014      behavior: Optional[Behavior] = None,5015      use_json_schema: bool = False,5016  ) -> 'FunctionDeclaration':5017    """Converts a Callable to a FunctionDeclaration based on the client.50185019    Note: For best results prefer5020    [Google-style5021    docstring](https://google.github.io/styleguide/pyguide.html#383-functions-and-methods)5022    when describing arguments. This function does **not** parse argument5023    descriptions into the property description slots of the resulting structure.5024    Instead it sends the whole docstring in the top-level function description.5025    Google-style docstring are closest to what the model is trained on.5026    """5027    if client.vertexai:5028      return cls.from_callable_with_api_option(5029          callable=callable,5030          api_option='ENTERPRISE',5031          behavior=behavior,5032          use_json_schema=use_json_schema,5033      )5034    else:5035      return cls.from_callable_with_api_option(5036          callable=callable,5037          api_option='GEMINI_API',5038          behavior=behavior,5039          use_json_schema=use_json_schema,5040      )504150425043class FunctionDeclarationDict(TypedDict, total=False):5044  """Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3).50455046  Included in this declaration are the function name, description, parameters5047  and response type. This FunctionDeclaration is a representation of a block of5048  code that can be used as a `Tool` by the model and executed by the client.5049  """50505051  description: Optional[str]5052  """Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function."""50535054  name: Optional[str]5055  """Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots, colons and dashes, with a maximum length of 128."""50565057  parameters: Optional[SchemaDict]5058  """Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1"""50595060  parameters_json_schema: Optional[Any]5061  """Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: ``` { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } ``` This field is mutually exclusive with `parameters`."""50625063  response: Optional[SchemaDict]5064  """Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function."""50655066  response_json_schema: Optional[Any]5067  """Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with `response`."""50685069  behavior: Optional[Behavior]5070  """Optional. Specifies the function Behavior. If not specified, the system keeps the current function call behavior. This field is currently only supported by the BidiGenerateContent method."""507150725073FunctionDeclarationOrDict = Union[FunctionDeclaration, FunctionDeclarationDict]507450755076class DynamicRetrievalConfig(_common.BaseModel):5077  """Describes the options to customize dynamic retrieval."""50785079  dynamic_threshold: Optional[float] = Field(5080      default=None,5081      description="""Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used.""",5082  )5083  mode: Optional[DynamicRetrievalConfigMode] = Field(5084      default=None,5085      description="""The mode of the predictor to be used in dynamic retrieval.""",5086  )508750885089class DynamicRetrievalConfigDict(TypedDict, total=False):5090  """Describes the options to customize dynamic retrieval."""50915092  dynamic_threshold: Optional[float]5093  """Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used."""50945095  mode: Optional[DynamicRetrievalConfigMode]5096  """The mode of the predictor to be used in dynamic retrieval."""509750985099DynamicRetrievalConfigOrDict = Union[5100    DynamicRetrievalConfig, DynamicRetrievalConfigDict5101]510251035104class GoogleSearchRetrieval(_common.BaseModel):5105  """Tool to retrieve public web data for grounding, powered by Google."""51065107  dynamic_retrieval_config: Optional[DynamicRetrievalConfig] = Field(5108      default=None,5109      description="""Specifies the dynamic retrieval configuration for the given source.""",5110  )511151125113class GoogleSearchRetrievalDict(TypedDict, total=False):5114  """Tool to retrieve public web data for grounding, powered by Google."""51155116  dynamic_retrieval_config: Optional[DynamicRetrievalConfigDict]5117  """Specifies the dynamic retrieval configuration for the given source."""511851195120GoogleSearchRetrievalOrDict = Union[5121    GoogleSearchRetrieval, GoogleSearchRetrievalDict5122]512351245125class ToolParallelAiSearch(_common.BaseModel):5126  """ParallelAiSearch tool type.51275128  A tool that uses the Parallel.ai search engine for grounding. This data type5129  is not supported in Gemini API.5130  """51315132  api_key: Optional[str] = Field(5133      default=None,5134      description="""Optional. The API key for ParallelAiSearch. If an API key is not provided, the system will attempt to verify access by checking for an active Parallel.ai subscription through the Google Cloud Marketplace. See https://docs.parallel.ai/search/search-quickstart for more details.""",5135  )5136  custom_configs: Optional[dict[str, Any]] = Field(5137      default=None,5138      description="""Optional. Custom configs for ParallelAiSearch. This field can be used to pass any parameter from the Parallel.ai Search API. See the Parallel.ai documentation for the full list of available parameters and their usage: https://docs.parallel.ai/api-reference/search-beta/search Currently only `source_policy`, `excerpts`, `max_results`, `mode`, `fetch_policy` can be set via this field. For example: { "source_policy": { "include_domains": ["google.com", "wikipedia.org"], "exclude_domains": ["example.com"] }, "fetch_policy": { "max_age_seconds": 3600 } }""",5139  )5140  enable_data_retention: Optional[bool] = Field(5141      default=None,5142      description="""Optional. Deprecated: Use `enable_zero_data_retention` instead. Instructs Vertex Grounding to use Parallel's Zero Data Retention Marketplace product. If this value is "false" or omitted, the Parallel Web Search for Grounding standard subscription will be used. If this value is "true", the Parallel Web Search for Grounding - ZDR subscription will be used.""",5143  )5144  enable_zero_data_retention: Optional[bool] = Field(5145      default=None,5146      description="""Optional. Instructs Vertex Grounding to use Parallel's Zero Data Retention Marketplace product. If this value is "false" or omitted, the Parallel Web Search for Grounding standard subscription will be used. If this value is "true", the Parallel Web Search for Grounding - ZDR subscription will be used.""",5147  )514851495150class ToolParallelAiSearchDict(TypedDict, total=False):5151  """ParallelAiSearch tool type.51525153  A tool that uses the Parallel.ai search engine for grounding. This data type5154  is not supported in Gemini API.5155  """51565157  api_key: Optional[str]5158  """Optional. The API key for ParallelAiSearch. If an API key is not provided, the system will attempt to verify access by checking for an active Parallel.ai subscription through the Google Cloud Marketplace. See https://docs.parallel.ai/search/search-quickstart for more details."""51595160  custom_configs: Optional[dict[str, Any]]5161  """Optional. Custom configs for ParallelAiSearch. This field can be used to pass any parameter from the Parallel.ai Search API. See the Parallel.ai documentation for the full list of available parameters and their usage: https://docs.parallel.ai/api-reference/search-beta/search Currently only `source_policy`, `excerpts`, `max_results`, `mode`, `fetch_policy` can be set via this field. For example: { "source_policy": { "include_domains": ["google.com", "wikipedia.org"], "exclude_domains": ["example.com"] }, "fetch_policy": { "max_age_seconds": 3600 } }"""51625163  enable_data_retention: Optional[bool]5164  """Optional. Deprecated: Use `enable_zero_data_retention` instead. Instructs Vertex Grounding to use Parallel's Zero Data Retention Marketplace product. If this value is "false" or omitted, the Parallel Web Search for Grounding standard subscription will be used. If this value is "true", the Parallel Web Search for Grounding - ZDR subscription will be used."""51655166  enable_zero_data_retention: Optional[bool]5167  """Optional. Instructs Vertex Grounding to use Parallel's Zero Data Retention Marketplace product. If this value is "false" or omitted, the Parallel Web Search for Grounding standard subscription will be used. If this value is "true", the Parallel Web Search for Grounding - ZDR subscription will be used."""516851695170ToolParallelAiSearchOrDict = Union[5171    ToolParallelAiSearch, ToolParallelAiSearchDict5172]517351745175class UrlContext(_common.BaseModel):5176  """Tool to support URL context."""51775178  pass517951805181class UrlContextDict(TypedDict, total=False):5182  """Tool to support URL context."""51835184  pass518551865187UrlContextOrDict = Union[UrlContext, UrlContextDict]518851895190class StreamableHttpTransport(_common.BaseModel):5191  """A transport that can stream HTTP requests and responses.51925193  Next ID: 6. This data type is not supported in Vertex AI.5194  """51955196  headers: Optional[dict[str, str]] = Field(5197      default=None,5198      description="""Optional: Fields for authentication headers, timeouts, etc., if needed.""",5199  )5200  sse_read_timeout: Optional[str] = Field(5201      default=None, description="""Timeout for SSE read operations."""5202  )5203  terminate_on_close: Optional[bool] = Field(5204      default=None,5205      description="""Whether to close the client session when the transport closes.""",5206  )5207  timeout: Optional[str] = Field(5208      default=None, description="""HTTP timeout for regular operations."""5209  )5210  url: Optional[str] = Field(5211      default=None,5212      description="""The full URL for the MCPServer endpoint. Example: "https://api.example.com/mcp".""",5213  )521452155216class StreamableHttpTransportDict(TypedDict, total=False):5217  """A transport that can stream HTTP requests and responses.52185219  Next ID: 6. This data type is not supported in Vertex AI.5220  """52215222  headers: Optional[dict[str, str]]5223  """Optional: Fields for authentication headers, timeouts, etc., if needed."""52245225  sse_read_timeout: Optional[str]5226  """Timeout for SSE read operations."""52275228  terminate_on_close: Optional[bool]5229  """Whether to close the client session when the transport closes."""52305231  timeout: Optional[str]5232  """HTTP timeout for regular operations."""52335234  url: Optional[str]5235  """The full URL for the MCPServer endpoint. Example: "https://api.example.com/mcp"."""523652375238StreamableHttpTransportOrDict = Union[5239    StreamableHttpTransport, StreamableHttpTransportDict5240]524152425243class McpServer(_common.BaseModel):5244  """A MCPServer is a server that can be called by the model to perform actions.52455246  It is a server that implements the MCP protocol. Next ID: 7. This data type is5247  not supported in Vertex AI.5248  """52495250  name: Optional[str] = Field(5251      default=None, description="""The name of the MCPServer."""5252  )5253  streamable_http_transport: Optional[StreamableHttpTransport] = Field(5254      default=None,5255      description="""A transport that can stream HTTP requests and responses.""",5256  )525752585259class McpServerDict(TypedDict, total=False):5260  """A MCPServer is a server that can be called by the model to perform actions.52615262  It is a server that implements the MCP protocol. Next ID: 7. This data type is5263  not supported in Vertex AI.5264  """52655266  name: Optional[str]5267  """The name of the MCPServer."""52685269  streamable_http_transport: Optional[StreamableHttpTransportDict]5270  """A transport that can stream HTTP requests and responses."""527152725273McpServerOrDict = Union[McpServer, McpServerDict]527452755276class ToolExaAiSearch(_common.BaseModel):5277  """ExaAiSearch tool type.52785279  A tool that uses the Exa.ai search engine for grounding. This data type is not5280  supported in Gemini API.5281  """52825283  api_key: Optional[str] = Field(5284      default=None, description="""Required. The API key for ExaAiSearch."""5285  )5286  custom_configs: Optional[dict[str, Any]] = Field(5287      default=None,5288      description="""Optional. This field can be used to pass any parameter from the Exa.ai Search API.""",5289  )529052915292class ToolExaAiSearchDict(TypedDict, total=False):5293  """ExaAiSearch tool type.52945295  A tool that uses the Exa.ai search engine for grounding. This data type is not5296  supported in Gemini API.5297  """52985299  api_key: Optional[str]5300  """Required. The API key for ExaAiSearch."""53015302  custom_configs: Optional[dict[str, Any]]5303  """Optional. This field can be used to pass any parameter from the Exa.ai Search API."""530453055306ToolExaAiSearchOrDict = Union[ToolExaAiSearch, ToolExaAiSearchDict]530753085309class Tool(_common.BaseModel):5310  """Tool details of a tool that the model may use to generate a response."""53115312  retrieval: Optional[Retrieval] = Field(5313      default=None,5314      description="""Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation. This field is not supported in Gemini API.""",5315  )5316  computer_use: Optional[ComputerUse] = Field(5317      default=None,5318      description="""Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.""",5319  )5320  file_search: Optional[FileSearch] = Field(5321      default=None,5322      description="""Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora. This field is not supported in Vertex AI.""",5323  )5324  google_search: Optional[GoogleSearch] = Field(5325      default=None,5326      description="""Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.""",5327  )5328  google_maps: Optional[GoogleMaps] = Field(5329      default=None,5330      description="""Optional. Tool that allows grounding the model's response with5331      geospatial context related to the user's query.""",5332  )5333  code_execution: Optional[ToolCodeExecution] = Field(5334      default=None,5335      description="""Optional. CodeExecution tool type. Enables the model to execute code as part of generation.""",5336  )5337  enterprise_web_search: Optional[EnterpriseWebSearch] = Field(5338      default=None,5339      description="""Optional. Tool to support searching public web data, powered by Vertex AI Search and Sec4 compliance. This field is not supported in Gemini API.""",5340  )5341  function_declarations: Optional[list[FunctionDeclaration]] = Field(5342      default=None,5343      description="""Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 512 function declarations can be provided.""",5344  )5345  google_search_retrieval: Optional[GoogleSearchRetrieval] = Field(5346      default=None,5347      description="""Optional. Specialized retrieval tool that is powered by Google Search.""",5348  )5349  parallel_ai_search: Optional[ToolParallelAiSearch] = Field(5350      default=None,5351      description="""Optional. If specified, Vertex AI will use Parallel.ai to search for information to answer user queries. The search results will be grounded on Parallel.ai and presented to the model for response generation. This field is not supported in Gemini API.""",5352  )5353  url_context: Optional[UrlContext] = Field(5354      default=None,5355      description="""Optional. Tool to support URL context retrieval.""",5356  )5357  mcp_servers: Optional[list[McpServer]] = Field(5358      default=None,5359      description="""Optional. MCP Servers to connect to. This field is not supported in Vertex AI.""",5360  )5361  exa_ai_search: Optional[ToolExaAiSearch] = Field(5362      default=None,5363      description="""Optional. Uses Exa.ai to search for information to answer user queries. The search results will be grounded on Exa.ai and presented to the model for response generation. This field is not supported in Gemini API.""",5364  )536553665367class ToolDict(TypedDict, total=False):5368  """Tool details of a tool that the model may use to generate a response."""53695370  retrieval: Optional[RetrievalDict]5371  """Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation. This field is not supported in Gemini API."""53725373  computer_use: Optional[ComputerUseDict]5374  """Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations."""53755376  file_search: Optional[FileSearchDict]5377  """Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora. This field is not supported in Vertex AI."""53785379  google_search: Optional[GoogleSearchDict]5380  """Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google."""53815382  google_maps: Optional[GoogleMapsDict]5383  """Optional. Tool that allows grounding the model's response with5384      geospatial context related to the user's query."""53855386  code_execution: Optional[ToolCodeExecutionDict]5387  """Optional. CodeExecution tool type. Enables the model to execute code as part of generation."""53885389  enterprise_web_search: Optional[EnterpriseWebSearchDict]5390  """Optional. Tool to support searching public web data, powered by Vertex AI Search and Sec4 compliance. This field is not supported in Gemini API."""53915392  function_declarations: Optional[list[FunctionDeclarationDict]]5393  """Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 512 function declarations can be provided."""53945395  google_search_retrieval: Optional[GoogleSearchRetrievalDict]5396  """Optional. Specialized retrieval tool that is powered by Google Search."""53975398  parallel_ai_search: Optional[ToolParallelAiSearchDict]5399  """Optional. If specified, Vertex AI will use Parallel.ai to search for information to answer user queries. The search results will be grounded on Parallel.ai and presented to the model for response generation. This field is not supported in Gemini API."""54005401  url_context: Optional[UrlContextDict]5402  """Optional. Tool to support URL context retrieval."""54035404  mcp_servers: Optional[list[McpServerDict]]5405  """Optional. MCP Servers to connect to. This field is not supported in Vertex AI."""54065407  exa_ai_search: Optional[ToolExaAiSearchDict]5408  """Optional. Uses Exa.ai to search for information to answer user queries. The search results will be grounded on Exa.ai and presented to the model for response generation. This field is not supported in Gemini API."""540954105411ToolOrDict = Union[Tool, ToolDict]541254135414def _validate_tool_list(v: object, handler: Any) -> Any:5415  """Pass MCP tool/session objects through Pydantic validation untouched.54165417  `Tool` has all-optional fields, so without this wrapper Pydantic's default5418  Union resolution would coerce any non-Tool item (e.g. an `mcp.ClientSession`)5419  into an empty `Tool()`. This wrapper dispatches dict -> Tool and leaves5420  every other type identity-preserved so MCP routing downstream still works.5421  """5422  if v is None:5423    return None5424  if not isinstance(v, list):5425    return handler(v)5426  out = []5427  for item in v:5428    if isinstance(item, dict):5429      out.append(Tool.model_validate(item))5430    else:5431      out.append(item)5432  return out543354345435if typing.TYPE_CHECKING:5436  ToolUnion = Union[Tool, Callable[..., Any], mcp_types.Tool, McpClientSession]5437  ToolUnionDict = Union[5438      ToolDict, Callable[..., Any], mcp_types.Tool, McpClientSession5439  ]5440  ToolListUnion = list[ToolUnion]5441  ToolListUnionDict = list[ToolUnionDict]5442else:5443  ToolUnion = Union[Tool, Callable[..., Any]]  # type: ignore[misc]5444  ToolUnionDict = Union[ToolDict, Callable[..., Any]]  # type: ignore[misc]5445  ToolListUnion = Annotated[list, WrapValidator(_validate_tool_list)]5446  ToolListUnionDict = list[ToolUnionDict]54475448SchemaUnion = Union[5449    dict[Any, Any], type, Schema, builtin_types.GenericAlias, VersionedUnionType  # type: ignore[valid-type]5450]5451SchemaUnionDict = Union[SchemaUnion, SchemaDict]545254535454class VoiceConsentSignature(_common.BaseModel):5455  """The signature of the voice consent check."""54565457  signature: Optional[str] = Field(5458      default=None,5459      description="""The signature string.5460      """,5461  )546254635464class VoiceConsentSignatureDict(TypedDict, total=False):5465  """The signature of the voice consent check."""54665467  signature: Optional[str]5468  """The signature string.5469      """547054715472VoiceConsentSignatureOrDict = Union[5473    VoiceConsentSignature, VoiceConsentSignatureDict5474]547554765477class ReplicatedVoiceConfig(_common.BaseModel):5478  """The configuration for the replicated voice to use."""54795480  mime_type: Optional[str] = Field(5481      default=None,5482      description="""The mimetype of the voice sample. The only currently supported5483      value is `audio/wav`. This represents 16-bit signed little-endian wav5484      data, with a 24kHz sampling rate.5485      """,5486  )5487  voice_sample_audio: Optional[bytes] = Field(5488      default=None,5489      description="""The sample of the custom voice.5490      """,5491  )5492  consent_audio: Optional[bytes] = Field(5493      default=None,5494      description="""Recorded consent verifying ownership of the voice. This5495      represents 16-bit signed little-endian wav data, with a 24kHz sampling5496      rate.""",5497  )5498  voice_consent_signature: Optional[VoiceConsentSignature] = Field(5499      default=None,5500      description="""Signature of a previously verified consent audio. This should be5501      populated with a signature generated by the server for a previous5502      request containing the consent_audio field. When provided, the5503      signature is verified instead of the consent_audio field to reduce5504      latency. Requests will fail if the signature is invalid or expired.""",5505  )550655075508class ReplicatedVoiceConfigDict(TypedDict, total=False):5509  """The configuration for the replicated voice to use."""55105511  mime_type: Optional[str]5512  """The mimetype of the voice sample. The only currently supported5513      value is `audio/wav`. This represents 16-bit signed little-endian wav5514      data, with a 24kHz sampling rate.5515      """55165517  voice_sample_audio: Optional[bytes]5518  """The sample of the custom voice.5519      """55205521  consent_audio: Optional[bytes]5522  """Recorded consent verifying ownership of the voice. This5523      represents 16-bit signed little-endian wav data, with a 24kHz sampling5524      rate."""55255526  voice_consent_signature: Optional[VoiceConsentSignatureDict]5527  """Signature of a previously verified consent audio. This should be5528      populated with a signature generated by the server for a previous5529      request containing the consent_audio field. When provided, the5530      signature is verified instead of the consent_audio field to reduce5531      latency. Requests will fail if the signature is invalid or expired."""553255335534ReplicatedVoiceConfigOrDict = Union[5535    ReplicatedVoiceConfig, ReplicatedVoiceConfigDict5536]553755385539class PrebuiltVoiceConfig(_common.BaseModel):5540  """Configuration for a prebuilt voice."""55415542  voice_name: Optional[str] = Field(5543      default=None, description="""The name of the prebuilt voice to use."""5544  )554555465547class PrebuiltVoiceConfigDict(TypedDict, total=False):5548  """Configuration for a prebuilt voice."""55495550  voice_name: Optional[str]5551  """The name of the prebuilt voice to use."""555255535554PrebuiltVoiceConfigOrDict = Union[PrebuiltVoiceConfig, PrebuiltVoiceConfigDict]555555565557class VoiceConfig(_common.BaseModel):5558  """The configuration for the voice to use."""55595560  replicated_voice_config: Optional[ReplicatedVoiceConfig] = Field(5561      default=None,5562      description="""The configuration for a replicated voice, which is a clone of a5563      user's voice that can be used for speech synthesis. If this is unset, a5564      default voice is used.""",5565  )5566  prebuilt_voice_config: Optional[PrebuiltVoiceConfig] = Field(5567      default=None, description="""The configuration for a prebuilt voice."""5568  )556955705571class VoiceConfigDict(TypedDict, total=False):5572  """The configuration for the voice to use."""55735574  replicated_voice_config: Optional[ReplicatedVoiceConfigDict]5575  """The configuration for a replicated voice, which is a clone of a5576      user's voice that can be used for speech synthesis. If this is unset, a5577      default voice is used."""55785579  prebuilt_voice_config: Optional[PrebuiltVoiceConfigDict]5580  """The configuration for a prebuilt voice."""558155825583VoiceConfigOrDict = Union[VoiceConfig, VoiceConfigDict]558455855586class SpeakerVoiceConfig(_common.BaseModel):5587  """Configuration for a single speaker in a multi-speaker setup."""55885589  speaker: Optional[str] = Field(5590      default=None,5591      description="""Required. The name of the speaker. This should be the same as the speaker name used in the prompt.""",5592  )5593  voice_config: Optional[VoiceConfig] = Field(5594      default=None,5595      description="""Required. The configuration for the voice of this speaker.""",5596  )559755985599class SpeakerVoiceConfigDict(TypedDict, total=False):5600  """Configuration for a single speaker in a multi-speaker setup."""56015602  speaker: Optional[str]5603  """Required. The name of the speaker. This should be the same as the speaker name used in the prompt."""56045605  voice_config: Optional[VoiceConfigDict]5606  """Required. The configuration for the voice of this speaker."""560756085609SpeakerVoiceConfigOrDict = Union[SpeakerVoiceConfig, SpeakerVoiceConfigDict]561056115612class MultiSpeakerVoiceConfig(_common.BaseModel):5613  """Configuration for a multi-speaker text-to-speech request."""56145615  speaker_voice_configs: Optional[list[SpeakerVoiceConfig]] = Field(5616      default=None,5617      description="""Required. A list of configurations for the voices of the speakers. Exactly two speaker voice configurations must be provided.""",5618  )561956205621class MultiSpeakerVoiceConfigDict(TypedDict, total=False):5622  """Configuration for a multi-speaker text-to-speech request."""56235624  speaker_voice_configs: Optional[list[SpeakerVoiceConfigDict]]5625  """Required. A list of configurations for the voices of the speakers. Exactly two speaker voice configurations must be provided."""562656275628MultiSpeakerVoiceConfigOrDict = Union[5629    MultiSpeakerVoiceConfig, MultiSpeakerVoiceConfigDict5630]563156325633class SpeechConfig(_common.BaseModel):5634  """Config for speech generation and transcription."""56355636  voice_config: Optional[VoiceConfig] = Field(5637      default=None,5638      description="""The configuration in case of single-voice output.""",5639  )5640  language_code: Optional[str] = Field(5641      default=None,5642      description="""Optional. The language code (ISO 639-1) for the speech synthesis.""",5643  )5644  multi_speaker_voice_config: Optional[MultiSpeakerVoiceConfig] = Field(5645      default=None,5646      description="""The configuration for a multi-speaker text-to-speech request. This field is mutually exclusive with `voice_config`.""",5647  )564856495650class SpeechConfigDict(TypedDict, total=False):5651  """Config for speech generation and transcription."""56525653  voice_config: Optional[VoiceConfigDict]5654  """The configuration in case of single-voice output."""56555656  language_code: Optional[str]5657  """Optional. The language code (ISO 639-1) for the speech synthesis."""56585659  multi_speaker_voice_config: Optional[MultiSpeakerVoiceConfigDict]5660  """The configuration for a multi-speaker text-to-speech request. This field is mutually exclusive with `voice_config`."""566156625663SpeechConfigOrDict = Union[SpeechConfig, SpeechConfigDict]566456655666class AutomaticFunctionCallingConfig(_common.BaseModel):5667  """The configuration for automatic function calling."""56685669  disable: Optional[bool] = Field(5670      default=None,5671      description="""Whether to disable automatic function calling.5672      If not set or set to False, will enable automatic function calling.5673      If set to True, will disable automatic function calling.5674      """,5675  )5676  maximum_remote_calls: Optional[int] = Field(5677      default=10,5678      description="""If automatic function calling is enabled,5679      maximum number of remote calls for automatic function calling.5680      This number should be a positive integer.5681      If not set, SDK will set maximum number of remote calls to 10.5682      """,5683  )5684  ignore_call_history: Optional[bool] = Field(5685      default=None,5686      description="""If automatic function calling is enabled,5687      whether to ignore call history to the response.5688      If not set, SDK will set ignore_call_history to false,5689      and will append the call history to5690      GenerateContentResponse.automatic_function_calling_history.5691      """,5692  )569356945695class AutomaticFunctionCallingConfigDict(TypedDict, total=False):5696  """The configuration for automatic function calling."""56975698  disable: Optional[bool]5699  """Whether to disable automatic function calling.5700      If not set or set to False, will enable automatic function calling.5701      If set to True, will disable automatic function calling.5702      """57035704  maximum_remote_calls: Optional[int]5705  """If automatic function calling is enabled,5706      maximum number of remote calls for automatic function calling.5707      This number should be a positive integer.5708      If not set, SDK will set maximum number of remote calls to 10.5709      """57105711  ignore_call_history: Optional[bool]5712  """If automatic function calling is enabled,5713      whether to ignore call history to the response.5714      If not set, SDK will set ignore_call_history to false,5715      and will append the call history to5716      GenerateContentResponse.automatic_function_calling_history.5717      """571857195720AutomaticFunctionCallingConfigOrDict = Union[5721    AutomaticFunctionCallingConfig, AutomaticFunctionCallingConfigDict5722]572357245725class ThinkingConfig(_common.BaseModel):5726  """The thinking features configuration."""57275728  include_thoughts: Optional[bool] = Field(5729      default=None,5730      description="""Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.5731      """,5732  )5733  thinking_budget: Optional[int] = Field(5734      default=None,5735      description="""Indicates the thinking budget in tokens. 0 is DISABLED. -1 is AUTOMATIC. The default values and allowed ranges are model dependent.5736      """,5737  )5738  thinking_level: Optional[ThinkingLevel] = Field(5739      default=None,5740      description="""Optional. The number of thoughts tokens that the model should generate.""",5741  )574257435744class ThinkingConfigDict(TypedDict, total=False):5745  """The thinking features configuration."""57465747  include_thoughts: Optional[bool]5748  """Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.5749      """57505751  thinking_budget: Optional[int]5752  """Indicates the thinking budget in tokens. 0 is DISABLED. -1 is AUTOMATIC. The default values and allowed ranges are model dependent.5753      """57545755  thinking_level: Optional[ThinkingLevel]5756  """Optional. The number of thoughts tokens that the model should generate."""575757585759ThinkingConfigOrDict = Union[ThinkingConfig, ThinkingConfigDict]576057615762class ImageConfigImageOutputOptions(_common.BaseModel):5763  """The image output format for generated images.57645765  This data type is not supported in Gemini API.5766  """57675768  compression_quality: Optional[int] = Field(5769      default=None,5770      description="""Optional. The compression quality of the output image.""",5771  )5772  mime_type: Optional[str] = Field(5773      default=None,5774      description="""Optional. The image format that the output should be saved as.""",5775  )577657775778class ImageConfigImageOutputOptionsDict(TypedDict, total=False):5779  """The image output format for generated images.57805781  This data type is not supported in Gemini API.5782  """57835784  compression_quality: Optional[int]5785  """Optional. The compression quality of the output image."""57865787  mime_type: Optional[str]5788  """Optional. The image format that the output should be saved as."""578957905791ImageConfigImageOutputOptionsOrDict = Union[5792    ImageConfigImageOutputOptions, ImageConfigImageOutputOptionsDict5793]579457955796class ImageConfig(_common.BaseModel):5797  """The image generation configuration to be used in GenerateContentConfig."""57985799  aspect_ratio: Optional[str] = Field(5800      default=None,5801      description="""Aspect ratio of the generated images. Supported values are5802      "1:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9", and "21:9".""",5803  )5804  image_size: Optional[str] = Field(5805      default=None,5806      description="""Optional. Specifies the size of generated images. Supported5807      values are `1K`, `2K`, `4K`. If not specified, the model will use default5808      value `1K`.""",5809  )5810  person_generation: Optional[str] = Field(5811      default=None,5812      description="""Controls the generation of people. Supported values are:5813      ALLOW_ALL, ALLOW_ADULT, ALLOW_NONE.""",5814  )5815  prominent_people: Optional[ProminentPeople] = Field(5816      default=None,5817      description="""Optional. Controls whether prominent people (celebrities) generation is allowed. If used with personGeneration, personGeneration enum would take precedence. For instance, if ALLOW_NONE is set, all person generation would be blocked. If this field is unspecified, the default behavior is to allow prominent people. This field is not supported in Gemini API.""",5818  )5819  output_mime_type: Optional[str] = Field(5820      default=None,5821      description="""MIME type of the generated image. This field is not5822      supported in Gemini API.""",5823  )5824  output_compression_quality: Optional[int] = Field(5825      default=None,5826      description="""Compression quality of the generated image (for5827      ``image/jpeg`` only). This field is not supported in Gemini API.""",5828  )5829  image_output_options: Optional[ImageConfigImageOutputOptions] = Field(5830      default=None,5831      description="""Optional. The image output format for generated images. This field is not supported in Gemini API.""",5832  )583358345835class ImageConfigDict(TypedDict, total=False):5836  """The image generation configuration to be used in GenerateContentConfig."""58375838  aspect_ratio: Optional[str]5839  """Aspect ratio of the generated images. Supported values are5840      "1:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9", and "21:9"."""58415842  image_size: Optional[str]5843  """Optional. Specifies the size of generated images. Supported5844      values are `1K`, `2K`, `4K`. If not specified, the model will use default5845      value `1K`."""58465847  person_generation: Optional[str]5848  """Controls the generation of people. Supported values are:5849      ALLOW_ALL, ALLOW_ADULT, ALLOW_NONE."""58505851  prominent_people: Optional[ProminentPeople]5852  """Optional. Controls whether prominent people (celebrities) generation is allowed. If used with personGeneration, personGeneration enum would take precedence. For instance, if ALLOW_NONE is set, all person generation would be blocked. If this field is unspecified, the default behavior is to allow prominent people. This field is not supported in Gemini API."""58535854  output_mime_type: Optional[str]5855  """MIME type of the generated image. This field is not5856      supported in Gemini API."""58575858  output_compression_quality: Optional[int]5859  """Compression quality of the generated image (for5860      ``image/jpeg`` only). This field is not supported in Gemini API."""58615862  image_output_options: Optional[ImageConfigImageOutputOptionsDict]5863  """Optional. The image output format for generated images. This field is not supported in Gemini API."""586458655866ImageConfigOrDict = Union[ImageConfig, ImageConfigDict]586758685869class FileStatus(_common.BaseModel):5870  """Status of a File that uses a common error model."""58715872  details: Optional[list[dict[str, Any]]] = Field(5873      default=None,5874      description="""A list of messages that carry the error details. There is a common set of message types for APIs to use.""",5875  )5876  message: Optional[str] = Field(5877      default=None,5878      description="""A list of messages that carry the error details. There is a common set of message types for APIs to use.""",5879  )5880  code: Optional[int] = Field(5881      default=None, description="""The status code. 0 for OK, 1 for CANCELLED"""5882  )588358845885class FileStatusDict(TypedDict, total=False):5886  """Status of a File that uses a common error model."""58875888  details: Optional[list[dict[str, Any]]]5889  """A list of messages that carry the error details. There is a common set of message types for APIs to use."""58905891  message: Optional[str]5892  """A list of messages that carry the error details. There is a common set of message types for APIs to use."""58935894  code: Optional[int]5895  """The status code. 0 for OK, 1 for CANCELLED"""589658975898FileStatusOrDict = Union[FileStatus, FileStatusDict]589959005901class File(_common.BaseModel):5902  """A file uploaded to the API."""59035904  name: Optional[str] = Field(5905      default=None,5906      description="""The `File` resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456`""",5907  )5908  display_name: Optional[str] = Field(5909      default=None,5910      description="""Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image'""",5911  )5912  mime_type: Optional[str] = Field(5913      default=None, description="""Output only. MIME type of the file."""5914  )5915  size_bytes: Optional[int] = Field(5916      default=None, description="""Output only. Size of the file in bytes."""5917  )5918  create_time: Optional[datetime.datetime] = Field(5919      default=None,5920      description="""Output only. The timestamp of when the `File` was created.""",5921  )5922  expiration_time: Optional[datetime.datetime] = Field(5923      default=None,5924      description="""Output only. The timestamp of when the `File` will be deleted. Only set if the `File` is scheduled to expire.""",5925  )5926  update_time: Optional[datetime.datetime] = Field(5927      default=None,5928      description="""Output only. The timestamp of when the `File` was last updated.""",5929  )5930  sha256_hash: Optional[str] = Field(5931      default=None,5932      description="""Output only. SHA-256 hash of the uploaded bytes. The hash value is encoded in base64 format.""",5933  )5934  uri: Optional[str] = Field(5935      default=None, description="""Output only. The URI of the `File`."""5936  )5937  download_uri: Optional[str] = Field(5938      default=None,5939      description="""Output only. The URI of the `File`, only set for downloadable (generated) files.""",5940  )5941  state: Optional[FileState] = Field(5942      default=None, description="""Output only. Processing state of the File."""5943  )5944  source: Optional[FileSource] = Field(5945      default=None, description="""Output only. The source of the `File`."""5946  )5947  video_metadata: Optional[dict[str, Any]] = Field(5948      default=None, description="""Output only. Metadata for a video."""5949  )5950  error: Optional[FileStatus] = Field(5951      default=None,5952      description="""Output only. Error status if File processing failed.""",5953  )595459555956class FileDict(TypedDict, total=False):5957  """A file uploaded to the API."""59585959  name: Optional[str]5960  """The `File` resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456`"""59615962  display_name: Optional[str]5963  """Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image'"""59645965  mime_type: Optional[str]5966  """Output only. MIME type of the file."""59675968  size_bytes: Optional[int]5969  """Output only. Size of the file in bytes."""59705971  create_time: Optional[datetime.datetime]5972  """Output only. The timestamp of when the `File` was created."""59735974  expiration_time: Optional[datetime.datetime]5975  """Output only. The timestamp of when the `File` will be deleted. Only set if the `File` is scheduled to expire."""59765977  update_time: Optional[datetime.datetime]5978  """Output only. The timestamp of when the `File` was last updated."""59795980  sha256_hash: Optional[str]5981  """Output only. SHA-256 hash of the uploaded bytes. The hash value is encoded in base64 format."""59825983  uri: Optional[str]5984  """Output only. The URI of the `File`."""59855986  download_uri: Optional[str]5987  """Output only. The URI of the `File`, only set for downloadable (generated) files."""59885989  state: Optional[FileState]5990  """Output only. Processing state of the File."""59915992  source: Optional[FileSource]5993  """Output only. The source of the `File`."""59945995  video_metadata: Optional[dict[str, Any]]5996  """Output only. Metadata for a video."""59975998  error: Optional[FileStatusDict]5999  """Output only. Error status if File processing failed."""600060016002FileOrDict = Union[File, FileDict]600360046005if _is_pillow_image_imported:6006  PartUnion = Union[str, PIL_Image, File, Part]6007else:6008  PartUnion = Union[str, File, Part]  # type: ignore[misc]600960106011if _is_pillow_image_imported:6012  PartUnionDict = Union[str, PIL_Image, File, FileDict, Part, PartDict]6013else:6014  PartUnionDict = Union[str, File, FileDict, Part, PartDict]  # type: ignore[misc]601560166017ContentUnion = Union[Content, PartUnion, list[PartUnion]]601860196020ContentUnionDict = Union[6021    Content, ContentDict, PartUnionDict, list[PartUnionDict]6022]602360246025class GenerationConfigRoutingConfigAutoRoutingMode(_common.BaseModel):6026  """The configuration for automated routing.60276028  When automated routing is specified, the routing will be determined by the6029  pretrained routing model and customer provided model routing preference. This6030  data type is not supported in Gemini API.6031  """60326033  model_routing_preference: Optional[6034      Literal['UNKNOWN', 'PRIORITIZE_QUALITY', 'BALANCED', 'PRIORITIZE_COST']6035  ] = Field(default=None, description="""The model routing preference.""")603660376038class GenerationConfigRoutingConfigAutoRoutingModeDict(TypedDict, total=False):6039  """The configuration for automated routing.60406041  When automated routing is specified, the routing will be determined by the6042  pretrained routing model and customer provided model routing preference. This6043  data type is not supported in Gemini API.6044  """60456046  model_routing_preference: Optional[6047      Literal['UNKNOWN', 'PRIORITIZE_QUALITY', 'BALANCED', 'PRIORITIZE_COST']6048  ]6049  """The model routing preference."""605060516052GenerationConfigRoutingConfigAutoRoutingModeOrDict = Union[6053    GenerationConfigRoutingConfigAutoRoutingMode,6054    GenerationConfigRoutingConfigAutoRoutingModeDict,6055]605660576058class GenerationConfigRoutingConfigManualRoutingMode(_common.BaseModel):6059  """The configuration for manual routing.60606061  When manual routing is specified, the model will be selected based on the6062  model name provided. This data type is not supported in Gemini API.6063  """60646065  model_name: Optional[str] = Field(6066      default=None,6067      description="""The name of the model to use. Only public LLM models are accepted.""",6068  )606960706071class GenerationConfigRoutingConfigManualRoutingModeDict(6072    TypedDict, total=False6073):6074  """The configuration for manual routing.60756076  When manual routing is specified, the model will be selected based on the6077  model name provided. This data type is not supported in Gemini API.6078  """60796080  model_name: Optional[str]6081  """The name of the model to use. Only public LLM models are accepted."""608260836084GenerationConfigRoutingConfigManualRoutingModeOrDict = Union[6085    GenerationConfigRoutingConfigManualRoutingMode,6086    GenerationConfigRoutingConfigManualRoutingModeDict,6087]608860896090class GenerationConfigRoutingConfig(_common.BaseModel):6091  """The configuration for routing the request to a specific model.60926093  This can be used to control which model is used for the generation, either6094  automatically or by specifying a model name. This data type is not supported6095  in Gemini API.6096  """60976098  auto_mode: Optional[GenerationConfigRoutingConfigAutoRoutingMode] = Field(6099      default=None,6100      description="""In this mode, the model is selected automatically based on the content of the request.""",6101  )6102  manual_mode: Optional[GenerationConfigRoutingConfigManualRoutingMode] = Field(6103      default=None,6104      description="""In this mode, the model is specified manually.""",6105  )610661076108class GenerationConfigRoutingConfigDict(TypedDict, total=False):6109  """The configuration for routing the request to a specific model.61106111  This can be used to control which model is used for the generation, either6112  automatically or by specifying a model name. This data type is not supported6113  in Gemini API.6114  """61156116  auto_mode: Optional[GenerationConfigRoutingConfigAutoRoutingModeDict]6117  """In this mode, the model is selected automatically based on the content of the request."""61186119  manual_mode: Optional[GenerationConfigRoutingConfigManualRoutingModeDict]6120  """In this mode, the model is specified manually."""612161226123GenerationConfigRoutingConfigOrDict = Union[6124    GenerationConfigRoutingConfig, GenerationConfigRoutingConfigDict6125]612661276128class SafetySetting(_common.BaseModel):6129  """A safety setting that affects the safety-blocking behavior.61306131  A SafetySetting consists of a harm category and a threshold for that category.6132  """61336134  category: Optional[HarmCategory] = Field(6135      default=None, description="""Required. The harm category to be blocked."""6136  )6137  method: Optional[HarmBlockMethod] = Field(6138      default=None,6139      description="""Optional. The method for blocking content. If not specified, the default behavior is to use the probability score. This field is not supported in Gemini API.""",6140  )6141  threshold: Optional[HarmBlockThreshold] = Field(6142      default=None,6143      description="""Required. The threshold for blocking content. If the harm probability exceeds this threshold, the content will be blocked.""",6144  )614561466147class SafetySettingDict(TypedDict, total=False):6148  """A safety setting that affects the safety-blocking behavior.61496150  A SafetySetting consists of a harm category and a threshold for that category.6151  """61526153  category: Optional[HarmCategory]6154  """Required. The harm category to be blocked."""61556156  method: Optional[HarmBlockMethod]6157  """Optional. The method for blocking content. If not specified, the default behavior is to use the probability score. This field is not supported in Gemini API."""61586159  threshold: Optional[HarmBlockThreshold]6160  """Required. The threshold for blocking content. If the harm probability exceeds this threshold, the content will be blocked."""616161626163SafetySettingOrDict = Union[SafetySetting, SafetySettingDict]616461656166class LatLng(_common.BaseModel):6167  """An object that represents a latitude/longitude pair.61686169  This is expressed as a pair of doubles to represent degrees latitude and6170  degrees longitude. Unless specified otherwise, this object must conform to the6171  WGS84 standard. Values must be within normalized ranges.6172  """61736174  latitude: Optional[float] = Field(6175      default=None,6176      description="""The latitude in degrees. It must be in the range [-90.0, +90.0].""",6177  )6178  longitude: Optional[float] = Field(6179      default=None,6180      description="""The longitude in degrees. It must be in the range [-180.0, +180.0].""",6181  )618261836184class LatLngDict(TypedDict, total=False):6185  """An object that represents a latitude/longitude pair.61866187  This is expressed as a pair of doubles to represent degrees latitude and6188  degrees longitude. Unless specified otherwise, this object must conform to the6189  WGS84 standard. Values must be within normalized ranges.6190  """61916192  latitude: Optional[float]6193  """The latitude in degrees. It must be in the range [-90.0, +90.0]."""61946195  longitude: Optional[float]6196  """The longitude in degrees. It must be in the range [-180.0, +180.0]."""619761986199LatLngOrDict = Union[LatLng, LatLngDict]620062016202class RetrievalConfig(_common.BaseModel):6203  """Retrieval config."""62046205  lat_lng: Optional[LatLng] = Field(6206      default=None, description="""The location of the user."""6207  )6208  language_code: Optional[str] = Field(6209      default=None, description="""The language code of the user."""6210  )621162126213class RetrievalConfigDict(TypedDict, total=False):6214  """Retrieval config."""62156216  lat_lng: Optional[LatLngDict]6217  """The location of the user."""62186219  language_code: Optional[str]6220  """The language code of the user."""622162226223RetrievalConfigOrDict = Union[RetrievalConfig, RetrievalConfigDict]622462256226class FunctionCallingConfig(_common.BaseModel):6227  """Function calling config."""62286229  allowed_function_names: Optional[list[str]] = Field(6230      default=None,6231      description="""Optional. Function names to call. Only set when the Mode is ANY. Function names should match FunctionDeclaration.name. With mode set to ANY, model will predict a function call from the set of function names provided.""",6232  )6233  mode: Optional[FunctionCallingConfigMode] = Field(6234      default=None, description="""Optional. Function calling mode."""6235  )6236  stream_function_call_arguments: Optional[bool] = Field(6237      default=None,6238      description="""Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the `FunctionCall.partial_args` field. This field is not supported in Gemini API.""",6239  )624062416242class FunctionCallingConfigDict(TypedDict, total=False):6243  """Function calling config."""62446245  allowed_function_names: Optional[list[str]]6246  """Optional. Function names to call. Only set when the Mode is ANY. Function names should match FunctionDeclaration.name. With mode set to ANY, model will predict a function call from the set of function names provided."""62476248  mode: Optional[FunctionCallingConfigMode]6249  """Optional. Function calling mode."""62506251  stream_function_call_arguments: Optional[bool]6252  """Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the `FunctionCall.partial_args` field. This field is not supported in Gemini API."""625362546255FunctionCallingConfigOrDict = Union[6256    FunctionCallingConfig, FunctionCallingConfigDict6257]625862596260class ToolConfig(_common.BaseModel):6261  """Tool config.62626263  This config is shared for all tools provided in the request.6264  """62656266  retrieval_config: Optional[RetrievalConfig] = Field(6267      default=None, description="""Optional. Retrieval config."""6268  )6269  function_calling_config: Optional[FunctionCallingConfig] = Field(6270      default=None, description="""Optional. Function calling config."""6271  )6272  include_server_side_tool_invocations: Optional[bool] = Field(6273      default=None,6274      description="""Optional. If true, the API response will include the server-side tool calls and responses within the `Content` message. This allows clients to observe the server's tool interactions. This field is not supported in Vertex AI.""",6275  )627662776278class ToolConfigDict(TypedDict, total=False):6279  """Tool config.62806281  This config is shared for all tools provided in the request.6282  """62836284  retrieval_config: Optional[RetrievalConfigDict]6285  """Optional. Retrieval config."""62866287  function_calling_config: Optional[FunctionCallingConfigDict]6288  """Optional. Function calling config."""62896290  include_server_side_tool_invocations: Optional[bool]6291  """Optional. If true, the API response will include the server-side tool calls and responses within the `Content` message. This allows clients to observe the server's tool interactions. This field is not supported in Vertex AI."""629262936294ToolConfigOrDict = Union[ToolConfig, ToolConfigDict]629562966297SpeechConfigUnion = Union[str, SpeechConfig]629862996300SpeechConfigUnionDict = Union[str, SpeechConfig, SpeechConfigDict]630163026303class ModelArmorConfig(_common.BaseModel):6304  """Configuration for Model Armor.63056306  Model Armor is a Google Cloud service that provides safety and security6307  filtering for prompts and responses. It helps protect your AI applications6308  from risks such as harmful content, sensitive data leakage, and prompt6309  injection attacks. This data type is not supported in Gemini API.6310  """63116312  prompt_template_name: Optional[str] = Field(6313      default=None,6314      description="""Optional. The resource name of the Model Armor template to use for prompt screening. A Model Armor template is a set of customized filters and thresholds that define how Model Armor screens content. If specified, Model Armor will use this template to check the user's prompt for safety and security risks before it is sent to the model. The name must be in the format `projects/{project}/locations/{location}/templates/{template}`.""",6315  )6316  response_template_name: Optional[str] = Field(6317      default=None,6318      description="""Optional. The resource name of the Model Armor template to use for response screening. A Model Armor template is a set of customized filters and thresholds that define how Model Armor screens content. If specified, Model Armor will use this template to check the model's response for safety and security risks before it is returned to the user. The name must be in the format `projects/{project}/locations/{location}/templates/{template}`.""",6319  )632063216322class ModelArmorConfigDict(TypedDict, total=False):6323  """Configuration for Model Armor.63246325  Model Armor is a Google Cloud service that provides safety and security6326  filtering for prompts and responses. It helps protect your AI applications6327  from risks such as harmful content, sensitive data leakage, and prompt6328  injection attacks. This data type is not supported in Gemini API.6329  """63306331  prompt_template_name: Optional[str]6332  """Optional. The resource name of the Model Armor template to use for prompt screening. A Model Armor template is a set of customized filters and thresholds that define how Model Armor screens content. If specified, Model Armor will use this template to check the user's prompt for safety and security risks before it is sent to the model. The name must be in the format `projects/{project}/locations/{location}/templates/{template}`."""63336334  response_template_name: Optional[str]6335  """Optional. The resource name of the Model Armor template to use for response screening. A Model Armor template is a set of customized filters and thresholds that define how Model Armor screens content. If specified, Model Armor will use this template to check the model's response for safety and security risks before it is returned to the user. The name must be in the format `projects/{project}/locations/{location}/templates/{template}`."""633663376338ModelArmorConfigOrDict = Union[ModelArmorConfig, ModelArmorConfigDict]633963406341class LanguageAuto(_common.BaseModel):6342  """Deprecated: Language auto-detection is now the default when language_codes is omitted."""63436344  pass634563466347class LanguageAutoDict(TypedDict, total=False):6348  """Deprecated: Language auto-detection is now the default when language_codes is omitted."""63496350  pass635163526353LanguageAutoOrDict = Union[LanguageAuto, LanguageAutoDict]635463556356class LanguageHints(_common.BaseModel):6357  """Deprecated: Use AudioTranscriptionConfig.language_codes instead."""63586359  language_codes: Optional[list[str]] = Field(6360      default=None, description="""Deprecated. BCP-47 language codes."""6361  )636263636364class LanguageHintsDict(TypedDict, total=False):6365  """Deprecated: Use AudioTranscriptionConfig.language_codes instead."""63666367  language_codes: Optional[list[str]]6368  """Deprecated. BCP-47 language codes."""636963706371LanguageHintsOrDict = Union[LanguageHints, LanguageHintsDict]637263736374class AudioTranscriptionConfig(_common.BaseModel):6375  """The audio transcription configuration in Setup."""63766377  language_codes: Optional[list[str]] = Field(6378      default=None,6379      description="""Optional. BCP-47 language codes providing hints about the languages present in the audio. If omitted or empty, defaults to automatic language detection.""",6380  )6381  language_auto: Optional[LanguageAuto] = Field(6382      default=None,6383      description="""Deprecated: Auto-detection is now the default when language_codes is omitted. This field will be removed in a future version.""",6384  )6385  language_hints: Optional[LanguageHints] = Field(6386      default=None,6387      description="""Deprecated: Use top-level language_codes instead. This field will be removed in a future version.""",6388  )6389  custom_vocabulary: Optional[list[str]] = Field(6390      default=None,6391      description="""A list of custom vocabulary phrases, which biases the ASR model to improve recognition of these specific terms.""",6392  )6393  adaptation_phrases: Optional[list[str]] = Field(6394      default=None,6395      description="""Deprecated. A list of phrases used for speech adaptation, which biases the ASR model to improve recognition of these specific terms.""",6396  )6397  word_timestamp: Optional[bool] = Field(6398      default=None,6399      description="""Configures word-level timestamp generation.6400      """,6401  )6402  diarization: Optional[bool] = Field(6403      default=None,6404      description="""Configures speaker diarization.6405      """,6406  )6407  mode: Optional[AudioTranscriptionConfigMode] = Field(6408      default=None,6409      description="""Optional. Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If unspecified, defaults to `VERBATIM` transcription. In `SMART` mode, the model performs disfluency removal (eliminating filler words, repetitions, and false starts), light grammatical cleanup, automatic formatting (paragraphs, bullet points, numbered lists), and minor user edits (inline self-corrections). Timestamps and diarization are incompatible with mode `SMART`.""",6410  )641164126413class AudioTranscriptionConfigDict(TypedDict, total=False):6414  """The audio transcription configuration in Setup."""64156416  language_codes: Optional[list[str]]6417  """Optional. BCP-47 language codes providing hints about the languages present in the audio. If omitted or empty, defaults to automatic language detection."""64186419  language_auto: Optional[LanguageAutoDict]6420  """Deprecated: Auto-detection is now the default when language_codes is omitted. This field will be removed in a future version."""64216422  language_hints: Optional[LanguageHintsDict]6423  """Deprecated: Use top-level language_codes instead. This field will be removed in a future version."""64246425  custom_vocabulary: Optional[list[str]]6426  """A list of custom vocabulary phrases, which biases the ASR model to improve recognition of these specific terms."""64276428  adaptation_phrases: Optional[list[str]]6429  """Deprecated. A list of phrases used for speech adaptation, which biases the ASR model to improve recognition of these specific terms."""64306431  word_timestamp: Optional[bool]6432  """Configures word-level timestamp generation.6433      """64346435  diarization: Optional[bool]6436  """Configures speaker diarization.6437      """64386439  mode: Optional[AudioTranscriptionConfigMode]6440  """Optional. Configures transcription mode. Supported values: `VERBATIM`, `SMART`. If unspecified, defaults to `VERBATIM` transcription. In `SMART` mode, the model performs disfluency removal (eliminating filler words, repetitions, and false starts), light grammatical cleanup, automatic formatting (paragraphs, bullet points, numbered lists), and minor user edits (inline self-corrections). Timestamps and diarization are incompatible with mode `SMART`."""644164426443AudioTranscriptionConfigOrDict = Union[6444    AudioTranscriptionConfig, AudioTranscriptionConfigDict6445]644664476448class GenerateContentConfig(_common.BaseModel):6449  """Optional model configuration parameters.64506451  For more information, see `Content generation parameters6452  <https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/content-generation-parameters>`_.6453  """64546455  http_options: Optional[HttpOptions] = Field(6456      default=None, description="""Used to override HTTP request options."""6457  )6458  should_return_http_response: Optional[bool] = Field(6459      default=None,6460      description=""" If true, the raw HTTP response will be returned in the 'sdk_http_response' field.""",6461  )6462  system_instruction: Optional[ContentUnion] = Field(6463      default=None,6464      description="""Instructions for the model to steer it toward better performance.6465      For example, "Answer as concisely as possible" or "Don't use technical6466      terms in your response".6467      """,6468  )6469  temperature: Optional[float] = Field(6470      default=None,6471      description="""Value that controls the degree of randomness in token selection.6472      Lower temperatures are good for prompts that require a less open-ended or6473      creative response, while higher temperatures can lead to more diverse or6474      creative results.6475      """,6476  )6477  top_p: Optional[float] = Field(6478      default=None,6479      description="""Tokens are selected from the most to least probable until the sum6480      of their probabilities equals this value. Use a lower value for less6481      random responses and a higher value for more random responses.6482      """,6483  )6484  top_k: Optional[float] = Field(6485      default=None,6486      description="""For each token selection step, the ``top_k`` tokens with the6487      highest probabilities are sampled. Then tokens are further filtered based6488      on ``top_p`` with the final token selected using temperature sampling. Use6489      a lower number for less random responses and a higher number for more6490      random responses.6491      """,6492  )6493  candidate_count: Optional[int] = Field(6494      default=None,6495      description="""Number of response variations to return.6496      """,6497  )6498  max_output_tokens: Optional[int] = Field(6499      default=None,6500      description="""Maximum number of tokens that can be generated in the response.6501      """,6502  )6503  stop_sequences: Optional[list[str]] = Field(6504      default=None,6505      description="""List of strings that tells the model to stop generating text if one6506      of the strings is encountered in the response.6507      """,6508  )6509  response_logprobs: Optional[bool] = Field(6510      default=None,6511      description="""Whether to return the log probabilities of the tokens that were6512      chosen by the model at each step.6513      """,6514  )6515  logprobs: Optional[int] = Field(6516      default=None,6517      description="""Number of top candidate tokens to return the log probabilities for6518      at each generation step.6519      """,6520  )6521  presence_penalty: Optional[float] = Field(6522      default=None,6523      description="""Positive values penalize tokens that already appear in the6524      generated text, increasing the probability of generating more diverse6525      content.6526      """,6527  )6528  frequency_penalty: Optional[float] = Field(6529      default=None,6530      description="""Positive values penalize tokens that repeatedly appear in the6531      generated text, increasing the probability of generating more diverse6532      content.6533      """,6534  )6535  seed: Optional[int] = Field(6536      default=None,6537      description="""When ``seed`` is fixed to a specific number, the model makes a best6538      effort to provide the same response for repeated requests. By default, a6539      random number is used.6540      """,6541  )6542  response_mime_type: Optional[str] = Field(6543      default=None,6544      description="""Output response mimetype of the generated candidate text.6545      Supported mimetype:6546        - `text/plain`: (default) Text output.6547        - `application/json`: JSON response in the candidates.6548      The model needs to be prompted to output the appropriate response type,6549      otherwise the behavior is undefined.6550      """,6551  )6552  response_schema: Optional[SchemaUnion] = Field(6553      default=None,6554      description="""The `Schema` object allows the definition of input and output data types.6555      These types can be objects, but also primitives and arrays.6556      Represents a select subset of an [OpenAPI 3.0 schema6557      object](https://spec.openapis.org/oas/v3.0.3#schema).6558      If set, a compatible response_mime_type must also be set.6559      Compatible mimetypes: `application/json`: Schema for JSON response.65606561      If `response_schema` doesn't process your schema correctly, try using6562      `response_json_schema` instead.6563      """,6564  )6565  response_json_schema: Optional[Any] = Field(6566      default=None,6567      description="""Optional. Output schema of the generated response.6568      This is an alternative to `response_schema` that accepts [JSON6569      Schema](https://json-schema.org/). If set, `response_schema` must be6570      omitted, but `response_mime_type` is required. While the full JSON Schema6571      may be sent, not all features are supported. Specifically, only the6572      following properties are supported: - `$id` - `$defs` - `$ref` - `$anchor`6573      - `type` - `format` - `title` - `description` - `enum` (for strings and6574      numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` -6575      `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) -6576      `properties` - `additionalProperties` - `required` The non-standard6577      `propertyOrdering` property may also be set. Cyclic references are6578      unrolled to a limited degree and, as such, may only be used within6579      non-required properties. (Nullable properties are not sufficient.) If6580      `$ref` is set on a sub-schema, no other properties, except for than those6581      starting as a `$`, may be set.""",6582  )6583  routing_config: Optional[GenerationConfigRoutingConfig] = Field(6584      default=None,6585      description="""Configuration for model router requests.6586      """,6587  )6588  model_selection_config: Optional[ModelSelectionConfig] = Field(6589      default=None,6590      description="""Configuration for model selection.6591      """,6592  )6593  safety_settings: Optional[list[SafetySetting]] = Field(6594      default=None,6595      description="""Safety settings in the request to block unsafe content in the6596      response.6597      """,6598  )6599  tools: Optional[ToolListUnion] = Field(6600      default=None,6601      description="""Code that enables the system to interact with external systems to6602      perform an action outside of the knowledge and scope of the model.6603      """,6604  )6605  tool_config: Optional[ToolConfig] = Field(6606      default=None,6607      description="""Associates model output to a specific function call.6608      """,6609  )6610  labels: Optional[dict[str, str]] = Field(6611      default=None,6612      description="""Labels with user-defined metadata to break down billed charges.""",6613  )6614  cached_content: Optional[str] = Field(6615      default=None,6616      description="""Resource name of a context cache that can be used in subsequent6617      requests.6618      """,6619  )6620  response_modalities: Optional[list[str]] = Field(6621      default=None,6622      description="""The requested modalities of the response. Represents the set of6623      modalities that the model can return.6624      """,6625  )6626  media_resolution: Optional[MediaResolution] = Field(6627      default=None,6628      description="""If specified, the media resolution specified will be used.6629    """,6630  )6631  speech_config: Optional[SpeechConfigUnion] = Field(6632      default=None,6633      description="""The speech generation configuration.6634      """,6635  )6636  audio_timestamp: Optional[bool] = Field(6637      default=None,6638      description="""If enabled, audio timestamp will be included in the request to the6639       model.6640      """,6641  )6642  automatic_function_calling: Optional[AutomaticFunctionCallingConfig] = Field(6643      default=None,6644      description="""The configuration for automatic function calling.6645      """,6646  )6647  thinking_config: Optional[ThinkingConfig] = Field(6648      default=None,6649      description="""The thinking features configuration.6650      """,6651  )6652  image_config: Optional[ImageConfig] = Field(6653      default=None,6654      description="""The image generation configuration.6655      """,6656  )6657  enable_enhanced_civic_answers: Optional[bool] = Field(6658      default=None,6659      description="""Enables enhanced civic answers. It may not be available for all6660      models. This field is not supported in Gemini Enterprise Agent Platform.6661      """,6662  )6663  model_armor_config: Optional[ModelArmorConfig] = Field(6664      default=None,6665      description="""Settings for prompt and response sanitization using the Model Armor6666      service. If supplied, safety_settings must not be supplied.6667      """,6668  )6669  service_tier: Optional[ServiceTier] = Field(6670      default=None,6671      description="""The service tier to use for the request. For example, ServiceTier.FLEX.""",6672  )6673  audio_transcription_config: Optional[AudioTranscriptionConfig] = Field(6674      default=None,6675      description="""Optional. Configuration for audio transcription (speech recognition).6676      """,6677  )66786679  @pydantic.field_validator('response_schema', mode='before')6680  @classmethod6681  def _convert_literal_to_enum(cls, value: Any) -> Union[Any, EnumMeta]:6682    if typing.get_origin(value) is typing.Literal:6683      enum_vals = typing.get_args(value)6684      if not all(isinstance(arg, str) for arg in enum_vals):6685        # This doesn't stop execution, it tells pydantic to raise a ValidationError6686        # when the class is instantiated with an unsupported Literal6687        raise ValueError(f'Literal type {value} must be a list of strings.')6688      # The title 'PlaceholderLiteralEnum' is removed from the generated Schema6689      # before sending the request6690      return Enum('PlaceholderLiteralEnum', {s: s for s in enum_vals})6691    return value66926693  @pydantic.field_validator('image_config', mode='before')6694  @classmethod6695  def _check_image_config_type(cls, value: Any) -> Any:6696    if isinstance(value, GenerateImagesConfig):6697      raise ValueError(6698          'image_config must be an instance of ImageConfig or compatible dict.'6699      )6700    return value670167026703class GenerateContentConfigDict(TypedDict, total=False):6704  """Optional model configuration parameters.67056706  For more information, see `Content generation parameters6707  <https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/content-generation-parameters>`_.6708  """67096710  http_options: Optional[HttpOptionsDict]6711  """Used to override HTTP request options."""67126713  should_return_http_response: Optional[bool]6714  """ If true, the raw HTTP response will be returned in the 'sdk_http_response' field."""67156716  system_instruction: Optional[ContentUnionDict]6717  """Instructions for the model to steer it toward better performance.6718      For example, "Answer as concisely as possible" or "Don't use technical6719      terms in your response".6720      """67216722  temperature: Optional[float]6723  """Value that controls the degree of randomness in token selection.6724      Lower temperatures are good for prompts that require a less open-ended or6725      creative response, while higher temperatures can lead to more diverse or6726      creative results.6727      """67286729  top_p: Optional[float]6730  """Tokens are selected from the most to least probable until the sum6731      of their probabilities equals this value. Use a lower value for less6732      random responses and a higher value for more random responses.6733      """67346735  top_k: Optional[float]6736  """For each token selection step, the ``top_k`` tokens with the6737      highest probabilities are sampled. Then tokens are further filtered based6738      on ``top_p`` with the final token selected using temperature sampling. Use6739      a lower number for less random responses and a higher number for more6740      random responses.6741      """67426743  candidate_count: Optional[int]6744  """Number of response variations to return.6745      """67466747  max_output_tokens: Optional[int]6748  """Maximum number of tokens that can be generated in the response.6749      """67506751  stop_sequences: Optional[list[str]]6752  """List of strings that tells the model to stop generating text if one6753      of the strings is encountered in the response.6754      """67556756  response_logprobs: Optional[bool]6757  """Whether to return the log probabilities of the tokens that were6758      chosen by the model at each step.6759      """67606761  logprobs: Optional[int]6762  """Number of top candidate tokens to return the log probabilities for6763      at each generation step.6764      """67656766  presence_penalty: Optional[float]6767  """Positive values penalize tokens that already appear in the6768      generated text, increasing the probability of generating more diverse6769      content.6770      """67716772  frequency_penalty: Optional[float]6773  """Positive values penalize tokens that repeatedly appear in the6774      generated text, increasing the probability of generating more diverse6775      content.6776      """67776778  seed: Optional[int]6779  """When ``seed`` is fixed to a specific number, the model makes a best6780      effort to provide the same response for repeated requests. By default, a6781      random number is used.6782      """67836784  response_mime_type: Optional[str]6785  """Output response mimetype of the generated candidate text.6786      Supported mimetype:6787        - `text/plain`: (default) Text output.6788        - `application/json`: JSON response in the candidates.6789      The model needs to be prompted to output the appropriate response type,6790      otherwise the behavior is undefined.6791      """67926793  response_schema: Optional[SchemaUnionDict]6794  """The `Schema` object allows the definition of input and output data types.6795      These types can be objects, but also primitives and arrays.6796      Represents a select subset of an [OpenAPI 3.0 schema6797      object](https://spec.openapis.org/oas/v3.0.3#schema).6798      If set, a compatible response_mime_type must also be set.6799      Compatible mimetypes: `application/json`: Schema for JSON response.68006801      If `response_schema` doesn't process your schema correctly, try using6802      `response_json_schema` instead.6803      """68046805  response_json_schema: Optional[Any]6806  """Optional. Output schema of the generated response.6807      This is an alternative to `response_schema` that accepts [JSON6808      Schema](https://json-schema.org/). If set, `response_schema` must be6809      omitted, but `response_mime_type` is required. While the full JSON Schema6810      may be sent, not all features are supported. Specifically, only the6811      following properties are supported: - `$id` - `$defs` - `$ref` - `$anchor`6812      - `type` - `format` - `title` - `description` - `enum` (for strings and6813      numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` -6814      `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) -6815      `properties` - `additionalProperties` - `required` The non-standard6816      `propertyOrdering` property may also be set. Cyclic references are6817      unrolled to a limited degree and, as such, may only be used within6818      non-required properties. (Nullable properties are not sufficient.) If6819      `$ref` is set on a sub-schema, no other properties, except for than those6820      starting as a `$`, may be set."""68216822  routing_config: Optional[GenerationConfigRoutingConfigDict]6823  """Configuration for model router requests.6824      """68256826  model_selection_config: Optional[ModelSelectionConfigDict]6827  """Configuration for model selection.6828      """68296830  safety_settings: Optional[list[SafetySettingDict]]6831  """Safety settings in the request to block unsafe content in the6832      response.6833      """68346835  tools: Optional[ToolListUnionDict]6836  """Code that enables the system to interact with external systems to6837      perform an action outside of the knowledge and scope of the model.6838      """68396840  tool_config: Optional[ToolConfigDict]6841  """Associates model output to a specific function call.6842      """68436844  labels: Optional[dict[str, str]]6845  """Labels with user-defined metadata to break down billed charges."""68466847  cached_content: Optional[str]6848  """Resource name of a context cache that can be used in subsequent6849      requests.6850      """68516852  response_modalities: Optional[list[str]]6853  """The requested modalities of the response. Represents the set of6854      modalities that the model can return.6855      """68566857  media_resolution: Optional[MediaResolution]6858  """If specified, the media resolution specified will be used.6859    """68606861  speech_config: Optional[SpeechConfigUnionDict]6862  """The speech generation configuration.6863      """68646865  audio_timestamp: Optional[bool]6866  """If enabled, audio timestamp will be included in the request to the6867       model.6868      """68696870  automatic_function_calling: Optional[AutomaticFunctionCallingConfigDict]6871  """The configuration for automatic function calling.6872      """68736874  thinking_config: Optional[ThinkingConfigDict]6875  """The thinking features configuration.6876      """68776878  image_config: Optional[ImageConfigDict]6879  """The image generation configuration.6880      """68816882  enable_enhanced_civic_answers: Optional[bool]6883  """Enables enhanced civic answers. It may not be available for all6884      models. This field is not supported in Gemini Enterprise Agent Platform.6885      """68866887  model_armor_config: Optional[ModelArmorConfigDict]6888  """Settings for prompt and response sanitization using the Model Armor6889      service. If supplied, safety_settings must not be supplied.6890      """68916892  service_tier: Optional[ServiceTier]6893  """The service tier to use for the request. For example, ServiceTier.FLEX."""68946895  audio_transcription_config: Optional[AudioTranscriptionConfigDict]6896  """Optional. Configuration for audio transcription (speech recognition).6897      """689868996900GenerateContentConfigOrDict = Union[6901    GenerateContentConfig, GenerateContentConfigDict6902]690369046905ContentListUnion = Union[ContentUnion, list[ContentUnion]]690669076908ContentListUnionDict = Union[ContentUnionDict, list[ContentUnionDict]]690969106911class _GenerateContentParameters(_common.BaseModel):6912  """Config for models.generate_content parameters."""69136914  model: Optional[str] = Field(6915      default=None,6916      description="""ID of the model to use. For a list of models, see `Google models6917    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",6918  )6919  contents: Optional[ContentListUnion] = Field(6920      default=None,6921      description="""Content of the request.6922      """,6923  )6924  config: Optional[GenerateContentConfig] = Field(6925      default=None,6926      description="""Configuration that contains optional model parameters.6927      """,6928  )692969306931class _GenerateContentParametersDict(TypedDict, total=False):6932  """Config for models.generate_content parameters."""69336934  model: Optional[str]6935  """ID of the model to use. For a list of models, see `Google models6936    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""69376938  contents: Optional[ContentListUnionDict]6939  """Content of the request.6940      """69416942  config: Optional[GenerateContentConfigDict]6943  """Configuration that contains optional model parameters.6944      """694569466947_GenerateContentParametersOrDict = Union[6948    _GenerateContentParameters, _GenerateContentParametersDict6949]695069516952class HttpResponse(_common.BaseModel):6953  """A wrapper class for the http response."""69546955  headers: Optional[dict[str, str]] = Field(6956      default=None,6957      description="""Used to retain the processed HTTP headers in the response.""",6958  )6959  body: Optional[str] = Field(6960      default=None,6961      description="""The raw HTTP response body, in JSON format.""",6962  )696369646965class HttpResponseDict(TypedDict, total=False):6966  """A wrapper class for the http response."""69676968  headers: Optional[dict[str, str]]6969  """Used to retain the processed HTTP headers in the response."""69706971  body: Optional[str]6972  """The raw HTTP response body, in JSON format."""697369746975HttpResponseOrDict = Union[HttpResponse, HttpResponseDict]697669776978class GoogleTypeDate(_common.BaseModel):6979  """Represents a whole or partial calendar date, such as a birthday.69806981  The time of day and time zone are either specified elsewhere or are6982  insignificant. The date is relative to the Gregorian Calendar. This can6983  represent one of the following: * A full date, with non-zero year, month, and6984  day values. * A month and day, with a zero year (for example, an anniversary).6985  * A year on its own, with a zero month and a zero day. * A year and month,6986  with a zero day (for example, a credit card expiration date). Related types: *6987  google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp. This6988  data type is not supported in Gemini API.6989  """69906991  day: Optional[int] = Field(6992      default=None,6993      description="""Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.""",6994  )6995  month: Optional[int] = Field(6996      default=None,6997      description="""Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.""",6998  )6999  year: Optional[int] = Field(7000      default=None,7001      description="""Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.""",7002  )700370047005class GoogleTypeDateDict(TypedDict, total=False):7006  """Represents a whole or partial calendar date, such as a birthday.70077008  The time of day and time zone are either specified elsewhere or are7009  insignificant. The date is relative to the Gregorian Calendar. This can7010  represent one of the following: * A full date, with non-zero year, month, and7011  day values. * A month and day, with a zero year (for example, an anniversary).7012  * A year on its own, with a zero month and a zero day. * A year and month,7013  with a zero day (for example, a credit card expiration date). Related types: *7014  google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp. This7015  data type is not supported in Gemini API.7016  """70177018  day: Optional[int]7019  """Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant."""70207021  month: Optional[int]7022  """Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day."""70237024  year: Optional[int]7025  """Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year."""702670277028GoogleTypeDateOrDict = Union[GoogleTypeDate, GoogleTypeDateDict]702970307031class Citation(_common.BaseModel):7032  """A citation for a piece of generatedcontent.70337034  This data type is not supported in Gemini API.7035  """70367037  end_index: Optional[int] = Field(7038      default=None,7039      description="""Output only. The end index of the citation in the content.""",7040  )7041  license: Optional[str] = Field(7042      default=None,7043      description="""Output only. The license of the source of the citation.""",7044  )7045  publication_date: Optional[GoogleTypeDate] = Field(7046      default=None,7047      description="""Output only. The publication date of the source of the citation.""",7048  )7049  start_index: Optional[int] = Field(7050      default=None,7051      description="""Output only. The start index of the citation in the content.""",7052  )7053  title: Optional[str] = Field(7054      default=None,7055      description="""Output only. The title of the source of the citation.""",7056  )7057  uri: Optional[str] = Field(7058      default=None,7059      description="""Output only. The URI of the source of the citation.""",7060  )706170627063class CitationDict(TypedDict, total=False):7064  """A citation for a piece of generatedcontent.70657066  This data type is not supported in Gemini API.7067  """70687069  end_index: Optional[int]7070  """Output only. The end index of the citation in the content."""70717072  license: Optional[str]7073  """Output only. The license of the source of the citation."""70747075  publication_date: Optional[GoogleTypeDateDict]7076  """Output only. The publication date of the source of the citation."""70777078  start_index: Optional[int]7079  """Output only. The start index of the citation in the content."""70807081  title: Optional[str]7082  """Output only. The title of the source of the citation."""70837084  uri: Optional[str]7085  """Output only. The URI of the source of the citation."""708670877088CitationOrDict = Union[Citation, CitationDict]708970907091class CitationMetadata(_common.BaseModel):7092  """Citation information when the model quotes another source."""70937094  citations: Optional[list[Citation]] = Field(7095      default=None,7096      description="""Contains citation information when the model directly quotes, at7097      length, from another source. Can include traditional websites and code7098      repositories.7099      """,7100  )71017102  @model_validator(mode='before')7103  @classmethod7104  def _rename_citation_sources(cls, data: Any) -> Any:7105    if isinstance(data, dict) and 'citationSources' in data:7106      data['citations'] = data.pop('citationSources')7107    return data710871097110MetricUnion = Union['Metric', 'UnifiedMetric']7111MetricUnionDict = Union['MetricDict', 'UnifiedMetricDict']711271137114class CitationMetadataDict(TypedDict, total=False):7115  """Citation information when the model quotes another source."""71167117  citations: Optional[list[CitationDict]]7118  """Contains citation information when the model directly quotes, at7119      length, from another source. Can include traditional websites and code7120      repositories.7121      """712271237124CitationMetadataOrDict = Union[CitationMetadata, CitationMetadataDict]712571267127class GroundingChunkMapsPlaceAnswerSourcesAuthorAttribution(_common.BaseModel):7128  """Author attribution for a photo or review."""71297130  display_name: Optional[str] = Field(7131      default=None, description="""Name of the author of the Photo or Review."""7132  )7133  photo_uri: Optional[str] = Field(7134      default=None,7135      description="""Profile photo URI of the author of the Photo or Review.""",7136  )7137  uri: Optional[str] = Field(7138      default=None, description="""URI of the author of the Photo or Review."""7139  )714071417142class GroundingChunkMapsPlaceAnswerSourcesAuthorAttributionDict(7143    TypedDict, total=False7144):7145  """Author attribution for a photo or review."""71467147  display_name: Optional[str]7148  """Name of the author of the Photo or Review."""71497150  photo_uri: Optional[str]7151  """Profile photo URI of the author of the Photo or Review."""71527153  uri: Optional[str]7154  """URI of the author of the Photo or Review."""715571567157GroundingChunkMapsPlaceAnswerSourcesAuthorAttributionOrDict = Union[7158    GroundingChunkMapsPlaceAnswerSourcesAuthorAttribution,7159    GroundingChunkMapsPlaceAnswerSourcesAuthorAttributionDict,7160]716171627163class GroundingChunkMapsPlaceAnswerSourcesReviewSnippet(_common.BaseModel):7164  """Encapsulates a review snippet."""71657166  author_attribution: Optional[7167      GroundingChunkMapsPlaceAnswerSourcesAuthorAttribution7168  ] = Field(default=None, description="""This review's author.""")7169  flag_content_uri: Optional[str] = Field(7170      default=None,7171      description="""A link where users can flag a problem with the review.""",7172  )7173  google_maps_uri: Optional[str] = Field(7174      default=None, description="""A link to show the review on Google Maps."""7175  )7176  relative_publish_time_description: Optional[str] = Field(7177      default=None,7178      description="""A string of formatted recent time, expressing the review time relative to the current time in a form appropriate for the language and country.""",7179  )7180  review: Optional[str] = Field(7181      default=None,7182      description="""A reference representing this place review which may be used to look up this place review again.""",7183  )7184  review_id: Optional[str] = Field(7185      default=None, description="""Id of the review referencing the place."""7186  )7187  title: Optional[str] = Field(7188      default=None, description="""Title of the review."""7189  )719071917192class GroundingChunkMapsPlaceAnswerSourcesReviewSnippetDict(7193    TypedDict, total=False7194):7195  """Encapsulates a review snippet."""71967197  author_attribution: Optional[7198      GroundingChunkMapsPlaceAnswerSourcesAuthorAttributionDict7199  ]7200  """This review's author."""72017202  flag_content_uri: Optional[str]7203  """A link where users can flag a problem with the review."""72047205  google_maps_uri: Optional[str]7206  """A link to show the review on Google Maps."""72077208  relative_publish_time_description: Optional[str]7209  """A string of formatted recent time, expressing the review time relative to the current time in a form appropriate for the language and country."""72107211  review: Optional[str]7212  """A reference representing this place review which may be used to look up this place review again."""72137214  review_id: Optional[str]7215  """Id of the review referencing the place."""72167217  title: Optional[str]7218  """Title of the review."""721972207221GroundingChunkMapsPlaceAnswerSourcesReviewSnippetOrDict = Union[7222    GroundingChunkMapsPlaceAnswerSourcesReviewSnippet,7223    GroundingChunkMapsPlaceAnswerSourcesReviewSnippetDict,7224]722572267227class GroundingChunkMapsPlaceAnswerSources(_common.BaseModel):7228  """The sources that were used to generate the place answer.72297230  This includes review snippets and photos that were used to generate the7231  answer, as well as URIs to flag content.7232  """72337234  review_snippet: Optional[7235      list[GroundingChunkMapsPlaceAnswerSourcesReviewSnippet]7236  ] = Field(7237      default=None,7238      description="""Snippets of reviews that were used to generate the answer.""",7239  )7240  flag_content_uri: Optional[str] = Field(7241      default=None,7242      description="""A link where users can flag a problem with the generated answer.""",7243  )7244  review_snippets: Optional[7245      list[GroundingChunkMapsPlaceAnswerSourcesReviewSnippet]7246  ] = Field(7247      default=None,7248      description="""Snippets of reviews that were used to generate the answer.""",7249  )725072517252class GroundingChunkMapsPlaceAnswerSourcesDict(TypedDict, total=False):7253  """The sources that were used to generate the place answer.72547255  This includes review snippets and photos that were used to generate the7256  answer, as well as URIs to flag content.7257  """72587259  review_snippet: Optional[7260      list[GroundingChunkMapsPlaceAnswerSourcesReviewSnippetDict]7261  ]7262  """Snippets of reviews that were used to generate the answer."""72637264  flag_content_uri: Optional[str]7265  """A link where users can flag a problem with the generated answer."""72667267  review_snippets: Optional[7268      list[GroundingChunkMapsPlaceAnswerSourcesReviewSnippetDict]7269  ]7270  """Snippets of reviews that were used to generate the answer."""727172727273GroundingChunkMapsPlaceAnswerSourcesOrDict = Union[7274    GroundingChunkMapsPlaceAnswerSources,7275    GroundingChunkMapsPlaceAnswerSourcesDict,7276]727772787279class GroundingChunkMapsRoute(_common.BaseModel):7280  """Route information from Google Maps.72817282  This data type is not supported in Gemini API.7283  """72847285  distance_meters: Optional[int] = Field(7286      default=None,7287      description="""The total distance of the route, in meters.""",7288  )7289  duration: Optional[str] = Field(7290      default=None, description="""The total duration of the route."""7291  )7292  encoded_polyline: Optional[str] = Field(7293      default=None,7294      description="""An encoded polyline of the route. See https://developers.google.com/maps/documentation/utilities/polylinealgorithm""",7295  )729672977298class GroundingChunkMapsRouteDict(TypedDict, total=False):7299  """Route information from Google Maps.73007301  This data type is not supported in Gemini API.7302  """73037304  distance_meters: Optional[int]7305  """The total distance of the route, in meters."""73067307  duration: Optional[str]7308  """The total duration of the route."""73097310  encoded_polyline: Optional[str]7311  """An encoded polyline of the route. See https://developers.google.com/maps/documentation/utilities/polylinealgorithm"""731273137314GroundingChunkMapsRouteOrDict = Union[7315    GroundingChunkMapsRoute, GroundingChunkMapsRouteDict7316]731773187319class GroundingChunkMaps(_common.BaseModel):7320  """A `Maps` chunk is a piece of evidence that comes from Google Maps.73217322  It contains information about a place, such as its name, address, and reviews.7323  This is used to provide the user with rich, location-based information.7324  """73257326  place_answer_sources: Optional[GroundingChunkMapsPlaceAnswerSources] = Field(7327      default=None,7328      description="""The sources that were used to generate the place answer.73297330      This includes review snippets and photos that were used to generate the7331      answer, as well as URIs to flag content.""",7332  )7333  place_id: Optional[str] = Field(7334      default=None,7335      description="""This Place's resource name, in `places/{place_id}` format.73367337      This can be used to look up the place in the Google Maps API.""",7338  )7339  text: Optional[str] = Field(7340      default=None, description="""The text of the place answer."""7341  )7342  title: Optional[str] = Field(7343      default=None, description="""The title of the place."""7344  )7345  uri: Optional[str] = Field(7346      default=None, description="""The URI of the place."""7347  )7348  route: Optional[GroundingChunkMapsRoute] = Field(7349      default=None, description="""Output only. Route information."""7350  )735173527353class GroundingChunkMapsDict(TypedDict, total=False):7354  """A `Maps` chunk is a piece of evidence that comes from Google Maps.73557356  It contains information about a place, such as its name, address, and reviews.7357  This is used to provide the user with rich, location-based information.7358  """73597360  place_answer_sources: Optional[GroundingChunkMapsPlaceAnswerSourcesDict]7361  """The sources that were used to generate the place answer.73627363      This includes review snippets and photos that were used to generate the7364      answer, as well as URIs to flag content."""73657366  place_id: Optional[str]7367  """This Place's resource name, in `places/{place_id}` format.73687369      This can be used to look up the place in the Google Maps API."""73707371  text: Optional[str]7372  """The text of the place answer."""73737374  title: Optional[str]7375  """The title of the place."""73767377  uri: Optional[str]7378  """The URI of the place."""73797380  route: Optional[GroundingChunkMapsRouteDict]7381  """Output only. Route information."""738273837384GroundingChunkMapsOrDict = Union[GroundingChunkMaps, GroundingChunkMapsDict]738573867387class GroundingChunkImage(_common.BaseModel):7388  """An `Image` chunk is a piece of evidence that comes from an image search result.73897390  It contains the URI of the image search result and the URI of the image. This7391  is used to provide the user with a link to the source of the information.7392  """73937394  source_uri: Optional[str] = Field(7395      default=None, description="""The URI of the image search result page."""7396  )7397  image_uri: Optional[str] = Field(7398      default=None, description="""The URI of the image."""7399  )7400  title: Optional[str] = Field(7401      default=None, description="""The title of the image search result page."""7402  )7403  domain: Optional[str] = Field(7404      default=None,7405      description="""The domain of the image search result page.""",7406  )740774087409class GroundingChunkImageDict(TypedDict, total=False):7410  """An `Image` chunk is a piece of evidence that comes from an image search result.74117412  It contains the URI of the image search result and the URI of the image. This7413  is used to provide the user with a link to the source of the information.7414  """74157416  source_uri: Optional[str]7417  """The URI of the image search result page."""74187419  image_uri: Optional[str]7420  """The URI of the image."""74217422  title: Optional[str]7423  """The title of the image search result page."""74247425  domain: Optional[str]7426  """The domain of the image search result page."""742774287429GroundingChunkImageOrDict = Union[GroundingChunkImage, GroundingChunkImageDict]743074317432class RagChunkPageSpan(_common.BaseModel):7433  """Represents where the chunk starts and ends in the document.74347435  This data type is not supported in Gemini API.7436  """74377438  first_page: Optional[int] = Field(7439      default=None,7440      description="""Page where chunk starts in the document. Inclusive. 1-indexed.""",7441  )7442  last_page: Optional[int] = Field(7443      default=None,7444      description="""Page where chunk ends in the document. Inclusive. 1-indexed.""",7445  )744674477448class RagChunkPageSpanDict(TypedDict, total=False):7449  """Represents where the chunk starts and ends in the document.74507451  This data type is not supported in Gemini API.7452  """74537454  first_page: Optional[int]7455  """Page where chunk starts in the document. Inclusive. 1-indexed."""74567457  last_page: Optional[int]7458  """Page where chunk ends in the document. Inclusive. 1-indexed."""745974607461RagChunkPageSpanOrDict = Union[RagChunkPageSpan, RagChunkPageSpanDict]746274637464class RagChunk(_common.BaseModel):7465  """A RagChunk includes the content of a chunk of a RagFile, and associated metadata.74667467  This data type is not supported in Gemini API.7468  """74697470  page_span: Optional[RagChunkPageSpan] = Field(7471      default=None,7472      description="""If populated, represents where the chunk starts and ends in the document.""",7473  )7474  text: Optional[str] = Field(7475      default=None, description="""The content of the chunk."""7476  )7477  chunk_id: Optional[str] = Field(7478      default=None, description="""The ID of the chunk."""7479  )7480  file_id: Optional[str] = Field(7481      default=None,7482      description="""The ID of the file that the chunk belongs to.""",7483  )748474857486class RagChunkDict(TypedDict, total=False):7487  """A RagChunk includes the content of a chunk of a RagFile, and associated metadata.74887489  This data type is not supported in Gemini API.7490  """74917492  page_span: Optional[RagChunkPageSpanDict]7493  """If populated, represents where the chunk starts and ends in the document."""74947495  text: Optional[str]7496  """The content of the chunk."""74977498  chunk_id: Optional[str]7499  """The ID of the chunk."""75007501  file_id: Optional[str]7502  """The ID of the file that the chunk belongs to."""750375047505RagChunkOrDict = Union[RagChunk, RagChunkDict]750675077508class GroundingChunkStringList(_common.BaseModel):7509  """A list of string values. This data type is not supported in Vertex AI."""75107511  values: Optional[list[str]] = Field(7512      default=None, description="""The string values of the list."""7513  )751475157516class GroundingChunkStringListDict(TypedDict, total=False):7517  """A list of string values. This data type is not supported in Vertex AI."""75187519  values: Optional[list[str]]7520  """The string values of the list."""752175227523GroundingChunkStringListOrDict = Union[7524    GroundingChunkStringList, GroundingChunkStringListDict7525]752675277528class GroundingChunkCustomMetadata(_common.BaseModel):7529  """User provided metadata about the GroundingFact.75307531  This data type is not supported in Vertex AI.7532  """75337534  key: Optional[str] = Field(7535      default=None, description="""The key of the metadata."""7536  )7537  numeric_value: Optional[float] = Field(7538      default=None,7539      description="""Optional. The numeric value of the metadata. The expected range for this value depends on the specific `key` used.""",7540  )7541  string_list_value: Optional[GroundingChunkStringList] = Field(7542      default=None,7543      description="""Optional. A list of string values for the metadata.""",7544  )7545  string_value: Optional[str] = Field(7546      default=None,7547      description="""Optional. The string value of the metadata.""",7548  )754975507551class GroundingChunkCustomMetadataDict(TypedDict, total=False):7552  """User provided metadata about the GroundingFact.75537554  This data type is not supported in Vertex AI.7555  """75567557  key: Optional[str]7558  """The key of the metadata."""75597560  numeric_value: Optional[float]7561  """Optional. The numeric value of the metadata. The expected range for this value depends on the specific `key` used."""75627563  string_list_value: Optional[GroundingChunkStringListDict]7564  """Optional. A list of string values for the metadata."""75657566  string_value: Optional[str]7567  """Optional. The string value of the metadata."""756875697570GroundingChunkCustomMetadataOrDict = Union[7571    GroundingChunkCustomMetadata, GroundingChunkCustomMetadataDict7572]757375747575class GroundingChunkRetrievedContext(_common.BaseModel):7576  """Context retrieved from a data source to ground the model's response.75777578  This is used when a retrieval tool fetches information from a user-provided7579  corpus or a public dataset.7580  """75817582  document_name: Optional[str] = Field(7583      default=None,7584      description="""Output only. The full resource name of the referenced Vertex AI Search document. This is used to identify the specific document that was retrieved. The format is `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. This field is not supported in Gemini API.""",7585  )7586  rag_chunk: Optional[RagChunk] = Field(7587      default=None,7588      description="""Additional context for a Retrieval-Augmented Generation (RAG) retrieval result. This is populated only when the RAG retrieval tool is used. This field is not supported in Gemini API.""",7589  )7590  text: Optional[str] = Field(7591      default=None, description="""The content of the retrieved data source."""7592  )7593  title: Optional[str] = Field(7594      default=None, description="""The title of the retrieved data source."""7595  )7596  uri: Optional[str] = Field(7597      default=None, description="""The URI of the retrieved data source."""7598  )7599  custom_metadata: Optional[list[GroundingChunkCustomMetadata]] = Field(7600      default=None,7601      description="""Optional. User-provided metadata about the retrieved context. This field is not supported in Vertex AI.""",7602  )7603  file_search_store: Optional[str] = Field(7604      default=None,7605      description="""Optional. Name of the `FileSearchStore` containing the document. Example: `fileSearchStores/123`. This field is not supported in Vertex AI.""",7606  )7607  page_number: Optional[int] = Field(7608      default=None,7609      description="""Optional. Page number of the retrieved context, if applicable. This field is not supported in Vertex AI.""",7610  )7611  media_id: Optional[str] = Field(7612      default=None,7613      description="""Optional. The media blob resource name for multimodal file search results. Format: fileSearchStores/{file_search_store_id}/media/{blob_id}. This field is not supported in Vertex AI.""",7614  )761576167617class GroundingChunkRetrievedContextDict(TypedDict, total=False):7618  """Context retrieved from a data source to ground the model's response.76197620  This is used when a retrieval tool fetches information from a user-provided7621  corpus or a public dataset.7622  """76237624  document_name: Optional[str]7625  """Output only. The full resource name of the referenced Vertex AI Search document. This is used to identify the specific document that was retrieved. The format is `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}`. This field is not supported in Gemini API."""76267627  rag_chunk: Optional[RagChunkDict]7628  """Additional context for a Retrieval-Augmented Generation (RAG) retrieval result. This is populated only when the RAG retrieval tool is used. This field is not supported in Gemini API."""76297630  text: Optional[str]7631  """The content of the retrieved data source."""76327633  title: Optional[str]7634  """The title of the retrieved data source."""76357636  uri: Optional[str]7637  """The URI of the retrieved data source."""76387639  custom_metadata: Optional[list[GroundingChunkCustomMetadataDict]]7640  """Optional. User-provided metadata about the retrieved context. This field is not supported in Vertex AI."""76417642  file_search_store: Optional[str]7643  """Optional. Name of the `FileSearchStore` containing the document. Example: `fileSearchStores/123`. This field is not supported in Vertex AI."""76447645  page_number: Optional[int]7646  """Optional. Page number of the retrieved context, if applicable. This field is not supported in Vertex AI."""76477648  media_id: Optional[str]7649  """Optional. The media blob resource name for multimodal file search results. Format: fileSearchStores/{file_search_store_id}/media/{blob_id}. This field is not supported in Vertex AI."""765076517652GroundingChunkRetrievedContextOrDict = Union[7653    GroundingChunkRetrievedContext, GroundingChunkRetrievedContextDict7654]765576567657class GroundingChunkWeb(_common.BaseModel):7658  """A `Web` chunk is a piece of evidence that comes from a web page.76597660  It contains the URI of the web page, the title of the page, and the domain of7661  the page. This is used to provide the user with a link to the source of the7662  information.7663  """76647665  domain: Optional[str] = Field(7666      default=None,7667      description="""The domain of the web page that contains the evidence. This can be used to filter out low-quality sources. This field is not supported in Gemini API.""",7668  )7669  title: Optional[str] = Field(7670      default=None,7671      description="""The title of the web page that contains the evidence.""",7672  )7673  uri: Optional[str] = Field(7674      default=None,7675      description="""The URI of the web page that contains the evidence.""",7676  )767776787679class GroundingChunkWebDict(TypedDict, total=False):7680  """A `Web` chunk is a piece of evidence that comes from a web page.76817682  It contains the URI of the web page, the title of the page, and the domain of7683  the page. This is used to provide the user with a link to the source of the7684  information.7685  """76867687  domain: Optional[str]7688  """The domain of the web page that contains the evidence. This can be used to filter out low-quality sources. This field is not supported in Gemini API."""76897690  title: Optional[str]7691  """The title of the web page that contains the evidence."""76927693  uri: Optional[str]7694  """The URI of the web page that contains the evidence."""769576967697GroundingChunkWebOrDict = Union[GroundingChunkWeb, GroundingChunkWebDict]769876997700class GroundingChunk(_common.BaseModel):7701  """A piece of evidence that supports a claim made by the model.77027703  This is used to show a citation for a claim made by the model. When grounding7704  is enabled, the model returns a `GroundingChunk` that contains a reference to7705  the source of the information.7706  """77077708  image: Optional[GroundingChunkImage] = Field(7709      default=None,7710      description="""A grounding chunk from an image search result. See the `Image` message for details.""",7711  )7712  maps: Optional[GroundingChunkMaps] = Field(7713      default=None,7714      description="""A `Maps` chunk is a piece of evidence that comes from Google Maps.77157716      It contains information about a place, such as its name, address, and7717      reviews. This is used to provide the user with rich, location-based7718      information.""",7719  )7720  retrieved_context: Optional[GroundingChunkRetrievedContext] = Field(7721      default=None,7722      description="""A grounding chunk from a data source retrieved by a retrieval tool, such as Vertex AI Search. See the `RetrievedContext` message for details""",7723  )7724  web: Optional[GroundingChunkWeb] = Field(7725      default=None,7726      description="""A grounding chunk from a web page, typically from Google Search. See the `Web` message for details.""",7727  )772877297730class GroundingChunkDict(TypedDict, total=False):7731  """A piece of evidence that supports a claim made by the model.77327733  This is used to show a citation for a claim made by the model. When grounding7734  is enabled, the model returns a `GroundingChunk` that contains a reference to7735  the source of the information.7736  """77377738  image: Optional[GroundingChunkImageDict]7739  """A grounding chunk from an image search result. See the `Image` message for details."""77407741  maps: Optional[GroundingChunkMapsDict]7742  """A `Maps` chunk is a piece of evidence that comes from Google Maps.77437744      It contains information about a place, such as its name, address, and7745      reviews. This is used to provide the user with rich, location-based7746      information."""77477748  retrieved_context: Optional[GroundingChunkRetrievedContextDict]7749  """A grounding chunk from a data source retrieved by a retrieval tool, such as Vertex AI Search. See the `RetrievedContext` message for details"""77507751  web: Optional[GroundingChunkWebDict]7752  """A grounding chunk from a web page, typically from Google Search. See the `Web` message for details."""775377547755GroundingChunkOrDict = Union[GroundingChunk, GroundingChunkDict]775677577758class Segment(_common.BaseModel):7759  """Segment of the content this support belongs to."""77607761  start_index: Optional[int] = Field(7762      default=None,7763      description="""Output only. Start index in the given Part, measured in bytes.77647765      Offset from the start of the Part, inclusive, starting at zero.""",7766  )7767  end_index: Optional[int] = Field(7768      default=None,7769      description="""Output only. End index in the given Part, measured in bytes.77707771      Offset from the start of the Part, exclusive, starting at zero.""",7772  )7773  part_index: Optional[int] = Field(7774      default=None,7775      description="""Output only. The index of a Part object within its parent7776      Content object.""",7777  )7778  text: Optional[str] = Field(7779      default=None,7780      description="""Output only. The text corresponding to the segment from the7781      response.""",7782  )778377847785class SegmentDict(TypedDict, total=False):7786  """Segment of the content this support belongs to."""77877788  start_index: Optional[int]7789  """Output only. Start index in the given Part, measured in bytes.77907791      Offset from the start of the Part, inclusive, starting at zero."""77927793  end_index: Optional[int]7794  """Output only. End index in the given Part, measured in bytes.77957796      Offset from the start of the Part, exclusive, starting at zero."""77977798  part_index: Optional[int]7799  """Output only. The index of a Part object within its parent7800      Content object."""78017802  text: Optional[str]7803  """Output only. The text corresponding to the segment from the7804      response."""780578067807SegmentOrDict = Union[Segment, SegmentDict]780878097810class GroundingSupport(_common.BaseModel):7811  """Grounding support."""78127813  confidence_scores: Optional[list[float]] = Field(7814      default=None,7815      description="""Confidence score of the support references.78167817      Ranges from 0 to 1. 1 is the most confident. This list must have the7818      same size as the grounding_chunk_indices.""",7819  )7820  grounding_chunk_indices: Optional[list[int]] = Field(7821      default=None,7822      description="""A list of indices (into 'grounding_chunk') specifying the7823      citations associated with the claim. For instance [1,3,4] means that7824      grounding_chunk[1], grounding_chunk[3], grounding_chunk[4] are the7825      retrieved content attributed to the claim.""",7826  )7827  segment: Optional[Segment] = Field(7828      default=None,7829      description="""Segment of the content this support belongs to.""",7830  )7831  rendered_parts: Optional[list[int]] = Field(7832      default=None,7833      description="""Indices into the `rendered_parts` field of the `GroundingMetadata` message. These indices specify which rendered parts are associated with this support message.""",7834  )783578367837class GroundingSupportDict(TypedDict, total=False):7838  """Grounding support."""78397840  confidence_scores: Optional[list[float]]7841  """Confidence score of the support references.78427843      Ranges from 0 to 1. 1 is the most confident. This list must have the7844      same size as the grounding_chunk_indices."""78457846  grounding_chunk_indices: Optional[list[int]]7847  """A list of indices (into 'grounding_chunk') specifying the7848      citations associated with the claim. For instance [1,3,4] means that7849      grounding_chunk[1], grounding_chunk[3], grounding_chunk[4] are the7850      retrieved content attributed to the claim."""78517852  segment: Optional[SegmentDict]7853  """Segment of the content this support belongs to."""78547855  rendered_parts: Optional[list[int]]7856  """Indices into the `rendered_parts` field of the `GroundingMetadata` message. These indices specify which rendered parts are associated with this support message."""785778587859GroundingSupportOrDict = Union[GroundingSupport, GroundingSupportDict]786078617862class RetrievalMetadata(_common.BaseModel):7863  """Metadata returned to client when grounding is enabled."""78647865  google_search_dynamic_retrieval_score: Optional[float] = Field(7866      default=None,7867      description="""Optional. Score indicating how likely information from google7868      search could help answer the prompt. The score is in the range [0, 1],7869      where 0 is the least likely and 1 is the most likely. This score is only7870      populated when google search grounding and dynamic retrieval is enabled.7871      It will be compared to the threshold to determine whether to trigger7872      Google search.""",7873  )787478757876class RetrievalMetadataDict(TypedDict, total=False):7877  """Metadata returned to client when grounding is enabled."""78787879  google_search_dynamic_retrieval_score: Optional[float]7880  """Optional. Score indicating how likely information from google7881      search could help answer the prompt. The score is in the range [0, 1],7882      where 0 is the least likely and 1 is the most likely. This score is only7883      populated when google search grounding and dynamic retrieval is enabled.7884      It will be compared to the threshold to determine whether to trigger7885      Google search."""788678877888RetrievalMetadataOrDict = Union[RetrievalMetadata, RetrievalMetadataDict]788978907891class SearchEntryPoint(_common.BaseModel):7892  """The entry point used to search for grounding sources."""78937894  rendered_content: Optional[str] = Field(7895      default=None,7896      description="""Optional. Web content snippet that can be embedded in a web page7897      or an app webview.""",7898  )7899  sdk_blob: Optional[bytes] = Field(7900      default=None,7901      description="""Optional. JSON representing array of tuples.""",7902  )790379047905class SearchEntryPointDict(TypedDict, total=False):7906  """The entry point used to search for grounding sources."""79077908  rendered_content: Optional[str]7909  """Optional. Web content snippet that can be embedded in a web page7910      or an app webview."""79117912  sdk_blob: Optional[bytes]7913  """Optional. JSON representing array of tuples."""791479157916SearchEntryPointOrDict = Union[SearchEntryPoint, SearchEntryPointDict]791779187919class GroundingMetadataSourceFlaggingUri(_common.BaseModel):7920  """A URI that can be used to flag a place or review for inappropriate content.79217922  This is populated only when the grounding source is Google Maps. This data7923  type is not supported in Gemini API.7924  """79257926  flag_content_uri: Optional[str] = Field(7927      default=None,7928      description="""The URI that can be used to flag the content.""",7929  )7930  source_id: Optional[str] = Field(7931      default=None, description="""The ID of the place or review."""7932  )793379347935class GroundingMetadataSourceFlaggingUriDict(TypedDict, total=False):7936  """A URI that can be used to flag a place or review for inappropriate content.79377938  This is populated only when the grounding source is Google Maps. This data7939  type is not supported in Gemini API.7940  """79417942  flag_content_uri: Optional[str]7943  """The URI that can be used to flag the content."""79447945  source_id: Optional[str]7946  """The ID of the place or review."""794779487949GroundingMetadataSourceFlaggingUriOrDict = Union[7950    GroundingMetadataSourceFlaggingUri, GroundingMetadataSourceFlaggingUriDict7951]795279537954class GroundingMetadata(_common.BaseModel):7955  """Information for various kinds of grounding."""79567957  image_search_queries: Optional[list[str]] = Field(7958      default=None,7959      description="""Optional. The image search queries that were used to generate the content. This field is populated only when the grounding source is Google Search with the Image Search search_type enabled.""",7960  )7961  grounding_chunks: Optional[list[GroundingChunk]] = Field(7962      default=None,7963      description="""A list of supporting references retrieved from the grounding7964      source. This field is populated when the grounding source is Google7965      Search, Vertex AI Search, or Google Maps.7966      """,7967  )7968  grounding_supports: Optional[list[GroundingSupport]] = Field(7969      default=None, description="""List of grounding support."""7970  )7971  retrieval_metadata: Optional[RetrievalMetadata] = Field(7972      default=None,7973      description="""Metadata related to retrieval in the grounding flow.""",7974  )7975  search_entry_point: Optional[SearchEntryPoint] = Field(7976      default=None,7977      description="""Optional. Google search entry for the following-up web7978      searches.""",7979  )7980  web_search_queries: Optional[list[str]] = Field(7981      default=None,7982      description="""Web search queries for the following-up web search.""",7983  )7984  google_maps_widget_context_token: Optional[str] = Field(7985      default=None,7986      description="""Optional. Output only. Deprecated: The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and will no longer be populated once removed. A token that can be used to render a Google Maps widget with the contextual data. This field is populated only when the grounding source is Google Maps.""",7987  )7988  retrieval_queries: Optional[list[str]] = Field(7989      default=None,7990      description="""Optional. The queries that were executed by the retrieval tools. This field is populated only when the grounding source is a retrieval tool, such as Vertex AI Search. This field is not supported in Gemini API.""",7991  )7992  source_flagging_uris: Optional[list[GroundingMetadataSourceFlaggingUri]] = (7993      Field(7994          default=None,7995          description="""Optional. Output only. A list of URIs that can be used to flag a place or review for inappropriate content. This field is populated only when the grounding source is Google Maps. This field is not supported in Gemini API.""",7996      )7997  )799879998000class GroundingMetadataDict(TypedDict, total=False):8001  """Information for various kinds of grounding."""80028003  image_search_queries: Optional[list[str]]8004  """Optional. The image search queries that were used to generate the content. This field is populated only when the grounding source is Google Search with the Image Search search_type enabled."""80058006  grounding_chunks: Optional[list[GroundingChunkDict]]8007  """A list of supporting references retrieved from the grounding8008      source. This field is populated when the grounding source is Google8009      Search, Vertex AI Search, or Google Maps.8010      """80118012  grounding_supports: Optional[list[GroundingSupportDict]]8013  """List of grounding support."""80148015  retrieval_metadata: Optional[RetrievalMetadataDict]8016  """Metadata related to retrieval in the grounding flow."""80178018  search_entry_point: Optional[SearchEntryPointDict]8019  """Optional. Google search entry for the following-up web8020      searches."""80218022  web_search_queries: Optional[list[str]]8023  """Web search queries for the following-up web search."""80248025  google_maps_widget_context_token: Optional[str]8026  """Optional. Output only. Deprecated: The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and will no longer be populated once removed. A token that can be used to render a Google Maps widget with the contextual data. This field is populated only when the grounding source is Google Maps."""80278028  retrieval_queries: Optional[list[str]]8029  """Optional. The queries that were executed by the retrieval tools. This field is populated only when the grounding source is a retrieval tool, such as Vertex AI Search. This field is not supported in Gemini API."""80308031  source_flagging_uris: Optional[list[GroundingMetadataSourceFlaggingUriDict]]8032  """Optional. Output only. A list of URIs that can be used to flag a place or review for inappropriate content. This field is populated only when the grounding source is Google Maps. This field is not supported in Gemini API."""803380348035GroundingMetadataOrDict = Union[GroundingMetadata, GroundingMetadataDict]803680378038class LogprobsResultCandidate(_common.BaseModel):8039  """A single token and its associated log probability."""80408041  log_probability: Optional[float] = Field(8042      default=None,8043      description="""The log probability of this token. A higher value indicates that the model was more confident in this token. The log probability can be used to assess the relative likelihood of different tokens and to identify when the model is uncertain.""",8044  )8045  token: Optional[str] = Field(8046      default=None, description="""The token's string representation."""8047  )8048  token_id: Optional[int] = Field(8049      default=None,8050      description="""The token's numerical ID. While the `token` field provides the string representation of the token, the `token_id` is the numerical representation that the model uses internally. This can be useful for developers who want to build custom logic based on the model's vocabulary.""",8051  )805280538054class LogprobsResultCandidateDict(TypedDict, total=False):8055  """A single token and its associated log probability."""80568057  log_probability: Optional[float]8058  """The log probability of this token. A higher value indicates that the model was more confident in this token. The log probability can be used to assess the relative likelihood of different tokens and to identify when the model is uncertain."""80598060  token: Optional[str]8061  """The token's string representation."""80628063  token_id: Optional[int]8064  """The token's numerical ID. While the `token` field provides the string representation of the token, the `token_id` is the numerical representation that the model uses internally. This can be useful for developers who want to build custom logic based on the model's vocabulary."""806580668067LogprobsResultCandidateOrDict = Union[8068    LogprobsResultCandidate, LogprobsResultCandidateDict8069]807080718072class LogprobsResultTopCandidates(_common.BaseModel):8073  """A list of the top candidate tokens and their log probabilities at each decoding step.80748075  This can be used to see what other tokens the model considered.8076  """80778078  candidates: Optional[list[LogprobsResultCandidate]] = Field(8079      default=None,8080      description="""The list of candidate tokens, sorted by log probability in descending order.""",8081  )808280838084class LogprobsResultTopCandidatesDict(TypedDict, total=False):8085  """A list of the top candidate tokens and their log probabilities at each decoding step.80868087  This can be used to see what other tokens the model considered.8088  """80898090  candidates: Optional[list[LogprobsResultCandidateDict]]8091  """The list of candidate tokens, sorted by log probability in descending order."""809280938094LogprobsResultTopCandidatesOrDict = Union[8095    LogprobsResultTopCandidates, LogprobsResultTopCandidatesDict8096]809780988099class LogprobsResult(_common.BaseModel):8100  """The log probabilities of the tokens generated by the model.81018102  This is useful for understanding the model's confidence in its predictions and8103  for debugging. For example, you can use log probabilities to identify when the8104  model is making a less confident prediction or to explore alternative8105  responses that the model considered. A low log probability can also indicate8106  that the model is "hallucinating" or generating factually incorrect8107  information.8108  """81098110  chosen_candidates: Optional[list[LogprobsResultCandidate]] = Field(8111      default=None,8112      description="""A list of the chosen candidate tokens at each decoding step. The length of this list is equal to the total number of decoding steps. Note that the chosen candidate might not be in `top_candidates`.""",8113  )8114  top_candidates: Optional[list[LogprobsResultTopCandidates]] = Field(8115      default=None,8116      description="""A list of the top candidate tokens at each decoding step. The length of this list is equal to the total number of decoding steps.""",8117  )8118  log_probability_sum: Optional[float] = Field(8119      default=None,8120      description="""Sum of log probabilities for all tokens. This field is not supported in Vertex AI.""",8121  )812281238124class LogprobsResultDict(TypedDict, total=False):8125  """The log probabilities of the tokens generated by the model.81268127  This is useful for understanding the model's confidence in its predictions and8128  for debugging. For example, you can use log probabilities to identify when the8129  model is making a less confident prediction or to explore alternative8130  responses that the model considered. A low log probability can also indicate8131  that the model is "hallucinating" or generating factually incorrect8132  information.8133  """81348135  chosen_candidates: Optional[list[LogprobsResultCandidateDict]]8136  """A list of the chosen candidate tokens at each decoding step. The length of this list is equal to the total number of decoding steps. Note that the chosen candidate might not be in `top_candidates`."""81378138  top_candidates: Optional[list[LogprobsResultTopCandidatesDict]]8139  """A list of the top candidate tokens at each decoding step. The length of this list is equal to the total number of decoding steps."""81408141  log_probability_sum: Optional[float]8142  """Sum of log probabilities for all tokens. This field is not supported in Vertex AI."""814381448145LogprobsResultOrDict = Union[LogprobsResult, LogprobsResultDict]814681478148class SafetyRating(_common.BaseModel):8149  """A safety rating for a piece of content.81508151  The safety rating contains the harm category and the harm probability level.8152  """81538154  blocked: Optional[bool] = Field(8155      default=None,8156      description="""Output only. Indicates whether the content was blocked because of this rating.""",8157  )8158  category: Optional[HarmCategory] = Field(8159      default=None,8160      description="""Output only. The harm category of this rating.""",8161  )8162  overwritten_threshold: Optional[HarmBlockThreshold] = Field(8163      default=None,8164      description="""Output only. The overwritten threshold for the safety category of Gemini 2.0 image out. If minors are detected in the output image, the threshold of each safety category will be overwritten if user sets a lower threshold. This field is not supported in Gemini API.""",8165  )8166  probability: Optional[HarmProbability] = Field(8167      default=None,8168      description="""Output only. The probability of harm for this category.""",8169  )8170  probability_score: Optional[float] = Field(8171      default=None,8172      description="""Output only. The probability score of harm for this category. This field is not supported in Gemini API.""",8173  )8174  severity: Optional[HarmSeverity] = Field(8175      default=None,8176      description="""Output only. The severity of harm for this category. This field is not supported in Gemini API.""",8177  )8178  severity_score: Optional[float] = Field(8179      default=None,8180      description="""Output only. The severity score of harm for this category. This field is not supported in Gemini API.""",8181  )818281838184class SafetyRatingDict(TypedDict, total=False):8185  """A safety rating for a piece of content.81868187  The safety rating contains the harm category and the harm probability level.8188  """81898190  blocked: Optional[bool]8191  """Output only. Indicates whether the content was blocked because of this rating."""81928193  category: Optional[HarmCategory]8194  """Output only. The harm category of this rating."""81958196  overwritten_threshold: Optional[HarmBlockThreshold]8197  """Output only. The overwritten threshold for the safety category of Gemini 2.0 image out. If minors are detected in the output image, the threshold of each safety category will be overwritten if user sets a lower threshold. This field is not supported in Gemini API."""81988199  probability: Optional[HarmProbability]8200  """Output only. The probability of harm for this category."""82018202  probability_score: Optional[float]8203  """Output only. The probability score of harm for this category. This field is not supported in Gemini API."""82048205  severity: Optional[HarmSeverity]8206  """Output only. The severity of harm for this category. This field is not supported in Gemini API."""82078208  severity_score: Optional[float]8209  """Output only. The severity score of harm for this category. This field is not supported in Gemini API."""821082118212SafetyRatingOrDict = Union[SafetyRating, SafetyRatingDict]821382148215class UrlMetadata(_common.BaseModel):8216  """The metadata for a single URL retrieval."""82178218  retrieved_url: Optional[str] = Field(8219      default=None, description="""The URL retrieved by the tool."""8220  )8221  url_retrieval_status: Optional[UrlRetrievalStatus] = Field(8222      default=None, description="""The status of the URL retrieval."""8223  )822482258226class UrlMetadataDict(TypedDict, total=False):8227  """The metadata for a single URL retrieval."""82288229  retrieved_url: Optional[str]8230  """The URL retrieved by the tool."""82318232  url_retrieval_status: Optional[UrlRetrievalStatus]8233  """The status of the URL retrieval."""823482358236UrlMetadataOrDict = Union[UrlMetadata, UrlMetadataDict]823782388239class UrlContextMetadata(_common.BaseModel):8240  """Metadata returned when the model uses the `url_context` tool to get information from a user-provided URL."""82418242  url_metadata: Optional[list[UrlMetadata]] = Field(8243      default=None,8244      description="""Output only. A list of URL metadata, with one entry for each URL retrieved by the tool.""",8245  )824682478248class UrlContextMetadataDict(TypedDict, total=False):8249  """Metadata returned when the model uses the `url_context` tool to get information from a user-provided URL."""82508251  url_metadata: Optional[list[UrlMetadataDict]]8252  """Output only. A list of URL metadata, with one entry for each URL retrieved by the tool."""825382548255UrlContextMetadataOrDict = Union[UrlContextMetadata, UrlContextMetadataDict]825682578258class Candidate(_common.BaseModel):8259  """A response candidate generated from the model."""82608261  content: Optional[Content] = Field(8262      default=None,8263      description="""Contains the multi-part content of the response.8264      """,8265  )8266  citation_metadata: Optional[CitationMetadata] = Field(8267      default=None,8268      description="""Source attribution of the generated content.8269      """,8270  )8271  finish_message: Optional[str] = Field(8272      default=None,8273      description="""Describes the reason the model stopped generating tokens.8274      """,8275  )8276  token_count: Optional[int] = Field(8277      default=None,8278      description="""Number of tokens for this candidate.8279      """,8280  )8281  finish_reason: Optional[FinishReason] = Field(8282      default=None,8283      description="""The reason why the model stopped generating tokens.8284      If empty, the model has not stopped generating the tokens.8285      """,8286  )8287  grounding_metadata: Optional[GroundingMetadata] = Field(8288      default=None,8289      description="""Output only. Metadata returned when grounding is enabled. It8290      contains the sources used to ground the generated content.8291      """,8292  )8293  avg_logprobs: Optional[float] = Field(8294      default=None,8295      description="""Output only. The average log probability of the tokens in this candidate. This is a length-normalized score that can be used to compare the quality of candidates of different lengths. A higher average log probability suggests a more confident and coherent response.""",8296  )8297  index: Optional[int] = Field(8298      default=None,8299      description="""Output only. The 0-based index of this candidate in the list of generated responses. This is useful for distinguishing between multiple candidates when `candidate_count` > 1.""",8300  )8301  logprobs_result: Optional[LogprobsResult] = Field(8302      default=None,8303      description="""Output only. The detailed log probability information for the tokens in this candidate. This is useful for debugging, understanding model uncertainty, and identifying potential "hallucinations".""",8304  )8305  safety_ratings: Optional[list[SafetyRating]] = Field(8306      default=None,8307      description="""Output only. A list of ratings for the safety of a response candidate. There is at most one rating per category.""",8308  )8309  url_context_metadata: Optional[UrlContextMetadata] = Field(8310      default=None,8311      description="""Output only. Metadata returned when the model uses the `url_context` tool to get information from a user-provided URL.""",8312  )831383148315class CandidateDict(TypedDict, total=False):8316  """A response candidate generated from the model."""83178318  content: Optional[ContentDict]8319  """Contains the multi-part content of the response.8320      """83218322  citation_metadata: Optional[CitationMetadataDict]8323  """Source attribution of the generated content.8324      """83258326  finish_message: Optional[str]8327  """Describes the reason the model stopped generating tokens.8328      """83298330  token_count: Optional[int]8331  """Number of tokens for this candidate.8332      """83338334  finish_reason: Optional[FinishReason]8335  """The reason why the model stopped generating tokens.8336      If empty, the model has not stopped generating the tokens.8337      """83388339  grounding_metadata: Optional[GroundingMetadataDict]8340  """Output only. Metadata returned when grounding is enabled. It8341      contains the sources used to ground the generated content.8342      """83438344  avg_logprobs: Optional[float]8345  """Output only. The average log probability of the tokens in this candidate. This is a length-normalized score that can be used to compare the quality of candidates of different lengths. A higher average log probability suggests a more confident and coherent response."""83468347  index: Optional[int]8348  """Output only. The 0-based index of this candidate in the list of generated responses. This is useful for distinguishing between multiple candidates when `candidate_count` > 1."""83498350  logprobs_result: Optional[LogprobsResultDict]8351  """Output only. The detailed log probability information for the tokens in this candidate. This is useful for debugging, understanding model uncertainty, and identifying potential "hallucinations"."""83528353  safety_ratings: Optional[list[SafetyRatingDict]]8354  """Output only. A list of ratings for the safety of a response candidate. There is at most one rating per category."""83558356  url_context_metadata: Optional[UrlContextMetadataDict]8357  """Output only. Metadata returned when the model uses the `url_context` tool to get information from a user-provided URL."""835883598360CandidateOrDict = Union[Candidate, CandidateDict]836183628363class GenerateContentResponsePromptFeedback(_common.BaseModel):8364  """Content filter results for a prompt sent in the request.83658366  Note: This is sent only in the first stream chunk and only if no candidates8367  were generated due to content violations.8368  """83698370  block_reason: Optional[BlockedReason] = Field(8371      default=None,8372      description="""Output only. The reason why the prompt was blocked.""",8373  )8374  block_reason_message: Optional[str] = Field(8375      default=None,8376      description="""Output only. A readable message that explains the reason why the prompt was blocked. This field is not supported in Gemini API.""",8377  )8378  safety_ratings: Optional[list[SafetyRating]] = Field(8379      default=None,8380      description="""Output only. A list of safety ratings for the prompt. There is one rating per category.""",8381  )838283838384class GenerateContentResponsePromptFeedbackDict(TypedDict, total=False):8385  """Content filter results for a prompt sent in the request.83868387  Note: This is sent only in the first stream chunk and only if no candidates8388  were generated due to content violations.8389  """83908391  block_reason: Optional[BlockedReason]8392  """Output only. The reason why the prompt was blocked."""83938394  block_reason_message: Optional[str]8395  """Output only. A readable message that explains the reason why the prompt was blocked. This field is not supported in Gemini API."""83968397  safety_ratings: Optional[list[SafetyRatingDict]]8398  """Output only. A list of safety ratings for the prompt. There is one rating per category."""839984008401GenerateContentResponsePromptFeedbackOrDict = Union[8402    GenerateContentResponsePromptFeedback,8403    GenerateContentResponsePromptFeedbackDict,8404]840584068407class ModalityTokenCount(_common.BaseModel):8408  """Represents a breakdown of token usage by modality.84098410  This message is used in CountTokensResponse and8411  GenerateContentResponse.UsageMetadata to provide a detailed view of how many8412  tokens are used by each modality (e.g., text, image, video) in a request. This8413  is particularly useful for multimodal models, allowing you to track and manage8414  token consumption for billing and quota purposes.8415  """84168417  modality: Optional[MediaModality] = Field(8418      default=None,8419      description="""The modality that this token count applies to.""",8420  )8421  token_count: Optional[int] = Field(8422      default=None,8423      description="""The number of tokens counted for this modality.""",8424  )842584268427class ModalityTokenCountDict(TypedDict, total=False):8428  """Represents a breakdown of token usage by modality.84298430  This message is used in CountTokensResponse and8431  GenerateContentResponse.UsageMetadata to provide a detailed view of how many8432  tokens are used by each modality (e.g., text, image, video) in a request. This8433  is particularly useful for multimodal models, allowing you to track and manage8434  token consumption for billing and quota purposes.8435  """84368437  modality: Optional[MediaModality]8438  """The modality that this token count applies to."""84398440  token_count: Optional[int]8441  """The number of tokens counted for this modality."""844284438444ModalityTokenCountOrDict = Union[ModalityTokenCount, ModalityTokenCountDict]844584468447class GenerateContentResponseUsageMetadata(_common.BaseModel):8448  """Usage metadata about the content generation request and response.84498450  This message provides a detailed breakdown of token usage and other relevant8451  metrics. This data type is not supported in Gemini API.8452  """84538454  cache_tokens_details: Optional[list[ModalityTokenCount]] = Field(8455      default=None,8456      description="""Output only. A detailed breakdown of the token count for each modality in the cached content.""",8457  )8458  cached_content_token_count: Optional[int] = Field(8459      default=None,8460      description="""Output only. The number of tokens in the cached content that was used for this request.""",8461  )8462  candidates_token_count: Optional[int] = Field(8463      default=None,8464      description="""The total number of tokens in the generated candidates.""",8465  )8466  candidates_tokens_details: Optional[list[ModalityTokenCount]] = Field(8467      default=None,8468      description="""Output only. A detailed breakdown of the token count for each modality in the generated candidates.""",8469  )8470  prompt_token_count: Optional[int] = Field(8471      default=None,8472      description="""The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When `cached_content` is set, this also includes the number of tokens in the cached content.""",8473  )8474  prompt_tokens_details: Optional[list[ModalityTokenCount]] = Field(8475      default=None,8476      description="""Output only. A detailed breakdown of the token count for each modality in the prompt.""",8477  )8478  thoughts_token_count: Optional[int] = Field(8479      default=None,8480      description="""Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable.""",8481  )8482  tool_use_prompt_token_count: Optional[int] = Field(8483      default=None,8484      description="""Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable.""",8485  )8486  tool_use_prompt_tokens_details: Optional[list[ModalityTokenCount]] = Field(8487      default=None,8488      description="""Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input.""",8489  )8490  total_token_count: Optional[int] = Field(8491      default=None,8492      description="""The total number of tokens for the entire request. This is the sum of `prompt_token_count`, `candidates_token_count`, `tool_use_prompt_token_count`, and `thoughts_token_count`.""",8493  )8494  traffic_type: Optional[TrafficType] = Field(8495      default=None,8496      description="""Output only. The traffic type for this request.""",8497  )849884998500class GenerateContentResponseUsageMetadataDict(TypedDict, total=False):8501  """Usage metadata about the content generation request and response.85028503  This message provides a detailed breakdown of token usage and other relevant8504  metrics. This data type is not supported in Gemini API.8505  """85068507  cache_tokens_details: Optional[list[ModalityTokenCountDict]]8508  """Output only. A detailed breakdown of the token count for each modality in the cached content."""85098510  cached_content_token_count: Optional[int]8511  """Output only. The number of tokens in the cached content that was used for this request."""85128513  candidates_token_count: Optional[int]8514  """The total number of tokens in the generated candidates."""85158516  candidates_tokens_details: Optional[list[ModalityTokenCountDict]]8517  """Output only. A detailed breakdown of the token count for each modality in the generated candidates."""85188519  prompt_token_count: Optional[int]8520  """The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When `cached_content` is set, this also includes the number of tokens in the cached content."""85218522  prompt_tokens_details: Optional[list[ModalityTokenCountDict]]8523  """Output only. A detailed breakdown of the token count for each modality in the prompt."""85248525  thoughts_token_count: Optional[int]8526  """Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable."""85278528  tool_use_prompt_token_count: Optional[int]8529  """Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable."""85308531  tool_use_prompt_tokens_details: Optional[list[ModalityTokenCountDict]]8532  """Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input."""85338534  total_token_count: Optional[int]8535  """The total number of tokens for the entire request. This is the sum of `prompt_token_count`, `candidates_token_count`, `tool_use_prompt_token_count`, and `thoughts_token_count`."""85368537  traffic_type: Optional[TrafficType]8538  """Output only. The traffic type for this request."""853985408541GenerateContentResponseUsageMetadataOrDict = Union[8542    GenerateContentResponseUsageMetadata,8543    GenerateContentResponseUsageMetadataDict,8544]854585468547class ModelStatus(_common.BaseModel):8548  """The status of the underlying model.85498550  This is used to indicate the stage of the underlying model and the retirement8551  time if applicable. This data type is not supported in Vertex AI.8552  """85538554  message: Optional[str] = Field(8555      default=None, description="""A message explaining the model status."""8556  )8557  model_stage: Optional[ModelStage] = Field(8558      default=None, description="""The stage of the underlying model."""8559  )8560  retirement_time: Optional[datetime.datetime] = Field(8561      default=None,8562      description="""The time at which the model will be retired.""",8563  )856485658566class ModelStatusDict(TypedDict, total=False):8567  """The status of the underlying model.85688569  This is used to indicate the stage of the underlying model and the retirement8570  time if applicable. This data type is not supported in Vertex AI.8571  """85728573  message: Optional[str]8574  """A message explaining the model status."""85758576  model_stage: Optional[ModelStage]8577  """The stage of the underlying model."""85788579  retirement_time: Optional[datetime.datetime]8580  """The time at which the model will be retired."""858185828583ModelStatusOrDict = Union[ModelStatus, ModelStatusDict]858485858586class GenerateContentResponse(_common.BaseModel):8587  """Response message for PredictionService.GenerateContent."""85888589  sdk_http_response: Optional[HttpResponse] = Field(8590      default=None, description="""Used to retain the full HTTP response."""8591  )8592  candidates: Optional[list[Candidate]] = Field(8593      default=None,8594      description="""Response variations returned by the model.8595      """,8596  )8597  create_time: Optional[datetime.datetime] = Field(8598      default=None,8599      description="""Timestamp when the request is made to the server.8600      """,8601  )8602  model_version: Optional[str] = Field(8603      default=None,8604      description="""Output only. The model version used to generate the response.""",8605  )8606  prompt_feedback: Optional[GenerateContentResponsePromptFeedback] = Field(8607      default=None,8608      description="""Output only. Content filter results for a prompt sent in the request. Note: Sent only in the first stream chunk. Only happens when no candidates were generated due to content violations.""",8609  )8610  response_id: Optional[str] = Field(8611      default=None,8612      description="""Output only. response_id is used to identify each response. It is the encoding of the event_id.""",8613  )8614  usage_metadata: Optional[GenerateContentResponseUsageMetadata] = Field(8615      default=None, description="""Usage metadata about the response(s)."""8616  )8617  model_status: Optional[ModelStatus] = Field(8618      default=None,8619      description="""Output only. The current model status of this model. This field is not supported in Vertex AI.""",8620  )8621  automatic_function_calling_history: Optional[list[Content]] = None8622  parsed: Optional[Union[pydantic.BaseModel, dict[Any, Any], Enum]] = Field(8623      default=None,8624      description="""First candidate from the parsed response if response_schema is provided. Not available for streaming.""",8625  )86268627  def _get_text(self) -> Optional[str]:8628    """Returns the concatenation of all text parts in the response.86298630    This is an internal method that allows customizing or disabling the warning8631    message.86328633    Returns:8634      The concatenation of all text parts in the response.8635    """8636    if (8637        not self.candidates8638        or not self.candidates[0].content8639        or not self.candidates[0].content.parts8640    ):8641      return None8642    global _response_text_warning_logged8643    if len(self.candidates) > 1 and not _response_text_warning_logged:8644      logger.warning(8645          f'there are {len(self.candidates)} candidates, returning text result'8646          ' from the first candidate. Access response.candidates directly to'8647          ' get the result from other candidates.'8648      )8649      _response_text_warning_logged = True8650    text = ''8651    any_text_part_text = False8652    non_text_parts = []8653    for part in self.candidates[0].content.parts:8654      for field_name, field_value in part.model_dump(8655          exclude={'text', 'thought', 'thought_signature'}8656      ).items():8657        if field_value is not None:8658          non_text_parts.append(field_name)8659      if isinstance(part.text, str):8660        if isinstance(part.thought, bool) and part.thought:8661          continue8662        any_text_part_text = True8663        text += part.text8664    global _response_text_non_text_warning_logged8665    if non_text_parts and not _response_text_non_text_warning_logged:8666      logger.warning(8667          'Warning: there are non-text parts in the response:'8668          f' {non_text_parts}, returning concatenated text result'8669          ' from text parts. Check the full candidates.content.parts accessor'8670          ' to get the full model response.'8671      )8672      _response_text_non_text_warning_logged = True8673    # part.text == '' is different from part.text is None8674    return text if any_text_part_text else None86758676  @property8677  def parts(self) -> Optional[list[Part]]:8678    """Returns the content-parts in the response.86798680    If there are multiple candidates, returns the parts from only the first one.8681    """8682    if (8683        not self.candidates8684        or self.candidates[0].content is None8685        or self.candidates[0].content.parts is None8686    ):8687      return None8688    global _response_parts_warning_logged8689    if len(self.candidates) > 1 and not _response_parts_warning_logged:8690      logger.warning(8691          'Warning: there are multiple candidates in the response, returning'8692          ' parts from the first one.'8693      )8694      _response_parts_warning_logged = True86958696    return self.candidates[0].content.parts86978698  @property8699  def text(self) -> Optional[str]:8700    """Returns the concatenation of all text parts in the response.87018702    If there are multiple candidates, returns the text from only the first one.8703    If there are non-text parts in the response, this returns only the text8704    parts.8705    """8706    return self._get_text()87078708  @property8709  def function_calls(self) -> Optional[list[FunctionCall]]:8710    """Returns the list of function calls in the response.87118712    If there are multiple candidates, this returns the function calls from only8713    the8714    first one.8715    """8716    if (8717        not self.candidates8718        or not self.candidates[0].content8719        or not self.candidates[0].content.parts8720    ):8721      return None8722    global _response_function_calls_warning_logged8723    if len(self.candidates) > 1 and not _response_function_calls_warning_logged:8724      logger.warning(8725          'Warning: there are multiple candidates in the response, returning'8726          ' function calls from the first one.'8727      )8728      _response_function_calls_warning_logged = True8729    function_calls = [8730        part.function_call8731        for part in self.candidates[0].content.parts8732        if part.function_call is not None8733    ]87348735    return function_calls if function_calls else None87368737  @property8738  def executable_code(self) -> Optional[str]:8739    """Returns the executable code in the response.87408741    If there are multiple candidates, this returns the executable code from only8742    the8743    first one.8744    """8745    if (8746        not self.candidates8747        or not self.candidates[0].content8748        or not self.candidates[0].content.parts8749    ):8750      return None8751    global _response_executable_code_warning_logged8752    if (8753        len(self.candidates) > 18754        and not _response_executable_code_warning_logged8755    ):8756      logging.warning(8757          'Warning: there are multiple candidates in the response, returning'8758          ' executable code from the first one.'8759      )8760      _response_executable_code_warning_logged = True8761    for part in self.candidates[0].content.parts:8762      if part.executable_code is not None:8763        return part.executable_code.code8764    return None87658766  @property8767  def code_execution_result(self) -> Optional[str]:8768    """Returns the code execution result in the response.87698770    If there are multiple candidates, this returns the code execution result8771    from only the8772    first one.8773    """8774    if (8775        not self.candidates8776        or not self.candidates[0].content8777        or not self.candidates[0].content.parts8778    ):8779      return None8780    global _response_code_execution_warning_logged8781    if len(self.candidates) > 1 and not _response_code_execution_warning_logged:8782      logging.warning(8783          'Warning: there are multiple candidates in the response, returning'8784          ' code execution result from the first one.'8785      )8786      _response_code_execution_warning_logged = True8787    for part in self.candidates[0].content.parts:8788      if part.code_execution_result is not None:8789        return part.code_execution_result.output8790    return None87918792  @classmethod8793  def _from_response(8794      cls: typing.Type[T],8795      *,8796      response: dict[str, object],8797      kwargs: dict[str, object],8798  ) -> T:8799    result = super()._from_response(response=response, kwargs=kwargs)88008801    # Handles response schema.8802    response_schema = _common.get_value_by_path(8803        kwargs, ['config', 'response_schema']8804    )8805    # Handles response_json_schema. Backend will throw error if both8806    # response_schema and response_json_schema are set.8807    if response_schema is None:8808      response_schema = _common.get_value_by_path(8809          kwargs, ['config', 'response_json_schema']8810      )8811    if (8812        inspect.isclass(response_schema)8813        and not (8814            isinstance(response_schema, builtin_types.GenericAlias)8815        )  # Needed for Python 3.108816        and issubclass(response_schema, pydantic.BaseModel)8817    ):8818      # Pydantic schema.8819      try:8820        result_text = result._get_text()8821        if result_text is not None:8822          result.parsed = response_schema.model_validate_json(result_text)8823      # may not be a valid json per stream response8824      except pydantic.ValidationError:8825        pass8826      except json.decoder.JSONDecodeError:8827        pass8828    elif (8829        isinstance(response_schema, EnumMeta) and result._get_text() is not None8830    ):8831      # Enum with "application/json" returns response in double quotes.8832      result_text = result._get_text()8833      if result_text is None:8834        raise ValueError('Response is empty.')8835      enum_value = result_text.replace('"', '')8836      try:8837        result.parsed = response_schema(enum_value)8838        if (8839            hasattr(response_schema, '__name__')8840            and response_schema.__name__ == 'PlaceholderLiteralEnum'8841        ):8842          result.parsed = str(response_schema(enum_value).name)  # type: ignore8843      except ValueError:8844        pass8845    elif isinstance(response_schema, builtin_types.GenericAlias) or isinstance(8846        response_schema, type8847    ):88488849      class Placeholder(pydantic.BaseModel):8850        placeholder: response_schema  # type: ignore[valid-type]88518852      try:8853        result_text = result._get_text()8854        if result_text is not None:8855          parsed = {'placeholder': json.loads(result_text)}8856          placeholder = Placeholder.model_validate(parsed)8857          result.parsed = placeholder.placeholder8858      except json.decoder.JSONDecodeError:8859        pass8860      except pydantic.ValidationError:8861        pass88628863    elif isinstance(response_schema, dict) or isinstance(8864        response_schema, Schema8865    ):8866      # With just the Schema, we don't know what pydantic model the user would8867      # want the result converted to. So just return json.8868      # JSON schema.8869      try:8870        result_text = result._get_text()8871        if result_text is not None:8872          result.parsed = json.loads(result_text)8873      # may not be a valid json per stream response8874      except json.decoder.JSONDecodeError:8875        pass8876    elif typing.get_origin(response_schema) in _UNION_TYPES:8877      # Union schema.8878      union_types = typing.get_args(response_schema)8879      for union_type in union_types:8880        if issubclass(union_type, pydantic.BaseModel):8881          try:8882            result_text = result._get_text()8883            if result_text is not None:88848885              class Placeholder(pydantic.BaseModel):  # type: ignore[no-redef]8886                placeholder: response_schema  # type: ignore[valid-type]88878888              parsed = {'placeholder': json.loads(result_text)}8889              placeholder = Placeholder.model_validate(parsed)8890              result.parsed = placeholder.placeholder8891          except json.decoder.JSONDecodeError:8892            pass8893          except pydantic.ValidationError:8894            pass8895        else:8896          try:8897            result_text = result._get_text()8898            if result_text is not None:8899              result.parsed = json.loads(result_text)8900          # may not be a valid json per stream response8901          except json.decoder.JSONDecodeError:8902            pass89038904    return result890589068907class GenerateContentResponseDict(TypedDict, total=False):8908  """Response message for PredictionService.GenerateContent."""89098910  sdk_http_response: Optional[HttpResponseDict]8911  """Used to retain the full HTTP response."""89128913  candidates: Optional[list[CandidateDict]]8914  """Response variations returned by the model.8915      """89168917  create_time: Optional[datetime.datetime]8918  """Timestamp when the request is made to the server.8919      """89208921  model_version: Optional[str]8922  """Output only. The model version used to generate the response."""89238924  prompt_feedback: Optional[GenerateContentResponsePromptFeedbackDict]8925  """Output only. Content filter results for a prompt sent in the request. Note: Sent only in the first stream chunk. Only happens when no candidates were generated due to content violations."""89268927  response_id: Optional[str]8928  """Output only. response_id is used to identify each response. It is the encoding of the event_id."""89298930  usage_metadata: Optional[GenerateContentResponseUsageMetadataDict]8931  """Usage metadata about the response(s)."""89328933  model_status: Optional[ModelStatusDict]8934  """Output only. The current model status of this model. This field is not supported in Vertex AI."""893589368937GenerateContentResponseOrDict = Union[8938    GenerateContentResponse, GenerateContentResponseDict8939]894089418942class EmbedContentConfig(_common.BaseModel):8943  """Optional parameters for the embed_content method."""89448945  task_type: Optional[str] = Field(8946      default=None,8947      description="""Type of task for which the embedding will be used.8948      """,8949  )8950  title: Optional[str] = Field(8951      default=None,8952      description="""Title for the text. Only applicable when TaskType is8953      `RETRIEVAL_DOCUMENT`.8954      """,8955  )8956  output_dimensionality: Optional[int] = Field(8957      default=None,8958      description="""Reduced dimension for the output embedding. If set,8959      excessive values in the output embedding are truncated from the end.8960      Supported by newer models since 2024 only. You cannot set this value if8961      using the earlier model (`models/embedding-001`).8962      """,8963  )8964  mime_type: Optional[str] = Field(8965      default=None,8966      description="""Gemini Enterprise Agent Platform only. The MIME type of the input.8967      """,8968  )8969  auto_truncate: Optional[bool] = Field(8970      default=None,8971      description="""Gemini Enterprise Agent Platform only. Whether to silently truncate inputs longer than8972      the max sequence length. If this option is set to false, oversized inputs8973      will lead to an INVALID_ARGUMENT error, similar to other text APIs.8974      """,8975  )8976  document_ocr: Optional[bool] = Field(8977      default=None,8978      description="""Gemini Enterprise Agent Platform only. Whether to enable OCR for document content.8979      Only applicable to Gemini Embedding 2 models.8980      """,8981  )8982  audio_track_extraction: Optional[bool] = Field(8983      default=None,8984      description="""Gemini Enterprise Agent Platform only. Whether to extract audio from video content.8985      Only applicable to Gemini Embedding 2 models.8986      """,8987  )8988  http_options: Optional[HttpOptions] = Field(8989      default=None, description="""Used to override HTTP request options."""8990  )899189928993class EmbedContentConfigDict(TypedDict, total=False):8994  """Optional parameters for the embed_content method."""89958996  task_type: Optional[str]8997  """Type of task for which the embedding will be used.8998      """89999000  title: Optional[str]9001  """Title for the text. Only applicable when TaskType is9002      `RETRIEVAL_DOCUMENT`.9003      """90049005  output_dimensionality: Optional[int]9006  """Reduced dimension for the output embedding. If set,9007      excessive values in the output embedding are truncated from the end.9008      Supported by newer models since 2024 only. You cannot set this value if9009      using the earlier model (`models/embedding-001`).9010      """90119012  mime_type: Optional[str]9013  """Gemini Enterprise Agent Platform only. The MIME type of the input.9014      """90159016  auto_truncate: Optional[bool]9017  """Gemini Enterprise Agent Platform only. Whether to silently truncate inputs longer than9018      the max sequence length. If this option is set to false, oversized inputs9019      will lead to an INVALID_ARGUMENT error, similar to other text APIs.9020      """90219022  document_ocr: Optional[bool]9023  """Gemini Enterprise Agent Platform only. Whether to enable OCR for document content.9024      Only applicable to Gemini Embedding 2 models.9025      """90269027  audio_track_extraction: Optional[bool]9028  """Gemini Enterprise Agent Platform only. Whether to extract audio from video content.9029      Only applicable to Gemini Embedding 2 models.9030      """90319032  http_options: Optional[HttpOptionsDict]9033  """Used to override HTTP request options."""903490359036EmbedContentConfigOrDict = Union[EmbedContentConfig, EmbedContentConfigDict]903790389039class _EmbedContentParametersPrivate(_common.BaseModel):9040  """Parameters for the _embed_content method."""90419042  model: Optional[str] = Field(9043      default=None,9044      description="""ID of the model to use. For a list of models, see `Google models9045    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",9046  )9047  contents: Optional[ContentListUnion] = Field(9048      default=None,9049      description="""The content to embed. Only the `parts.text` fields will be counted.9050      """,9051  )9052  content: Optional[ContentUnion] = Field(9053      default=None,9054      description="""The single content to embed. Only the `parts.text` fields will be counted.9055      """,9056  )9057  embedding_api_type: Optional[EmbeddingApiType] = Field(9058      default=None,9059      description="""The Gemini Enterprise Agent Platform embedding API to use.9060      """,9061  )9062  config: Optional[EmbedContentConfig] = Field(9063      default=None,9064      description="""Configuration that contains optional parameters.9065      """,9066  )906790689069class _EmbedContentParametersPrivateDict(TypedDict, total=False):9070  """Parameters for the _embed_content method."""90719072  model: Optional[str]9073  """ID of the model to use. For a list of models, see `Google models9074    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""90759076  contents: Optional[ContentListUnionDict]9077  """The content to embed. Only the `parts.text` fields will be counted.9078      """90799080  content: Optional[ContentUnionDict]9081  """The single content to embed. Only the `parts.text` fields will be counted.9082      """90839084  embedding_api_type: Optional[EmbeddingApiType]9085  """The Gemini Enterprise Agent Platform embedding API to use.9086      """90879088  config: Optional[EmbedContentConfigDict]9089  """Configuration that contains optional parameters.9090      """909190929093_EmbedContentParametersPrivateOrDict = Union[9094    _EmbedContentParametersPrivate, _EmbedContentParametersPrivateDict9095]909690979098class ContentEmbeddingStatistics(_common.BaseModel):9099  """Statistics of the input text associated with the result of content embedding."""91009101  truncated: Optional[bool] = Field(9102      default=None,9103      description="""Gemini Enterprise Agent Platform only. If the input text was truncated due to having9104      a length longer than the allowed maximum input.9105      """,9106  )9107  token_count: Optional[float] = Field(9108      default=None,9109      description="""Gemini Enterprise Agent Platform only. Number of tokens of the input text.9110      """,9111  )9112  tokens_details: Optional[list[ModalityTokenCount]] = Field(9113      default=None,9114      description="""Gemini Enterprise Agent Platform only. List of modalities and their token count for the input content.9115      """,9116  )911791189119class ContentEmbeddingStatisticsDict(TypedDict, total=False):9120  """Statistics of the input text associated with the result of content embedding."""91219122  truncated: Optional[bool]9123  """Gemini Enterprise Agent Platform only. If the input text was truncated due to having9124      a length longer than the allowed maximum input.9125      """91269127  token_count: Optional[float]9128  """Gemini Enterprise Agent Platform only. Number of tokens of the input text.9129      """91309131  tokens_details: Optional[list[ModalityTokenCountDict]]9132  """Gemini Enterprise Agent Platform only. List of modalities and their token count for the input content.9133      """913491359136ContentEmbeddingStatisticsOrDict = Union[9137    ContentEmbeddingStatistics, ContentEmbeddingStatisticsDict9138]913991409141class ContentEmbedding(_common.BaseModel):9142  """The embedding generated from an input content."""91439144  values: Optional[list[float]] = Field(9145      default=None,9146      description="""A list of floats representing an embedding.9147      """,9148  )9149  statistics: Optional[ContentEmbeddingStatistics] = Field(9150      default=None,9151      description="""Gemini Enterprise Agent Platform only. Statistics of the input text associated with this9152      embedding.9153      """,9154  )915591569157class ContentEmbeddingDict(TypedDict, total=False):9158  """The embedding generated from an input content."""91599160  values: Optional[list[float]]9161  """A list of floats representing an embedding.9162      """91639164  statistics: Optional[ContentEmbeddingStatisticsDict]9165  """Gemini Enterprise Agent Platform only. Statistics of the input text associated with this9166      embedding.9167      """916891699170ContentEmbeddingOrDict = Union[ContentEmbedding, ContentEmbeddingDict]917191729173class EmbedContentMetadata(_common.BaseModel):9174  """Request-level metadata for the Gemini Enterprise Agent Platform Embed Content API."""91759176  billable_character_count: Optional[int] = Field(9177      default=None,9178      description="""Gemini Enterprise Agent Platform only. The total number of billable characters included9179      in the request.9180      """,9181  )918291839184class EmbedContentMetadataDict(TypedDict, total=False):9185  """Request-level metadata for the Gemini Enterprise Agent Platform Embed Content API."""91869187  billable_character_count: Optional[int]9188  """Gemini Enterprise Agent Platform only. The total number of billable characters included9189      in the request.9190      """919191929193EmbedContentMetadataOrDict = Union[9194    EmbedContentMetadata, EmbedContentMetadataDict9195]919691979198class EmbedContentResponse(_common.BaseModel):9199  """Response for the embed_content method."""92009201  sdk_http_response: Optional[HttpResponse] = Field(9202      default=None, description="""Used to retain the full HTTP response."""9203  )9204  embeddings: Optional[list[ContentEmbedding]] = Field(9205      default=None,9206      description="""The embeddings for each request, in the same order as provided in9207      the batch request.9208      """,9209  )9210  metadata: Optional[EmbedContentMetadata] = Field(9211      default=None,9212      description="""Gemini Enterprise Agent Platform only. Metadata about the request.9213      """,9214  )921592169217class EmbedContentResponseDict(TypedDict, total=False):9218  """Response for the embed_content method."""92199220  sdk_http_response: Optional[HttpResponseDict]9221  """Used to retain the full HTTP response."""92229223  embeddings: Optional[list[ContentEmbeddingDict]]9224  """The embeddings for each request, in the same order as provided in9225      the batch request.9226      """92279228  metadata: Optional[EmbedContentMetadataDict]9229  """Gemini Enterprise Agent Platform only. Metadata about the request.9230      """923192329233EmbedContentResponseOrDict = Union[9234    EmbedContentResponse, EmbedContentResponseDict9235]923692379238class GenerateImagesConfig(_common.BaseModel):9239  """The config for generating an images."""92409241  http_options: Optional[HttpOptions] = Field(9242      default=None, description="""Used to override HTTP request options."""9243  )9244  output_gcs_uri: Optional[str] = Field(9245      default=None,9246      description="""Cloud Storage URI used to store the generated images.""",9247  )9248  negative_prompt: Optional[str] = Field(9249      default=None,9250      description="""Description of what to discourage in the generated images.""",9251  )9252  number_of_images: Optional[int] = Field(9253      default=None, description="""Number of images to generate."""9254  )9255  aspect_ratio: Optional[str] = Field(9256      default=None,9257      description="""Aspect ratio of the generated images. Supported values are9258      "1:1", "3:4", "4:3", "9:16", and "16:9".""",9259  )9260  guidance_scale: Optional[float] = Field(9261      default=None,9262      description="""Controls how much the model adheres to the text prompt. Large9263      values increase output and prompt alignment, but may compromise image9264      quality.""",9265  )9266  seed: Optional[int] = Field(9267      default=None,9268      description="""Random seed for image generation. This is not available when9269      ``add_watermark`` is set to true.""",9270  )9271  safety_filter_level: Optional[SafetyFilterLevel] = Field(9272      default=None, description="""Filter level for safety filtering."""9273  )9274  person_generation: Optional[PersonGeneration] = Field(9275      default=None, description="""Allows generation of people by the model."""9276  )9277  include_safety_attributes: Optional[bool] = Field(9278      default=None,9279      description="""Whether to report the safety scores of each generated image and9280      the positive prompt in the response.""",9281  )9282  include_rai_reason: Optional[bool] = Field(9283      default=None,9284      description="""Whether to include the Responsible AI filter reason if the image9285      is filtered out of the response.""",9286  )9287  language: Optional[ImagePromptLanguage] = Field(9288      default=None, description="""Language of the text in the prompt."""9289  )9290  output_mime_type: Optional[str] = Field(9291      default=None, description="""MIME type of the generated image."""9292  )9293  output_compression_quality: Optional[int] = Field(9294      default=None,9295      description="""Compression quality of the generated image (for ``image/jpeg``9296      only).""",9297  )9298  add_watermark: Optional[bool] = Field(9299      default=None,9300      description="""Whether to add a watermark to the generated images.""",9301  )9302  labels: Optional[dict[str, str]] = Field(9303      default=None,9304      description="""User specified labels to track billing usage.""",9305  )9306  image_size: Optional[str] = Field(9307      default=None,9308      description="""The size of the largest dimension of the generated image.9309      Supported sizes are 1K and 2K (not supported for Imagen 3 models).""",9310  )9311  enhance_prompt: Optional[bool] = Field(9312      default=None, description="""Whether to use the prompt rewriting logic."""9313  )931493159316class GenerateImagesConfigDict(TypedDict, total=False):9317  """The config for generating an images."""93189319  http_options: Optional[HttpOptionsDict]9320  """Used to override HTTP request options."""93219322  output_gcs_uri: Optional[str]9323  """Cloud Storage URI used to store the generated images."""93249325  negative_prompt: Optional[str]9326  """Description of what to discourage in the generated images."""93279328  number_of_images: Optional[int]9329  """Number of images to generate."""93309331  aspect_ratio: Optional[str]9332  """Aspect ratio of the generated images. Supported values are9333      "1:1", "3:4", "4:3", "9:16", and "16:9"."""93349335  guidance_scale: Optional[float]9336  """Controls how much the model adheres to the text prompt. Large9337      values increase output and prompt alignment, but may compromise image9338      quality."""93399340  seed: Optional[int]9341  """Random seed for image generation. This is not available when9342      ``add_watermark`` is set to true."""93439344  safety_filter_level: Optional[SafetyFilterLevel]9345  """Filter level for safety filtering."""93469347  person_generation: Optional[PersonGeneration]9348  """Allows generation of people by the model."""93499350  include_safety_attributes: Optional[bool]9351  """Whether to report the safety scores of each generated image and9352      the positive prompt in the response."""93539354  include_rai_reason: Optional[bool]9355  """Whether to include the Responsible AI filter reason if the image9356      is filtered out of the response."""93579358  language: Optional[ImagePromptLanguage]9359  """Language of the text in the prompt."""93609361  output_mime_type: Optional[str]9362  """MIME type of the generated image."""93639364  output_compression_quality: Optional[int]9365  """Compression quality of the generated image (for ``image/jpeg``9366      only)."""93679368  add_watermark: Optional[bool]9369  """Whether to add a watermark to the generated images."""93709371  labels: Optional[dict[str, str]]9372  """User specified labels to track billing usage."""93739374  image_size: Optional[str]9375  """The size of the largest dimension of the generated image.9376      Supported sizes are 1K and 2K (not supported for Imagen 3 models)."""93779378  enhance_prompt: Optional[bool]9379  """Whether to use the prompt rewriting logic."""938093819382GenerateImagesConfigOrDict = Union[9383    GenerateImagesConfig, GenerateImagesConfigDict9384]938593869387class _GenerateImagesParameters(_common.BaseModel):9388  """The parameters for generating images."""93899390  model: Optional[str] = Field(9391      default=None,9392      description="""ID of the model to use. For a list of models, see `Google models9393    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",9394  )9395  prompt: Optional[str] = Field(9396      default=None,9397      description="""Text prompt that typically describes the images to output.9398      """,9399  )9400  config: Optional[GenerateImagesConfig] = Field(9401      default=None,9402      description="""Configuration for generating images.9403      """,9404  )940594069407class _GenerateImagesParametersDict(TypedDict, total=False):9408  """The parameters for generating images."""94099410  model: Optional[str]9411  """ID of the model to use. For a list of models, see `Google models9412    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""94139414  prompt: Optional[str]9415  """Text prompt that typically describes the images to output.9416      """94179418  config: Optional[GenerateImagesConfigDict]9419  """Configuration for generating images.9420      """942194229423_GenerateImagesParametersOrDict = Union[9424    _GenerateImagesParameters, _GenerateImagesParametersDict9425]942694279428class Image(_common.BaseModel):9429  """An image."""94309431  gcs_uri: Optional[str] = Field(9432      default=None,9433      description="""The Cloud Storage URI of the image. ``Image`` can contain a value9434      for this field or the ``image_bytes`` field but not both.""",9435  )9436  image_bytes: Optional[bytes] = Field(9437      default=None,9438      description="""The image bytes data. ``Image`` can contain a value for this field9439      or the ``gcs_uri`` field but not both.""",9440  )9441  mime_type: Optional[str] = Field(9442      default=None, description="""The MIME type of the image."""9443  )94449445  _loaded_image: Optional['PIL_Image'] = None94469447  """Image."""94489449  @classmethod9450  def from_file(9451      cls, *, location: str, mime_type: Optional[str] = None9452  ) -> 'Image':9453    """Lazy-loads an image from a local file or Google Cloud Storage.94549455    Args:9456        location: The local path or Google Cloud Storage URI from which to load9457          the image.9458        mime_type: The MIME type of the image. If not provided, the MIME type9459          will be automatically determined.94609461    Returns:9462        A loaded image as an `Image` object.9463    """9464    import urllib9465    import pathlib9466    import mimetypes94679468    parsed_url = urllib.parse.urlparse(location)9469    if (9470        parsed_url.scheme == 'https'9471        and parsed_url.netloc == 'storage.googleapis.com'9472    ):9473      parsed_url = parsed_url._replace(9474          scheme='gs',9475          netloc='',9476          path=f'/{urllib.parse.unquote(parsed_url.path)}',9477      )9478      location = urllib.parse.urlunparse(parsed_url)94799480    if parsed_url.scheme == 'gs':9481      return cls(gcs_uri=location)94829483    # Load image from local path9484    image_bytes = pathlib.Path(location).read_bytes()94859486    if not mime_type:9487      mime_type, _ = mimetypes.guess_type(location)9488    image = cls(image_bytes=image_bytes, mime_type=mime_type)9489    return image94909491  def show(self) -> None:9492    """Shows the image.94939494    This method only works in a notebook environment.9495    """9496    in_notebook = 'ipykernel' in sys.modules9497    if in_notebook:9498      try:9499        from IPython import display as IPython_display9500      except ImportError:9501        IPython_display = None95029503      if IPython_display:9504        IPython_display.display(self._pil_image)9505    else:9506      img = self._pil_image9507      if img is not None:9508        img.show()95099510  @property9511  def _pil_image(self) -> Optional['PIL_Image']:9512    PIL_Image: Optional[builtin_types.ModuleType]9513    try:9514      from PIL import Image as PIL_Image9515    except ImportError:9516      PIL_Image = None9517    import io95189519    if self._loaded_image is None:9520      if not PIL_Image:9521        raise RuntimeError(9522            'The PIL module is not available. Please install the Pillow'9523            ' package. `pip install pillow`'9524        )9525      if self.image_bytes is None:9526        raise ValueError('The image bytes are not set.')9527      self._loaded_image = PIL_Image.open(io.BytesIO(self.image_bytes))9528    return self._loaded_image95299530  def save(self, location: str) -> None:9531    """Saves the image to a file.95329533    Args:9534        location: Local path where to save the image.9535    """9536    import pathlib95379538    if self.image_bytes is None:9539      raise ValueError('The image bytes are not set.')9540    pathlib.Path(location).write_bytes(self.image_bytes)954195429543JOB_STATES_SUCCEEDED_VERTEX = [9544    'JOB_STATE_SUCCEEDED',9545]95469547JOB_STATES_SUCCEEDED_MLDEV = [9548    'ACTIVE',9549]95509551JOB_STATES_SUCCEEDED = JOB_STATES_SUCCEEDED_VERTEX + JOB_STATES_SUCCEEDED_MLDEV955295539554JOB_STATES_ENDED_VERTEX = [9555    'JOB_STATE_SUCCEEDED',9556    'JOB_STATE_FAILED',9557    'JOB_STATE_CANCELLED',9558    'JOB_STATE_EXPIRED',9559]95609561JOB_STATES_ENDED_MLDEV = [9562    'ACTIVE',9563    'FAILED',9564]95659566JOB_STATES_ENDED = JOB_STATES_ENDED_VERTEX + JOB_STATES_ENDED_MLDEV956795689569class ImageDict(TypedDict, total=False):9570  """An image."""95719572  gcs_uri: Optional[str]9573  """The Cloud Storage URI of the image. ``Image`` can contain a value9574      for this field or the ``image_bytes`` field but not both."""95759576  image_bytes: Optional[bytes]9577  """The image bytes data. ``Image`` can contain a value for this field9578      or the ``gcs_uri`` field but not both."""95799580  mime_type: Optional[str]9581  """The MIME type of the image."""958295839584ImageOrDict = Union[Image, ImageDict]958595869587class SafetyAttributes(_common.BaseModel):9588  """Safety attributes of a GeneratedImage or the user-provided prompt."""95899590  categories: Optional[list[str]] = Field(9591      default=None, description="""List of RAI categories."""9592  )9593  scores: Optional[list[float]] = Field(9594      default=None, description="""List of scores of each categories."""9595  )9596  content_type: Optional[str] = Field(9597      default=None, description="""Internal use only."""9598  )959996009601class SafetyAttributesDict(TypedDict, total=False):9602  """Safety attributes of a GeneratedImage or the user-provided prompt."""96039604  categories: Optional[list[str]]9605  """List of RAI categories."""96069607  scores: Optional[list[float]]9608  """List of scores of each categories."""96099610  content_type: Optional[str]9611  """Internal use only."""961296139614SafetyAttributesOrDict = Union[SafetyAttributes, SafetyAttributesDict]961596169617class GeneratedImage(_common.BaseModel):9618  """An output image."""96199620  image: Optional[Image] = Field(9621      default=None, description="""The output image data."""9622  )9623  rai_filtered_reason: Optional[str] = Field(9624      default=None,9625      description="""Responsible AI filter reason if the image is filtered out of the9626      response.""",9627  )9628  safety_attributes: Optional[SafetyAttributes] = Field(9629      default=None,9630      description="""Safety attributes of the image. Lists of RAI categories and their9631      scores of each content.""",9632  )9633  enhanced_prompt: Optional[str] = Field(9634      default=None,9635      description="""The rewritten prompt used for the image generation if the prompt9636      enhancer is enabled.""",9637  )963896399640class GeneratedImageDict(TypedDict, total=False):9641  """An output image."""96429643  image: Optional[ImageDict]9644  """The output image data."""96459646  rai_filtered_reason: Optional[str]9647  """Responsible AI filter reason if the image is filtered out of the9648      response."""96499650  safety_attributes: Optional[SafetyAttributesDict]9651  """Safety attributes of the image. Lists of RAI categories and their9652      scores of each content."""96539654  enhanced_prompt: Optional[str]9655  """The rewritten prompt used for the image generation if the prompt9656      enhancer is enabled."""965796589659GeneratedImageOrDict = Union[GeneratedImage, GeneratedImageDict]966096619662class GenerateImagesResponse(_common.BaseModel):9663  """The output images response."""96649665  sdk_http_response: Optional[HttpResponse] = Field(9666      default=None, description="""Used to retain the full HTTP response."""9667  )9668  generated_images: Optional[list[GeneratedImage]] = Field(9669      default=None, description="""List of generated images."""9670  )9671  positive_prompt_safety_attributes: Optional[SafetyAttributes] = Field(9672      default=None,9673      description="""Safety attributes of the positive prompt. Only populated if9674      ``include_safety_attributes`` is set to True.""",9675  )96769677  @property9678  def images(self) -> list[Optional[Image]]:9679    """Returns the list of all generated images.96809681    A convenience method for accessing the images. Some attributes of the9682    generated image are only available through the ``GeneratedImage`` object.9683    """9684    if not self.generated_images:9685      return []9686    return [generated_image.image for generated_image in self.generated_images]968796889689class GenerateImagesResponseDict(TypedDict, total=False):9690  """The output images response."""96919692  sdk_http_response: Optional[HttpResponseDict]9693  """Used to retain the full HTTP response."""96949695  generated_images: Optional[list[GeneratedImageDict]]9696  """List of generated images."""96979698  positive_prompt_safety_attributes: Optional[SafetyAttributesDict]9699  """Safety attributes of the positive prompt. Only populated if9700      ``include_safety_attributes`` is set to True."""970197029703GenerateImagesResponseOrDict = Union[9704    GenerateImagesResponse, GenerateImagesResponseDict9705]970697079708class MaskReferenceConfig(_common.BaseModel):9709  """Configuration for a Mask reference image."""97109711  mask_mode: Optional[MaskReferenceMode] = Field(9712      default=None,9713      description="""Prompts the model to generate a mask instead of you needing to9714      provide one (unless MASK_MODE_USER_PROVIDED is used).""",9715  )9716  segmentation_classes: Optional[list[int]] = Field(9717      default=None,9718      description="""A list of up to 5 class ids to use for semantic segmentation.9719      Automatically creates an image mask based on specific objects.""",9720  )9721  mask_dilation: Optional[float] = Field(9722      default=None,9723      description="""Dilation percentage of the mask provided.9724      Float between 0 and 1.""",9725  )972697279728class MaskReferenceConfigDict(TypedDict, total=False):9729  """Configuration for a Mask reference image."""97309731  mask_mode: Optional[MaskReferenceMode]9732  """Prompts the model to generate a mask instead of you needing to9733      provide one (unless MASK_MODE_USER_PROVIDED is used)."""97349735  segmentation_classes: Optional[list[int]]9736  """A list of up to 5 class ids to use for semantic segmentation.9737      Automatically creates an image mask based on specific objects."""97389739  mask_dilation: Optional[float]9740  """Dilation percentage of the mask provided.9741      Float between 0 and 1."""974297439744MaskReferenceConfigOrDict = Union[MaskReferenceConfig, MaskReferenceConfigDict]974597469747class ControlReferenceConfig(_common.BaseModel):9748  """Configuration for a Control reference image."""97499750  control_type: Optional[ControlReferenceType] = Field(9751      default=None,9752      description="""The type of control reference image to use.""",9753  )9754  enable_control_image_computation: Optional[bool] = Field(9755      default=None,9756      description="""Defaults to False. When set to True, the control image will be9757      computed by the model based on the control type. When set to False,9758      the control image must be provided by the user.""",9759  )976097619762class ControlReferenceConfigDict(TypedDict, total=False):9763  """Configuration for a Control reference image."""97649765  control_type: Optional[ControlReferenceType]9766  """The type of control reference image to use."""97679768  enable_control_image_computation: Optional[bool]9769  """Defaults to False. When set to True, the control image will be9770      computed by the model based on the control type. When set to False,9771      the control image must be provided by the user."""977297739774ControlReferenceConfigOrDict = Union[9775    ControlReferenceConfig, ControlReferenceConfigDict9776]977797789779class StyleReferenceConfig(_common.BaseModel):9780  """Configuration for a Style reference image."""97819782  style_description: Optional[str] = Field(9783      default=None,9784      description="""A text description of the style to use for the generated image.""",9785  )978697879788class StyleReferenceConfigDict(TypedDict, total=False):9789  """Configuration for a Style reference image."""97909791  style_description: Optional[str]9792  """A text description of the style to use for the generated image."""979397949795StyleReferenceConfigOrDict = Union[9796    StyleReferenceConfig, StyleReferenceConfigDict9797]979897999800class SubjectReferenceConfig(_common.BaseModel):9801  """Configuration for a Subject reference image."""98029803  subject_type: Optional[SubjectReferenceType] = Field(9804      default=None,9805      description="""The subject type of a subject reference image.""",9806  )9807  subject_description: Optional[str] = Field(9808      default=None, description="""Subject description for the image."""9809  )981098119812class SubjectReferenceConfigDict(TypedDict, total=False):9813  """Configuration for a Subject reference image."""98149815  subject_type: Optional[SubjectReferenceType]9816  """The subject type of a subject reference image."""98179818  subject_description: Optional[str]9819  """Subject description for the image."""982098219822SubjectReferenceConfigOrDict = Union[9823    SubjectReferenceConfig, SubjectReferenceConfigDict9824]982598269827class _ReferenceImageAPI(_common.BaseModel):9828  """Private class that represents a Reference image that is sent to API."""98299830  reference_image: Optional[Image] = Field(9831      default=None,9832      description="""The reference image for the editing operation.""",9833  )9834  reference_id: Optional[int] = Field(9835      default=None, description="""The id of the reference image."""9836  )9837  reference_type: Optional[str] = Field(9838      default=None,9839      description="""The type of the reference image. Only set by the SDK.""",9840  )9841  mask_image_config: Optional[MaskReferenceConfig] = Field(9842      default=None,9843      description="""Configuration for the mask reference image.""",9844  )9845  control_image_config: Optional[ControlReferenceConfig] = Field(9846      default=None,9847      description="""Configuration for the control reference image.""",9848  )9849  style_image_config: Optional[StyleReferenceConfig] = Field(9850      default=None,9851      description="""Configuration for the style reference image.""",9852  )9853  subject_image_config: Optional[SubjectReferenceConfig] = Field(9854      default=None,9855      description="""Configuration for the subject reference image.""",9856  )985798589859class _ReferenceImageAPIDict(TypedDict, total=False):9860  """Private class that represents a Reference image that is sent to API."""98619862  reference_image: Optional[ImageDict]9863  """The reference image for the editing operation."""98649865  reference_id: Optional[int]9866  """The id of the reference image."""98679868  reference_type: Optional[str]9869  """The type of the reference image. Only set by the SDK."""98709871  mask_image_config: Optional[MaskReferenceConfigDict]9872  """Configuration for the mask reference image."""98739874  control_image_config: Optional[ControlReferenceConfigDict]9875  """Configuration for the control reference image."""98769877  style_image_config: Optional[StyleReferenceConfigDict]9878  """Configuration for the style reference image."""98799880  subject_image_config: Optional[SubjectReferenceConfigDict]9881  """Configuration for the subject reference image."""988298839884_ReferenceImageAPIOrDict = Union[_ReferenceImageAPI, _ReferenceImageAPIDict]988598869887class EditImageConfig(_common.BaseModel):9888  """Configuration for editing an image."""98899890  http_options: Optional[HttpOptions] = Field(9891      default=None, description="""Used to override HTTP request options."""9892  )9893  output_gcs_uri: Optional[str] = Field(9894      default=None,9895      description="""Cloud Storage URI used to store the generated images.""",9896  )9897  negative_prompt: Optional[str] = Field(9898      default=None,9899      description="""Description of what to discourage in the generated images.""",9900  )9901  number_of_images: Optional[int] = Field(9902      default=None, description="""Number of images to generate."""9903  )9904  aspect_ratio: Optional[str] = Field(9905      default=None,9906      description="""Aspect ratio of the generated images. Supported values are9907      "1:1", "3:4", "4:3", "9:16", and "16:9".""",9908  )9909  guidance_scale: Optional[float] = Field(9910      default=None,9911      description="""Controls how much the model adheres to the text prompt. Large9912      values increase output and prompt alignment, but may compromise image9913      quality.""",9914  )9915  seed: Optional[int] = Field(9916      default=None,9917      description="""Random seed for image generation. This is not available when9918      ``add_watermark`` is set to true.""",9919  )9920  safety_filter_level: Optional[SafetyFilterLevel] = Field(9921      default=None, description="""Filter level for safety filtering."""9922  )9923  person_generation: Optional[PersonGeneration] = Field(9924      default=None, description="""Allows generation of people by the model."""9925  )9926  include_safety_attributes: Optional[bool] = Field(9927      default=None,9928      description="""Whether to report the safety scores of each generated image and9929      the positive prompt in the response.""",9930  )9931  include_rai_reason: Optional[bool] = Field(9932      default=None,9933      description="""Whether to include the Responsible AI filter reason if the image9934      is filtered out of the response.""",9935  )9936  language: Optional[ImagePromptLanguage] = Field(9937      default=None, description="""Language of the text in the prompt."""9938  )9939  output_mime_type: Optional[str] = Field(9940      default=None, description="""MIME type of the generated image."""9941  )9942  output_compression_quality: Optional[int] = Field(9943      default=None,9944      description="""Compression quality of the generated image (for ``image/jpeg``9945      only).""",9946  )9947  add_watermark: Optional[bool] = Field(9948      default=None,9949      description="""Whether to add a watermark to the generated images.""",9950  )9951  labels: Optional[dict[str, str]] = Field(9952      default=None,9953      description="""User specified labels to track billing usage.""",9954  )9955  edit_mode: Optional[EditMode] = Field(9956      default=None,9957      description="""Describes the editing mode for the request.""",9958  )9959  base_steps: Optional[int] = Field(9960      default=None,9961      description="""The number of sampling steps. A higher value has better image9962      quality, while a lower value has better latency.""",9963  )996499659966class EditImageConfigDict(TypedDict, total=False):9967  """Configuration for editing an image."""99689969  http_options: Optional[HttpOptionsDict]9970  """Used to override HTTP request options."""99719972  output_gcs_uri: Optional[str]9973  """Cloud Storage URI used to store the generated images."""99749975  negative_prompt: Optional[str]9976  """Description of what to discourage in the generated images."""99779978  number_of_images: Optional[int]9979  """Number of images to generate."""99809981  aspect_ratio: Optional[str]9982  """Aspect ratio of the generated images. Supported values are9983      "1:1", "3:4", "4:3", "9:16", and "16:9"."""99849985  guidance_scale: Optional[float]9986  """Controls how much the model adheres to the text prompt. Large9987      values increase output and prompt alignment, but may compromise image9988      quality."""99899990  seed: Optional[int]9991  """Random seed for image generation. This is not available when9992      ``add_watermark`` is set to true."""99939994  safety_filter_level: Optional[SafetyFilterLevel]9995  """Filter level for safety filtering."""99969997  person_generation: Optional[PersonGeneration]9998  """Allows generation of people by the model."""999910000  include_safety_attributes: Optional[bool]10001  """Whether to report the safety scores of each generated image and10002      the positive prompt in the response."""1000310004  include_rai_reason: Optional[bool]10005  """Whether to include the Responsible AI filter reason if the image10006      is filtered out of the response."""1000710008  language: Optional[ImagePromptLanguage]10009  """Language of the text in the prompt."""1001010011  output_mime_type: Optional[str]10012  """MIME type of the generated image."""1001310014  output_compression_quality: Optional[int]10015  """Compression quality of the generated image (for ``image/jpeg``10016      only)."""1001710018  add_watermark: Optional[bool]10019  """Whether to add a watermark to the generated images."""1002010021  labels: Optional[dict[str, str]]10022  """User specified labels to track billing usage."""1002310024  edit_mode: Optional[EditMode]10025  """Describes the editing mode for the request."""1002610027  base_steps: Optional[int]10028  """The number of sampling steps. A higher value has better image10029      quality, while a lower value has better latency."""100301003110032EditImageConfigOrDict = Union[EditImageConfig, EditImageConfigDict]100331003410035class _EditImageParameters(_common.BaseModel):10036  """Parameters for the request to edit an image."""1003710038  model: Optional[str] = Field(10039      default=None, description="""The model to use."""10040  )10041  prompt: Optional[str] = Field(10042      default=None,10043      description="""A text description of the edit to apply to the image.""",10044  )10045  reference_images: Optional[list[_ReferenceImageAPI]] = Field(10046      default=None, description="""The reference images for editing."""10047  )10048  config: Optional[EditImageConfig] = Field(10049      default=None, description="""Configuration for editing."""10050  )100511005210053class _EditImageParametersDict(TypedDict, total=False):10054  """Parameters for the request to edit an image."""1005510056  model: Optional[str]10057  """The model to use."""1005810059  prompt: Optional[str]10060  """A text description of the edit to apply to the image."""1006110062  reference_images: Optional[list[_ReferenceImageAPIDict]]10063  """The reference images for editing."""1006410065  config: Optional[EditImageConfigDict]10066  """Configuration for editing."""100671006810069_EditImageParametersOrDict = Union[10070    _EditImageParameters, _EditImageParametersDict10071]100721007310074class EditImageResponse(_common.BaseModel):10075  """Response for the request to edit an image."""1007610077  sdk_http_response: Optional[HttpResponse] = Field(10078      default=None, description="""Used to retain the full HTTP response."""10079  )10080  generated_images: Optional[list[GeneratedImage]] = Field(10081      default=None, description="""Generated images."""10082  )100831008410085class EditImageResponseDict(TypedDict, total=False):10086  """Response for the request to edit an image."""1008710088  sdk_http_response: Optional[HttpResponseDict]10089  """Used to retain the full HTTP response."""1009010091  generated_images: Optional[list[GeneratedImageDict]]10092  """Generated images."""100931009410095EditImageResponseOrDict = Union[EditImageResponse, EditImageResponseDict]100961009710098class _UpscaleImageAPIConfig(_common.BaseModel):10099  """Internal API config for UpscaleImage.1010010101  These fields require default values sent to the API which are not intended10102  to be modifiable or exposed to users in the SDK method.10103  """1010410105  http_options: Optional[HttpOptions] = Field(10106      default=None, description="""Used to override HTTP request options."""10107  )10108  output_gcs_uri: Optional[str] = Field(10109      default=None,10110      description="""Cloud Storage URI used to store the generated images.""",10111  )10112  safety_filter_level: Optional[SafetyFilterLevel] = Field(10113      default=None, description="""Filter level for safety filtering."""10114  )10115  person_generation: Optional[PersonGeneration] = Field(10116      default=None, description="""Allows generation of people by the model."""10117  )10118  include_rai_reason: Optional[bool] = Field(10119      default=None,10120      description="""Whether to include a reason for filtered-out images in the10121      response.""",10122  )10123  output_mime_type: Optional[str] = Field(10124      default=None,10125      description="""The image format that the output should be saved as.""",10126  )10127  output_compression_quality: Optional[int] = Field(10128      default=None,10129      description="""The level of compression. Only applicable if the10130      ``output_mime_type`` is ``image/jpeg``.""",10131  )10132  enhance_input_image: Optional[bool] = Field(10133      default=None,10134      description="""Whether to add an image enhancing step before upscaling.10135      It is expected to suppress the noise and JPEG compression artifacts10136      from the input image.""",10137  )10138  image_preservation_factor: Optional[float] = Field(10139      default=None,10140      description="""With a higher image preservation factor, the original image10141      pixels are more respected. With a lower image preservation factor, the10142      output image will have be more different from the input image, but10143      with finer details and less noise.""",10144  )10145  labels: Optional[dict[str, str]] = Field(10146      default=None,10147      description="""User specified labels to track billing usage.""",10148  )10149  number_of_images: Optional[int] = Field(default=None, description="""""")10150  mode: Optional[str] = Field(default=None, description="""""")101511015210153class _UpscaleImageAPIConfigDict(TypedDict, total=False):10154  """Internal API config for UpscaleImage.1015510156  These fields require default values sent to the API which are not intended10157  to be modifiable or exposed to users in the SDK method.10158  """1015910160  http_options: Optional[HttpOptionsDict]10161  """Used to override HTTP request options."""1016210163  output_gcs_uri: Optional[str]10164  """Cloud Storage URI used to store the generated images."""1016510166  safety_filter_level: Optional[SafetyFilterLevel]10167  """Filter level for safety filtering."""1016810169  person_generation: Optional[PersonGeneration]10170  """Allows generation of people by the model."""1017110172  include_rai_reason: Optional[bool]10173  """Whether to include a reason for filtered-out images in the10174      response."""1017510176  output_mime_type: Optional[str]10177  """The image format that the output should be saved as."""1017810179  output_compression_quality: Optional[int]10180  """The level of compression. Only applicable if the10181      ``output_mime_type`` is ``image/jpeg``."""1018210183  enhance_input_image: Optional[bool]10184  """Whether to add an image enhancing step before upscaling.10185      It is expected to suppress the noise and JPEG compression artifacts10186      from the input image."""1018710188  image_preservation_factor: Optional[float]10189  """With a higher image preservation factor, the original image10190      pixels are more respected. With a lower image preservation factor, the10191      output image will have be more different from the input image, but10192      with finer details and less noise."""1019310194  labels: Optional[dict[str, str]]10195  """User specified labels to track billing usage."""1019610197  number_of_images: Optional[int]10198  """"""1019910200  mode: Optional[str]10201  """"""102021020310204_UpscaleImageAPIConfigOrDict = Union[10205    _UpscaleImageAPIConfig, _UpscaleImageAPIConfigDict10206]102071020810209class _UpscaleImageAPIParameters(_common.BaseModel):10210  """API parameters for UpscaleImage."""1021110212  model: Optional[str] = Field(10213      default=None, description="""The model to use."""10214  )10215  image: Optional[Image] = Field(10216      default=None, description="""The input image to upscale."""10217  )10218  upscale_factor: Optional[str] = Field(10219      default=None,10220      description="""The factor to upscale the image (x2 or x4).""",10221  )10222  config: Optional[_UpscaleImageAPIConfig] = Field(10223      default=None, description="""Configuration for upscaling."""10224  )102251022610227class _UpscaleImageAPIParametersDict(TypedDict, total=False):10228  """API parameters for UpscaleImage."""1022910230  model: Optional[str]10231  """The model to use."""1023210233  image: Optional[ImageDict]10234  """The input image to upscale."""1023510236  upscale_factor: Optional[str]10237  """The factor to upscale the image (x2 or x4)."""1023810239  config: Optional[_UpscaleImageAPIConfigDict]10240  """Configuration for upscaling."""102411024210243_UpscaleImageAPIParametersOrDict = Union[10244    _UpscaleImageAPIParameters, _UpscaleImageAPIParametersDict10245]102461024710248class UpscaleImageResponse(_common.BaseModel):1024910250  sdk_http_response: Optional[HttpResponse] = Field(10251      default=None, description="""Used to retain the full HTTP response."""10252  )10253  generated_images: Optional[list[GeneratedImage]] = Field(10254      default=None, description="""Generated images."""10255  )102561025710258class UpscaleImageResponseDict(TypedDict, total=False):1025910260  sdk_http_response: Optional[HttpResponseDict]10261  """Used to retain the full HTTP response."""1026210263  generated_images: Optional[list[GeneratedImageDict]]10264  """Generated images."""102651026610267UpscaleImageResponseOrDict = Union[10268    UpscaleImageResponse, UpscaleImageResponseDict10269]102701027110272class ProductImage(_common.BaseModel):10273  """An image of the product."""1027410275  product_image: Optional[Image] = Field(10276      default=None,10277      description="""An image of the product to be recontextualized.""",10278  )102791028010281class ProductImageDict(TypedDict, total=False):10282  """An image of the product."""1028310284  product_image: Optional[ImageDict]10285  """An image of the product to be recontextualized."""102861028710288ProductImageOrDict = Union[ProductImage, ProductImageDict]102891029010291class RecontextImageSource(_common.BaseModel):10292  """A set of source input(s) for image recontextualization."""1029310294  prompt: Optional[str] = Field(10295      default=None,10296      description="""A text prompt for guiding the model during image10297      recontextualization. Not supported for Virtual Try-On.""",10298  )10299  person_image: Optional[Image] = Field(10300      default=None,10301      description="""Image of the person or subject who will be wearing the10302      product(s).""",10303  )10304  product_images: Optional[list[ProductImage]] = Field(10305      default=None, description="""A list of product images."""10306  )103071030810309class RecontextImageSourceDict(TypedDict, total=False):10310  """A set of source input(s) for image recontextualization."""1031110312  prompt: Optional[str]10313  """A text prompt for guiding the model during image10314      recontextualization. Not supported for Virtual Try-On."""1031510316  person_image: Optional[ImageDict]10317  """Image of the person or subject who will be wearing the10318      product(s)."""1031910320  product_images: Optional[list[ProductImageDict]]10321  """A list of product images."""103221032310324RecontextImageSourceOrDict = Union[10325    RecontextImageSource, RecontextImageSourceDict10326]103271032810329class RecontextImageConfig(_common.BaseModel):10330  """Configuration for recontextualizing an image."""1033110332  http_options: Optional[HttpOptions] = Field(10333      default=None, description="""Used to override HTTP request options."""10334  )10335  number_of_images: Optional[int] = Field(10336      default=None, description="""Number of images to generate."""10337  )10338  base_steps: Optional[int] = Field(10339      default=None,10340      description="""The number of sampling steps. A higher value has better image10341      quality, while a lower value has better latency.""",10342  )10343  output_gcs_uri: Optional[str] = Field(10344      default=None,10345      description="""Cloud Storage URI used to store the generated images.""",10346  )10347  seed: Optional[int] = Field(10348      default=None, description="""Random seed for image generation."""10349  )10350  safety_filter_level: Optional[SafetyFilterLevel] = Field(10351      default=None, description="""Filter level for safety filtering."""10352  )10353  person_generation: Optional[PersonGeneration] = Field(10354      default=None,10355      description="""Whether allow to generate person images, and restrict to specific10356      ages.""",10357  )10358  add_watermark: Optional[bool] = Field(10359      default=None,10360      description="""Whether to add a SynthID watermark to the generated images.""",10361  )10362  output_mime_type: Optional[str] = Field(10363      default=None, description="""MIME type of the generated image."""10364  )10365  output_compression_quality: Optional[int] = Field(10366      default=None,10367      description="""Compression quality of the generated image (for ``image/jpeg``10368      only).""",10369  )10370  enhance_prompt: Optional[bool] = Field(10371      default=None, description="""Whether to use the prompt rewriting logic."""10372  )10373  labels: Optional[dict[str, str]] = Field(10374      default=None,10375      description="""User specified labels to track billing usage.""",10376  )103771037810379class RecontextImageConfigDict(TypedDict, total=False):10380  """Configuration for recontextualizing an image."""1038110382  http_options: Optional[HttpOptionsDict]10383  """Used to override HTTP request options."""1038410385  number_of_images: Optional[int]10386  """Number of images to generate."""1038710388  base_steps: Optional[int]10389  """The number of sampling steps. A higher value has better image10390      quality, while a lower value has better latency."""1039110392  output_gcs_uri: Optional[str]10393  """Cloud Storage URI used to store the generated images."""1039410395  seed: Optional[int]10396  """Random seed for image generation."""1039710398  safety_filter_level: Optional[SafetyFilterLevel]10399  """Filter level for safety filtering."""1040010401  person_generation: Optional[PersonGeneration]10402  """Whether allow to generate person images, and restrict to specific10403      ages."""1040410405  add_watermark: Optional[bool]10406  """Whether to add a SynthID watermark to the generated images."""1040710408  output_mime_type: Optional[str]10409  """MIME type of the generated image."""1041010411  output_compression_quality: Optional[int]10412  """Compression quality of the generated image (for ``image/jpeg``10413      only)."""1041410415  enhance_prompt: Optional[bool]10416  """Whether to use the prompt rewriting logic."""1041710418  labels: Optional[dict[str, str]]10419  """User specified labels to track billing usage."""104201042110422RecontextImageConfigOrDict = Union[10423    RecontextImageConfig, RecontextImageConfigDict10424]104251042610427class _RecontextImageParameters(_common.BaseModel):10428  """The parameters for recontextualizing an image."""1042910430  model: Optional[str] = Field(10431      default=None,10432      description="""ID of the model to use. For a list of models, see `Google models10433    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",10434  )10435  source: Optional[RecontextImageSource] = Field(10436      default=None,10437      description="""A set of source input(s) for image recontextualization.""",10438  )10439  config: Optional[RecontextImageConfig] = Field(10440      default=None,10441      description="""Configuration for image recontextualization.""",10442  )104431044410445class _RecontextImageParametersDict(TypedDict, total=False):10446  """The parameters for recontextualizing an image."""1044710448  model: Optional[str]10449  """ID of the model to use. For a list of models, see `Google models10450    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""1045110452  source: Optional[RecontextImageSourceDict]10453  """A set of source input(s) for image recontextualization."""1045410455  config: Optional[RecontextImageConfigDict]10456  """Configuration for image recontextualization."""104571045810459_RecontextImageParametersOrDict = Union[10460    _RecontextImageParameters, _RecontextImageParametersDict10461]104621046310464class RecontextImageResponse(_common.BaseModel):10465  """The output images response."""1046610467  generated_images: Optional[list[GeneratedImage]] = Field(10468      default=None, description="""List of generated images."""10469  )104701047110472class RecontextImageResponseDict(TypedDict, total=False):10473  """The output images response."""1047410475  generated_images: Optional[list[GeneratedImageDict]]10476  """List of generated images."""104771047810479RecontextImageResponseOrDict = Union[10480    RecontextImageResponse, RecontextImageResponseDict10481]104821048310484class ScribbleImage(_common.BaseModel):10485  """An image mask representing a brush scribble."""1048610487  image: Optional[Image] = Field(10488      default=None,10489      description="""The brush scribble to guide segmentation. Valid for the interactive mode.""",10490  )104911049210493class ScribbleImageDict(TypedDict, total=False):10494  """An image mask representing a brush scribble."""1049510496  image: Optional[ImageDict]10497  """The brush scribble to guide segmentation. Valid for the interactive mode."""104981049910500ScribbleImageOrDict = Union[ScribbleImage, ScribbleImageDict]105011050210503class SegmentImageSource(_common.BaseModel):10504  """A set of source input(s) for image segmentation."""1050510506  prompt: Optional[str] = Field(10507      default=None,10508      description="""A text prompt for guiding the model during image segmentation.10509      Required for prompt mode and semantic mode, disallowed for other modes.""",10510  )10511  image: Optional[Image] = Field(10512      default=None, description="""The image to be segmented."""10513  )10514  scribble_image: Optional[ScribbleImage] = Field(10515      default=None,10516      description="""The brush scribble to guide segmentation.10517      Required for the interactive mode, disallowed for other modes.""",10518  )105191052010521class SegmentImageSourceDict(TypedDict, total=False):10522  """A set of source input(s) for image segmentation."""1052310524  prompt: Optional[str]10525  """A text prompt for guiding the model during image segmentation.10526      Required for prompt mode and semantic mode, disallowed for other modes."""1052710528  image: Optional[ImageDict]10529  """The image to be segmented."""1053010531  scribble_image: Optional[ScribbleImageDict]10532  """The brush scribble to guide segmentation.10533      Required for the interactive mode, disallowed for other modes."""105341053510536SegmentImageSourceOrDict = Union[SegmentImageSource, SegmentImageSourceDict]105371053810539class SegmentImageConfig(_common.BaseModel):10540  """Configuration for segmenting an image."""1054110542  http_options: Optional[HttpOptions] = Field(10543      default=None, description="""Used to override HTTP request options."""10544  )10545  mode: Optional[SegmentMode] = Field(10546      default=None, description="""The segmentation mode to use."""10547  )10548  max_predictions: Optional[int] = Field(10549      default=None,10550      description="""The maximum number of predictions to return up to, by top10551      confidence score.""",10552  )10553  confidence_threshold: Optional[float] = Field(10554      default=None,10555      description="""The confidence score threshold for the detections as a decimal10556      value. Only predictions with a confidence score higher than this10557      threshold will be returned.""",10558  )10559  mask_dilation: Optional[float] = Field(10560      default=None,10561      description="""A decimal value representing how much dilation to apply to the10562      masks. 0 for no dilation. 1.0 means the masked area covers the whole10563      image.""",10564  )10565  binary_color_threshold: Optional[float] = Field(10566      default=None,10567      description="""The binary color threshold to apply to the masks. The threshold10568      can be set to a decimal value between 0 and 255 non-inclusive.10569      Set to -1 for no binary color thresholding.""",10570  )10571  labels: Optional[dict[str, str]] = Field(10572      default=None,10573      description="""User specified labels to track billing usage.""",10574  )105751057610577class SegmentImageConfigDict(TypedDict, total=False):10578  """Configuration for segmenting an image."""1057910580  http_options: Optional[HttpOptionsDict]10581  """Used to override HTTP request options."""1058210583  mode: Optional[SegmentMode]10584  """The segmentation mode to use."""1058510586  max_predictions: Optional[int]10587  """The maximum number of predictions to return up to, by top10588      confidence score."""1058910590  confidence_threshold: Optional[float]10591  """The confidence score threshold for the detections as a decimal10592      value. Only predictions with a confidence score higher than this10593      threshold will be returned."""1059410595  mask_dilation: Optional[float]10596  """A decimal value representing how much dilation to apply to the10597      masks. 0 for no dilation. 1.0 means the masked area covers the whole10598      image."""1059910600  binary_color_threshold: Optional[float]10601  """The binary color threshold to apply to the masks. The threshold10602      can be set to a decimal value between 0 and 255 non-inclusive.10603      Set to -1 for no binary color thresholding."""1060410605  labels: Optional[dict[str, str]]10606  """User specified labels to track billing usage."""106071060810609SegmentImageConfigOrDict = Union[SegmentImageConfig, SegmentImageConfigDict]106101061110612class _SegmentImageParameters(_common.BaseModel):10613  """The parameters for segmenting an image."""1061410615  model: Optional[str] = Field(10616      default=None,10617      description="""ID of the model to use. For a list of models, see `Google models10618    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",10619  )10620  source: Optional[SegmentImageSource] = Field(10621      default=None,10622      description="""A set of source input(s) for image segmentation.""",10623  )10624  config: Optional[SegmentImageConfig] = Field(10625      default=None, description="""Configuration for image segmentation."""10626  )106271062810629class _SegmentImageParametersDict(TypedDict, total=False):10630  """The parameters for segmenting an image."""1063110632  model: Optional[str]10633  """ID of the model to use. For a list of models, see `Google models10634    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""1063510636  source: Optional[SegmentImageSourceDict]10637  """A set of source input(s) for image segmentation."""1063810639  config: Optional[SegmentImageConfigDict]10640  """Configuration for image segmentation."""106411064210643_SegmentImageParametersOrDict = Union[10644    _SegmentImageParameters, _SegmentImageParametersDict10645]106461064710648class EntityLabel(_common.BaseModel):10649  """An entity representing the segmented area."""1065010651  label: Optional[str] = Field(10652      default=None, description="""The label of the segmented entity."""10653  )10654  score: Optional[float] = Field(10655      default=None,10656      description="""The confidence score of the detected label.""",10657  )106581065910660class EntityLabelDict(TypedDict, total=False):10661  """An entity representing the segmented area."""1066210663  label: Optional[str]10664  """The label of the segmented entity."""1066510666  score: Optional[float]10667  """The confidence score of the detected label."""106681066910670EntityLabelOrDict = Union[EntityLabel, EntityLabelDict]106711067210673class GeneratedImageMask(_common.BaseModel):10674  """A generated image mask."""1067510676  mask: Optional[Image] = Field(10677      default=None, description="""The generated image mask."""10678  )10679  labels: Optional[list[EntityLabel]] = Field(10680      default=None,10681      description="""The detected entities on the segmented area.""",10682  )106831068410685class GeneratedImageMaskDict(TypedDict, total=False):10686  """A generated image mask."""1068710688  mask: Optional[ImageDict]10689  """The generated image mask."""1069010691  labels: Optional[list[EntityLabelDict]]10692  """The detected entities on the segmented area."""106931069410695GeneratedImageMaskOrDict = Union[GeneratedImageMask, GeneratedImageMaskDict]106961069710698class SegmentImageResponse(_common.BaseModel):10699  """The output images response."""1070010701  generated_masks: Optional[list[GeneratedImageMask]] = Field(10702      default=None,10703      description="""List of generated image masks.10704      """,10705  )107061070710708class SegmentImageResponseDict(TypedDict, total=False):10709  """The output images response."""1071010711  generated_masks: Optional[list[GeneratedImageMaskDict]]10712  """List of generated image masks.10713      """107141071510716SegmentImageResponseOrDict = Union[10717    SegmentImageResponse, SegmentImageResponseDict10718]107191072010721class GetModelConfig(_common.BaseModel):10722  """Optional parameters for models.get method."""1072310724  http_options: Optional[HttpOptions] = Field(10725      default=None, description="""Used to override HTTP request options."""10726  )107271072810729class GetModelConfigDict(TypedDict, total=False):10730  """Optional parameters for models.get method."""1073110732  http_options: Optional[HttpOptionsDict]10733  """Used to override HTTP request options."""107341073510736GetModelConfigOrDict = Union[GetModelConfig, GetModelConfigDict]107371073810739class _GetModelParameters(_common.BaseModel):1074010741  model: Optional[str] = Field(default=None, description="""""")10742  config: Optional[GetModelConfig] = Field(10743      default=None, description="""Optional parameters for the request."""10744  )107451074610747class _GetModelParametersDict(TypedDict, total=False):1074810749  model: Optional[str]10750  """"""1075110752  config: Optional[GetModelConfigDict]10753  """Optional parameters for the request."""107541075510756_GetModelParametersOrDict = Union[_GetModelParameters, _GetModelParametersDict]107571075810759class Endpoint(_common.BaseModel):10760  """An endpoint where you deploy models."""1076110762  name: Optional[str] = Field(10763      default=None, description="""Resource name of the endpoint."""10764  )10765  deployed_model_id: Optional[str] = Field(10766      default=None,10767      description="""ID of the model that's deployed to the endpoint.""",10768  )107691077010771class EndpointDict(TypedDict, total=False):10772  """An endpoint where you deploy models."""1077310774  name: Optional[str]10775  """Resource name of the endpoint."""1077610777  deployed_model_id: Optional[str]10778  """ID of the model that's deployed to the endpoint."""107791078010781EndpointOrDict = Union[Endpoint, EndpointDict]107821078310784class TunedModelInfo(_common.BaseModel):10785  """A tuned machine learning model."""1078610787  base_model: Optional[str] = Field(10788      default=None,10789      description="""ID of the base model that you want to tune.""",10790  )10791  create_time: Optional[datetime.datetime] = Field(10792      default=None,10793      description="""Date and time when the base model was created.""",10794  )10795  update_time: Optional[datetime.datetime] = Field(10796      default=None,10797      description="""Date and time when the base model was last updated.""",10798  )107991080010801class TunedModelInfoDict(TypedDict, total=False):10802  """A tuned machine learning model."""1080310804  base_model: Optional[str]10805  """ID of the base model that you want to tune."""1080610807  create_time: Optional[datetime.datetime]10808  """Date and time when the base model was created."""1080910810  update_time: Optional[datetime.datetime]10811  """Date and time when the base model was last updated."""108121081310814TunedModelInfoOrDict = Union[TunedModelInfo, TunedModelInfoDict]108151081610817class Checkpoint(_common.BaseModel):10818  """Describes the machine learning model version checkpoint."""1081910820  checkpoint_id: Optional[str] = Field(10821      default=None,10822      description="""The ID of the checkpoint.10823      """,10824  )10825  epoch: Optional[int] = Field(10826      default=None,10827      description="""The epoch of the checkpoint.10828      """,10829  )10830  step: Optional[int] = Field(10831      default=None,10832      description="""The step of the checkpoint.10833      """,10834  )108351083610837class CheckpointDict(TypedDict, total=False):10838  """Describes the machine learning model version checkpoint."""1083910840  checkpoint_id: Optional[str]10841  """The ID of the checkpoint.10842      """1084310844  epoch: Optional[int]10845  """The epoch of the checkpoint.10846      """1084710848  step: Optional[int]10849  """The step of the checkpoint.10850      """108511085210853CheckpointOrDict = Union[Checkpoint, CheckpointDict]108541085510856class Model(_common.BaseModel):10857  """A trained machine learning model."""1085810859  name: Optional[str] = Field(10860      default=None, description="""Resource name of the model."""10861  )10862  display_name: Optional[str] = Field(10863      default=None, description="""Display name of the model."""10864  )10865  description: Optional[str] = Field(10866      default=None, description="""Description of the model."""10867  )10868  version: Optional[str] = Field(10869      default=None,10870      description="""Version ID of the model. A new version is committed when a new10871      model version is uploaded or trained under an existing model ID. The10872      version ID is an auto-incrementing decimal number in string10873      representation.""",10874  )10875  endpoints: Optional[list[Endpoint]] = Field(10876      default=None,10877      description="""List of deployed models created from this base model. Note that a10878      model could have been deployed to endpoints in different locations.""",10879  )10880  labels: Optional[dict[str, str]] = Field(10881      default=None,10882      description="""Labels with user-defined metadata to organize your models.""",10883  )10884  tuned_model_info: Optional[TunedModelInfo] = Field(10885      default=None,10886      description="""Information about the tuned model from the base model.""",10887  )10888  input_token_limit: Optional[int] = Field(10889      default=None,10890      description="""The maximum number of input tokens that the model can handle.""",10891  )10892  output_token_limit: Optional[int] = Field(10893      default=None,10894      description="""The maximum number of output tokens that the model can generate.""",10895  )10896  supported_actions: Optional[list[str]] = Field(10897      default=None,10898      description="""List of actions that are supported by the model.""",10899  )10900  default_checkpoint_id: Optional[str] = Field(10901      default=None,10902      description="""The default checkpoint id of a model version.10903      """,10904  )10905  checkpoints: Optional[list[Checkpoint]] = Field(10906      default=None, description="""The checkpoints of the model."""10907  )10908  temperature: Optional[float] = Field(10909      default=None,10910      description="""Temperature value used for sampling set when the dataset was saved.10911      This value is used to tune the degree of randomness.""",10912  )10913  max_temperature: Optional[float] = Field(10914      default=None,10915      description="""The maximum temperature value used for sampling set when the10916      dataset was saved. This value is used to tune the degree of randomness.""",10917  )10918  top_p: Optional[float] = Field(10919      default=None,10920      description="""Optional. Specifies the nucleus sampling threshold. The model10921      considers only the smallest set of tokens whose cumulative probability is10922      at least `top_p`. This helps generate more diverse and less repetitive10923      responses. For example, a `top_p` of 0.9 means the model considers tokens10924      until the cumulative probability of the tokens to select from reaches 0.9.10925      It's recommended to adjust either temperature or `top_p`, but not both.""",10926  )10927  top_k: Optional[int] = Field(10928      default=None,10929      description="""Optional. Specifies the top-k sampling threshold. The model10930      considers only the top k most probable tokens for the next token. This can10931      be useful for generating more coherent and less random text. For example,10932      a `top_k` of 40 means the model will choose the next word from the 40 most10933      likely words.""",10934  )10935  thinking: Optional[bool] = Field(10936      default=None,10937      description="""Whether the model supports thinking features. If true, thoughts are10938      returned only if the model supports thought and thoughts are available.""",10939  )109401094110942class ModelDict(TypedDict, total=False):10943  """A trained machine learning model."""1094410945  name: Optional[str]10946  """Resource name of the model."""1094710948  display_name: Optional[str]10949  """Display name of the model."""1095010951  description: Optional[str]10952  """Description of the model."""1095310954  version: Optional[str]10955  """Version ID of the model. A new version is committed when a new10956      model version is uploaded or trained under an existing model ID. The10957      version ID is an auto-incrementing decimal number in string10958      representation."""1095910960  endpoints: Optional[list[EndpointDict]]10961  """List of deployed models created from this base model. Note that a10962      model could have been deployed to endpoints in different locations."""1096310964  labels: Optional[dict[str, str]]10965  """Labels with user-defined metadata to organize your models."""1096610967  tuned_model_info: Optional[TunedModelInfoDict]10968  """Information about the tuned model from the base model."""1096910970  input_token_limit: Optional[int]10971  """The maximum number of input tokens that the model can handle."""1097210973  output_token_limit: Optional[int]10974  """The maximum number of output tokens that the model can generate."""1097510976  supported_actions: Optional[list[str]]10977  """List of actions that are supported by the model."""1097810979  default_checkpoint_id: Optional[str]10980  """The default checkpoint id of a model version.10981      """1098210983  checkpoints: Optional[list[CheckpointDict]]10984  """The checkpoints of the model."""1098510986  temperature: Optional[float]10987  """Temperature value used for sampling set when the dataset was saved.10988      This value is used to tune the degree of randomness."""1098910990  max_temperature: Optional[float]10991  """The maximum temperature value used for sampling set when the10992      dataset was saved. This value is used to tune the degree of randomness."""1099310994  top_p: Optional[float]10995  """Optional. Specifies the nucleus sampling threshold. The model10996      considers only the smallest set of tokens whose cumulative probability is10997      at least `top_p`. This helps generate more diverse and less repetitive10998      responses. For example, a `top_p` of 0.9 means the model considers tokens10999      until the cumulative probability of the tokens to select from reaches 0.9.11000      It's recommended to adjust either temperature or `top_p`, but not both."""1100111002  top_k: Optional[int]11003  """Optional. Specifies the top-k sampling threshold. The model11004      considers only the top k most probable tokens for the next token. This can11005      be useful for generating more coherent and less random text. For example,11006      a `top_k` of 40 means the model will choose the next word from the 40 most11007      likely words."""1100811009  thinking: Optional[bool]11010  """Whether the model supports thinking features. If true, thoughts are11011      returned only if the model supports thought and thoughts are available."""110121101311014ModelOrDict = Union[Model, ModelDict]110151101611017class ListModelsConfig(_common.BaseModel):1101811019  http_options: Optional[HttpOptions] = Field(11020      default=None, description="""Used to override HTTP request options."""11021  )11022  page_size: Optional[int] = Field(default=None, description="""""")11023  page_token: Optional[str] = Field(default=None, description="""""")11024  filter: Optional[str] = Field(default=None, description="""""")11025  query_base: Optional[bool] = Field(11026      default=None,11027      description="""Set true to list base models, false to list tuned models.""",11028  )110291103011031class ListModelsConfigDict(TypedDict, total=False):1103211033  http_options: Optional[HttpOptionsDict]11034  """Used to override HTTP request options."""1103511036  page_size: Optional[int]11037  """"""1103811039  page_token: Optional[str]11040  """"""1104111042  filter: Optional[str]11043  """"""1104411045  query_base: Optional[bool]11046  """Set true to list base models, false to list tuned models."""110471104811049ListModelsConfigOrDict = Union[ListModelsConfig, ListModelsConfigDict]110501105111052class _ListModelsParameters(_common.BaseModel):1105311054  config: Optional[ListModelsConfig] = Field(default=None, description="""""")110551105611057class _ListModelsParametersDict(TypedDict, total=False):1105811059  config: Optional[ListModelsConfigDict]11060  """"""110611106211063_ListModelsParametersOrDict = Union[11064    _ListModelsParameters, _ListModelsParametersDict11065]110661106711068class ListModelsResponse(_common.BaseModel):1106911070  sdk_http_response: Optional[HttpResponse] = Field(11071      default=None, description="""Used to retain the full HTTP response."""11072  )11073  next_page_token: Optional[str] = Field(default=None, description="""""")11074  models: Optional[list[Model]] = Field(default=None, description="""""")110751107611077class ListModelsResponseDict(TypedDict, total=False):1107811079  sdk_http_response: Optional[HttpResponseDict]11080  """Used to retain the full HTTP response."""1108111082  next_page_token: Optional[str]11083  """"""1108411085  models: Optional[list[ModelDict]]11086  """"""110871108811089ListModelsResponseOrDict = Union[ListModelsResponse, ListModelsResponseDict]110901109111092class UpdateModelConfig(_common.BaseModel):11093  """Configuration for updating a tuned model."""1109411095  http_options: Optional[HttpOptions] = Field(11096      default=None, description="""Used to override HTTP request options."""11097  )11098  display_name: Optional[str] = Field(default=None, description="""""")11099  description: Optional[str] = Field(default=None, description="""""")11100  default_checkpoint_id: Optional[str] = Field(default=None, description="""""")111011110211103class UpdateModelConfigDict(TypedDict, total=False):11104  """Configuration for updating a tuned model."""1110511106  http_options: Optional[HttpOptionsDict]11107  """Used to override HTTP request options."""1110811109  display_name: Optional[str]11110  """"""1111111112  description: Optional[str]11113  """"""1111411115  default_checkpoint_id: Optional[str]11116  """"""111171111811119UpdateModelConfigOrDict = Union[UpdateModelConfig, UpdateModelConfigDict]111201112111122class _UpdateModelParameters(_common.BaseModel):11123  """Configuration for updating a tuned model."""1112411125  model: Optional[str] = Field(default=None, description="""""")11126  config: Optional[UpdateModelConfig] = Field(default=None, description="""""")111271112811129class _UpdateModelParametersDict(TypedDict, total=False):11130  """Configuration for updating a tuned model."""1113111132  model: Optional[str]11133  """"""1113411135  config: Optional[UpdateModelConfigDict]11136  """"""111371113811139_UpdateModelParametersOrDict = Union[11140    _UpdateModelParameters, _UpdateModelParametersDict11141]111421114311144class DeleteModelConfig(_common.BaseModel):11145  """Configuration for deleting a tuned model."""1114611147  http_options: Optional[HttpOptions] = Field(11148      default=None, description="""Used to override HTTP request options."""11149  )111501115111152class DeleteModelConfigDict(TypedDict, total=False):11153  """Configuration for deleting a tuned model."""1115411155  http_options: Optional[HttpOptionsDict]11156  """Used to override HTTP request options."""111571115811159DeleteModelConfigOrDict = Union[DeleteModelConfig, DeleteModelConfigDict]111601116111162class _DeleteModelParameters(_common.BaseModel):11163  """Parameters for deleting a tuned model."""1116411165  model: Optional[str] = Field(default=None, description="""""")11166  config: Optional[DeleteModelConfig] = Field(11167      default=None, description="""Optional parameters for the request."""11168  )111691117011171class _DeleteModelParametersDict(TypedDict, total=False):11172  """Parameters for deleting a tuned model."""1117311174  model: Optional[str]11175  """"""1117611177  config: Optional[DeleteModelConfigDict]11178  """Optional parameters for the request."""111791118011181_DeleteModelParametersOrDict = Union[11182    _DeleteModelParameters, _DeleteModelParametersDict11183]111841118511186class DeleteModelResponse(_common.BaseModel):1118711188  sdk_http_response: Optional[HttpResponse] = Field(11189      default=None, description="""Used to retain the full HTTP response."""11190  )111911119211193class DeleteModelResponseDict(TypedDict, total=False):1119411195  sdk_http_response: Optional[HttpResponseDict]11196  """Used to retain the full HTTP response."""111971119811199DeleteModelResponseOrDict = Union[DeleteModelResponse, DeleteModelResponseDict]112001120111202class AudioResponseFormat(_common.BaseModel):11203  """Configuration for audio-specific output formatting."""1120411205  bit_rate: Optional[int] = Field(11206      default=None,11207      description="""Optional. Bit rate in bits per second (bps). Only applicable for compressed formats (MP3, Opus).""",11208  )11209  delivery: Optional[Delivery] = Field(11210      default=None,11211      description="""Optional. Delivery mode for the generated content.""",11212  )11213  mime_type: Optional[str] = Field(11214      default=None,11215      description="""Optional. The MIME type of the audio output.""",11216  )11217  sample_rate: Optional[int] = Field(11218      default=None,11219      description="""Optional. Sample rate for the generated audio in Hertz.""",11220  )112211122211223class AudioResponseFormatDict(TypedDict, total=False):11224  """Configuration for audio-specific output formatting."""1122511226  bit_rate: Optional[int]11227  """Optional. Bit rate in bits per second (bps). Only applicable for compressed formats (MP3, Opus)."""1122811229  delivery: Optional[Delivery]11230  """Optional. Delivery mode for the generated content."""1123111232  mime_type: Optional[str]11233  """Optional. The MIME type of the audio output."""1123411235  sample_rate: Optional[int]11236  """Optional. Sample rate for the generated audio in Hertz."""112371123811239AudioResponseFormatOrDict = Union[AudioResponseFormat, AudioResponseFormatDict]112401124111242class ImageResponseFormat(_common.BaseModel):11243  """Configuration for image-specific output formatting."""1124411245  aspect_ratio: Optional[AspectRatio] = Field(11246      default=None,11247      description="""Optional. The aspect ratio for the image output.""",11248  )11249  delivery: Optional[Delivery] = Field(11250      default=None,11251      description="""Optional. Delivery mode for the generated content.""",11252  )11253  image_size: Optional[ImageSize] = Field(11254      default=None, description="""Optional. The size of the image output."""11255  )11256  mime_type: Optional[str] = Field(11257      default=None,11258      description="""Optional. The MIME type of the image output.""",11259  )112601126111262class ImageResponseFormatDict(TypedDict, total=False):11263  """Configuration for image-specific output formatting."""1126411265  aspect_ratio: Optional[AspectRatio]11266  """Optional. The aspect ratio for the image output."""1126711268  delivery: Optional[Delivery]11269  """Optional. Delivery mode for the generated content."""1127011271  image_size: Optional[ImageSize]11272  """Optional. The size of the image output."""1127311274  mime_type: Optional[str]11275  """Optional. The MIME type of the image output."""112761127711278ImageResponseFormatOrDict = Union[ImageResponseFormat, ImageResponseFormatDict]112791128011281class TextResponseFormat(_common.BaseModel):11282  """Configuration for text-specific output formatting."""1128311284  mime_type: Optional[str] = Field(11285      default=None,11286      description="""Optional. The IANA standard MIME type of the response.""",11287  )11288  jsonSchema: Optional[Any] = Field(11289      alias='schema',11290      default=None,11291      description="""Optional. The JSON schema that the output should conform to. Only applicable when mime_type is APPLICATION_JSON.""",11292  )112931129411295class TextResponseFormatDict(TypedDict, total=False):11296  """Configuration for text-specific output formatting."""1129711298  mime_type: Optional[str]11299  """Optional. The IANA standard MIME type of the response."""1130011301  schema: Optional[Any]11302  """Optional. The JSON schema that the output should conform to. Only applicable when mime_type is APPLICATION_JSON."""113031130411305TextResponseFormatOrDict = Union[TextResponseFormat, TextResponseFormatDict]113061130711308class VideoResponseFormat(_common.BaseModel):11309  """Configuration for video-specific output formatting.1131011311  This data type is not supported in Gemini API.11312  """1131311314  aspect_ratio: Optional[AspectRatio] = Field(11315      default=None, description="""The aspect ratio for the video output."""11316  )11317  delivery: Optional[Delivery] = Field(11318      default=None,11319      description="""Optional. Delivery mode for the generated content.""",11320  )11321  duration: Optional[str] = Field(11322      default=None,11323      description="""Optional. The duration for the video output.""",11324  )11325  gcs_uri: Optional[str] = Field(11326      default=None,11327      description="""Optional. The Google Cloud Storage URI to store the video output. Required for Vertex if delivery is URI.""",11328  )11329  resolution: Optional[str] = Field(11330      default=None,11331      description="""Optional. The video output resolution. Supported values: "360p", "720p", "1080p", "4k".""",11332  )113331133411335class VideoResponseFormatDict(TypedDict, total=False):11336  """Configuration for video-specific output formatting.1133711338  This data type is not supported in Gemini API.11339  """1134011341  aspect_ratio: Optional[AspectRatio]11342  """The aspect ratio for the video output."""1134311344  delivery: Optional[Delivery]11345  """Optional. Delivery mode for the generated content."""1134611347  duration: Optional[str]11348  """Optional. The duration for the video output."""1134911350  gcs_uri: Optional[str]11351  """Optional. The Google Cloud Storage URI to store the video output. Required for Vertex if delivery is URI."""1135211353  resolution: Optional[str]11354  """Optional. The video output resolution. Supported values: "360p", "720p", "1080p", "4k"."""113551135611357VideoResponseFormatOrDict = Union[VideoResponseFormat, VideoResponseFormatDict]113581135911360class ResponseFormat(_common.BaseModel):11361  """Configuration for the model to configure output formatting and delivery.1136211363  This data type is not supported in Gemini API.11364  """1136511366  audio: Optional[AudioResponseFormat] = Field(11367      default=None, description="""Audio output format."""11368  )11369  image: Optional[ImageResponseFormat] = Field(11370      default=None, description="""Image output format."""11371  )11372  text: Optional[TextResponseFormat] = Field(11373      default=None, description="""Text output format."""11374  )11375  video: Optional[VideoResponseFormat] = Field(11376      default=None, description="""Video output format."""11377  )113781137911380class ResponseFormatDict(TypedDict, total=False):11381  """Configuration for the model to configure output formatting and delivery.1138211383  This data type is not supported in Gemini API.11384  """1138511386  audio: Optional[AudioResponseFormatDict]11387  """Audio output format."""1138811389  image: Optional[ImageResponseFormatDict]11390  """Image output format."""1139111392  text: Optional[TextResponseFormatDict]11393  """Text output format."""1139411395  video: Optional[VideoResponseFormatDict]11396  """Video output format."""113971139811399ResponseFormatOrDict = Union[ResponseFormat, ResponseFormatDict]114001140111402class TranslationConfig(_common.BaseModel):11403  """Config for stream translation."""1140411405  echo_target_language: Optional[bool] = Field(11406      default=None,11407      description="""If true, the model will generate audio when the target language is spoken, essentially it will parrot the input. If false, we will not produce audio for the target language.""",11408  )11409  target_language_code: Optional[str] = Field(11410      default=None,11411      description="""The target language for translation. Supported values are BCP-47 language codes (e.g. "en", "es", "fr").""",11412  )114131141411415class TranslationConfigDict(TypedDict, total=False):11416  """Config for stream translation."""1141711418  echo_target_language: Optional[bool]11419  """If true, the model will generate audio when the target language is spoken, essentially it will parrot the input. If false, we will not produce audio for the target language."""1142011421  target_language_code: Optional[str]11422  """The target language for translation. Supported values are BCP-47 language codes (e.g. "en", "es", "fr")."""114231142411425TranslationConfigOrDict = Union[TranslationConfig, TranslationConfigDict]114261142711428class GenerationConfig(_common.BaseModel):11429  """Generation config."""1143011431  model_selection_config: Optional[ModelSelectionConfig] = Field(11432      default=None, description="""Optional. Config for model selection."""11433  )11434  response_json_schema: Optional[Any] = Field(11435      default=None,11436      description="""Output schema of the generated response. This is an alternative to11437      `response_schema` that accepts [JSON Schema](https://json-schema.org/).11438      """,11439  )11440  audio_timestamp: Optional[bool] = Field(11441      default=None,11442      description="""Optional. If enabled, audio timestamps will be included in the request to the model. This can be useful for synchronizing audio with other modalities in the response. This field is not supported in Gemini API.""",11443  )11444  candidate_count: Optional[int] = Field(11445      default=None,11446      description="""Optional. The number of candidate responses to generate. A higher `candidate_count` can provide more options to choose from, but it also consumes more resources. This can be useful for generating a variety of responses and selecting the best one.""",11447  )11448  enable_affective_dialog: Optional[bool] = Field(11449      default=None,11450      description="""Optional. If enabled, the model will detect emotions and adapt its responses accordingly. For example, if the model detects that the user is frustrated, it may provide a more empathetic response.""",11451  )11452  frequency_penalty: Optional[float] = Field(11453      default=None,11454      description="""Optional. Penalizes tokens based on their frequency in the generated text. A positive value helps to reduce the repetition of words and phrases. Valid values can range from [-2.0, 2.0].""",11455  )11456  logprobs: Optional[int] = Field(11457      default=None,11458      description="""Optional. The number of top log probabilities to return for each token. This can be used to see which other tokens were considered likely candidates for a given position. A higher value will return more options, but it will also increase the size of the response.""",11459  )11460  max_output_tokens: Optional[int] = Field(11461      default=None,11462      description="""Optional. The maximum number of tokens to generate in the response. A token is approximately four characters. The default value varies by model. This parameter can be used to control the length of the generated text and prevent overly long responses.""",11463  )11464  media_resolution: Optional[MediaResolution] = Field(11465      default=None,11466      description="""Optional. The token resolution at which input media content is sampled. This is used to control the trade-off between the quality of the response and the number of tokens used to represent the media. A higher resolution allows the model to perceive more detail, which can lead to a more nuanced response, but it will also use more tokens. This does not affect the image dimensions sent to the model.""",11467  )11468  presence_penalty: Optional[float] = Field(11469      default=None,11470      description="""Optional. Penalizes tokens that have already appeared in the generated text. A positive value encourages the model to generate more diverse and less repetitive text. Valid values can range from [-2.0, 2.0].""",11471  )11472  response_logprobs: Optional[bool] = Field(11473      default=None,11474      description="""Optional. If set to true, the log probabilities of the output tokens are returned. Log probabilities are the logarithm of the probability of a token appearing in the output. A higher log probability means the token is more likely to be generated. This can be useful for analyzing the model's confidence in its own output and for debugging.""",11475  )11476  response_mime_type: Optional[str] = Field(11477      default=None,11478      description="""Optional. The IANA standard MIME type of the response. The model will generate output that conforms to this MIME type. Supported values include 'text/plain' (default) and 'application/json'. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. Deprecated: Use `response_format` instead.""",11479  )11480  response_modalities: Optional[list[Modality]] = Field(11481      default=None,11482      description="""Optional. The modalities of the response. The model will generate a response that includes all the specified modalities. For example, if this is set to `[TEXT, IMAGE]`, the response will include both text and an image.""",11483  )11484  response_schema: Optional[Schema] = Field(11485      default=None,11486      description="""Optional. Lets you to specify a schema for the model's response, ensuring that the output conforms to a particular structure. This is useful for generating structured data such as JSON. The schema is a subset of the [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must also set the `response_mime_type` to `application/json`. Deprecated: Use `response_format` instead.""",11487  )11488  routing_config: Optional[GenerationConfigRoutingConfig] = Field(11489      default=None,11490      description="""Optional. Routing configuration. This field is not supported in Gemini API.""",11491  )11492  seed: Optional[int] = Field(11493      default=None,11494      description="""Optional. A seed for the random number generator. By setting a seed, you can make the model's output mostly deterministic. For a given prompt and parameters (like temperature, top_p, etc.), the model will produce the same response every time. However, it's not a guaranteed absolute deterministic behavior. This is different from parameters like `temperature`, which control the *level* of randomness. `seed` ensures that the "random" choices the model makes are the same on every run, making it essential for testing and ensuring reproducible results.""",11495  )11496  speech_config: Optional[SpeechConfig] = Field(11497      default=None, description="""Optional. The speech generation config."""11498  )11499  stop_sequences: Optional[list[str]] = Field(11500      default=None,11501      description="""Optional. A list of character sequences that will stop the model from generating further tokens. If a stop sequence is generated, the output will end at that point. This is useful for controlling the length and structure of the output. For example, you can use ["\n", "###"] to stop generation at a new line or a specific marker.""",11502  )11503  temperature: Optional[float] = Field(11504      default=None,11505      description="""Optional. Controls the randomness of the output. A higher temperature results in more creative and diverse responses, while a lower temperature makes the output more predictable and focused. The valid range is (0.0, 2.0].""",11506  )11507  thinking_config: Optional[ThinkingConfig] = Field(11508      default=None,11509      description="""Optional. Configuration for thinking features. An error will be returned if this field is set for models that don't support thinking.""",11510  )11511  top_k: Optional[float] = Field(11512      default=None,11513      description="""Optional. Specifies the top-k sampling threshold. The model considers only the top k most probable tokens for the next token. This can be useful for generating more coherent and less random text. For example, a `top_k` of 40 means the model will choose the next word from the 40 most likely words.""",11514  )11515  top_p: Optional[float] = Field(11516      default=None,11517      description="""Optional. Specifies the nucleus sampling threshold. The model considers only the smallest set of tokens whose cumulative probability is at least `top_p`. This helps generate more diverse and less repetitive responses. For example, a `top_p` of 0.9 means the model considers tokens until the cumulative probability of the tokens to select from reaches 0.9. It's recommended to adjust either temperature or `top_p`, but not both.""",11518  )11519  enable_enhanced_civic_answers: Optional[bool] = Field(11520      default=None,11521      description="""Optional. Enables enhanced civic answers. It may not be available for all models. This field is not supported in Vertex AI.""",11522  )11523  response_format: Optional[list[ResponseFormat]] = Field(11524      default=None,11525      description="""Optional. New response format field for the model to configure output formatting and delivery.""",11526  )11527  translation_config: Optional[TranslationConfig] = Field(11528      default=None, description="""Optional. Config for translation."""11529  )11530  audio_transcription_config: Optional[AudioTranscriptionConfig] = Field(11531      default=None,11532      description="""Optional. Configuration for audio transcription (speech recognition).11533      """,11534  )115351153611537class GenerationConfigDict(TypedDict, total=False):11538  """Generation config."""1153911540  model_selection_config: Optional[ModelSelectionConfigDict]11541  """Optional. Config for model selection."""1154211543  response_json_schema: Optional[Any]11544  """Output schema of the generated response. This is an alternative to11545      `response_schema` that accepts [JSON Schema](https://json-schema.org/).11546      """1154711548  audio_timestamp: Optional[bool]11549  """Optional. If enabled, audio timestamps will be included in the request to the model. This can be useful for synchronizing audio with other modalities in the response. This field is not supported in Gemini API."""1155011551  candidate_count: Optional[int]11552  """Optional. The number of candidate responses to generate. A higher `candidate_count` can provide more options to choose from, but it also consumes more resources. This can be useful for generating a variety of responses and selecting the best one."""1155311554  enable_affective_dialog: Optional[bool]11555  """Optional. If enabled, the model will detect emotions and adapt its responses accordingly. For example, if the model detects that the user is frustrated, it may provide a more empathetic response."""1155611557  frequency_penalty: Optional[float]11558  """Optional. Penalizes tokens based on their frequency in the generated text. A positive value helps to reduce the repetition of words and phrases. Valid values can range from [-2.0, 2.0]."""1155911560  logprobs: Optional[int]11561  """Optional. The number of top log probabilities to return for each token. This can be used to see which other tokens were considered likely candidates for a given position. A higher value will return more options, but it will also increase the size of the response."""1156211563  max_output_tokens: Optional[int]11564  """Optional. The maximum number of tokens to generate in the response. A token is approximately four characters. The default value varies by model. This parameter can be used to control the length of the generated text and prevent overly long responses."""1156511566  media_resolution: Optional[MediaResolution]11567  """Optional. The token resolution at which input media content is sampled. This is used to control the trade-off between the quality of the response and the number of tokens used to represent the media. A higher resolution allows the model to perceive more detail, which can lead to a more nuanced response, but it will also use more tokens. This does not affect the image dimensions sent to the model."""1156811569  presence_penalty: Optional[float]11570  """Optional. Penalizes tokens that have already appeared in the generated text. A positive value encourages the model to generate more diverse and less repetitive text. Valid values can range from [-2.0, 2.0]."""1157111572  response_logprobs: Optional[bool]11573  """Optional. If set to true, the log probabilities of the output tokens are returned. Log probabilities are the logarithm of the probability of a token appearing in the output. A higher log probability means the token is more likely to be generated. This can be useful for analyzing the model's confidence in its own output and for debugging."""1157411575  response_mime_type: Optional[str]11576  """Optional. The IANA standard MIME type of the response. The model will generate output that conforms to this MIME type. Supported values include 'text/plain' (default) and 'application/json'. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. Deprecated: Use `response_format` instead."""1157711578  response_modalities: Optional[list[Modality]]11579  """Optional. The modalities of the response. The model will generate a response that includes all the specified modalities. For example, if this is set to `[TEXT, IMAGE]`, the response will include both text and an image."""1158011581  response_schema: Optional[SchemaDict]11582  """Optional. Lets you to specify a schema for the model's response, ensuring that the output conforms to a particular structure. This is useful for generating structured data such as JSON. The schema is a subset of the [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must also set the `response_mime_type` to `application/json`. Deprecated: Use `response_format` instead."""1158311584  routing_config: Optional[GenerationConfigRoutingConfigDict]11585  """Optional. Routing configuration. This field is not supported in Gemini API."""1158611587  seed: Optional[int]11588  """Optional. A seed for the random number generator. By setting a seed, you can make the model's output mostly deterministic. For a given prompt and parameters (like temperature, top_p, etc.), the model will produce the same response every time. However, it's not a guaranteed absolute deterministic behavior. This is different from parameters like `temperature`, which control the *level* of randomness. `seed` ensures that the "random" choices the model makes are the same on every run, making it essential for testing and ensuring reproducible results."""1158911590  speech_config: Optional[SpeechConfigDict]11591  """Optional. The speech generation config."""1159211593  stop_sequences: Optional[list[str]]11594  """Optional. A list of character sequences that will stop the model from generating further tokens. If a stop sequence is generated, the output will end at that point. This is useful for controlling the length and structure of the output. For example, you can use ["\n", "###"] to stop generation at a new line or a specific marker."""1159511596  temperature: Optional[float]11597  """Optional. Controls the randomness of the output. A higher temperature results in more creative and diverse responses, while a lower temperature makes the output more predictable and focused. The valid range is (0.0, 2.0]."""1159811599  thinking_config: Optional[ThinkingConfigDict]11600  """Optional. Configuration for thinking features. An error will be returned if this field is set for models that don't support thinking."""1160111602  top_k: Optional[float]11603  """Optional. Specifies the top-k sampling threshold. The model considers only the top k most probable tokens for the next token. This can be useful for generating more coherent and less random text. For example, a `top_k` of 40 means the model will choose the next word from the 40 most likely words."""1160411605  top_p: Optional[float]11606  """Optional. Specifies the nucleus sampling threshold. The model considers only the smallest set of tokens whose cumulative probability is at least `top_p`. This helps generate more diverse and less repetitive responses. For example, a `top_p` of 0.9 means the model considers tokens until the cumulative probability of the tokens to select from reaches 0.9. It's recommended to adjust either temperature or `top_p`, but not both."""1160711608  enable_enhanced_civic_answers: Optional[bool]11609  """Optional. Enables enhanced civic answers. It may not be available for all models. This field is not supported in Vertex AI."""1161011611  response_format: Optional[list[ResponseFormatDict]]11612  """Optional. New response format field for the model to configure output formatting and delivery."""1161311614  translation_config: Optional[TranslationConfigDict]11615  """Optional. Config for translation."""1161611617  audio_transcription_config: Optional[AudioTranscriptionConfigDict]11618  """Optional. Configuration for audio transcription (speech recognition).11619      """116201162111622GenerationConfigOrDict = Union[GenerationConfig, GenerationConfigDict]116231162411625class CountTokensConfig(_common.BaseModel):11626  """Config for the count_tokens method."""1162711628  http_options: Optional[HttpOptions] = Field(11629      default=None, description="""Used to override HTTP request options."""11630  )11631  system_instruction: Optional[ContentUnion] = Field(11632      default=None,11633      description="""Instructions for the model to steer it toward better performance.11634      """,11635  )11636  tools: Optional[list[Tool]] = Field(11637      default=None,11638      description="""Code that enables the system to interact with external systems to11639      perform an action outside of the knowledge and scope of the model.11640      """,11641  )11642  generation_config: Optional[GenerationConfig] = Field(11643      default=None,11644      description="""Configuration that the model uses to generate the response. Not11645      supported by the Gemini Developer API.11646      """,11647  )116481164911650class CountTokensConfigDict(TypedDict, total=False):11651  """Config for the count_tokens method."""1165211653  http_options: Optional[HttpOptionsDict]11654  """Used to override HTTP request options."""1165511656  system_instruction: Optional[ContentUnionDict]11657  """Instructions for the model to steer it toward better performance.11658      """1165911660  tools: Optional[list[ToolDict]]11661  """Code that enables the system to interact with external systems to11662      perform an action outside of the knowledge and scope of the model.11663      """1166411665  generation_config: Optional[GenerationConfigDict]11666  """Configuration that the model uses to generate the response. Not11667      supported by the Gemini Developer API.11668      """116691167011671CountTokensConfigOrDict = Union[CountTokensConfig, CountTokensConfigDict]116721167311674class _CountTokensParameters(_common.BaseModel):11675  """Parameters for counting tokens."""1167611677  model: Optional[str] = Field(11678      default=None,11679      description="""ID of the model to use. For a list of models, see `Google models11680    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",11681  )11682  contents: Optional[ContentListUnion] = Field(11683      default=None, description="""Input content."""11684  )11685  config: Optional[CountTokensConfig] = Field(11686      default=None, description="""Configuration for counting tokens."""11687  )116881168911690class _CountTokensParametersDict(TypedDict, total=False):11691  """Parameters for counting tokens."""1169211693  model: Optional[str]11694  """ID of the model to use. For a list of models, see `Google models11695    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""1169611697  contents: Optional[ContentListUnionDict]11698  """Input content."""1169911700  config: Optional[CountTokensConfigDict]11701  """Configuration for counting tokens."""117021170311704_CountTokensParametersOrDict = Union[11705    _CountTokensParameters, _CountTokensParametersDict11706]117071170811709class CountTokensResponse(_common.BaseModel):11710  """Response for counting tokens."""1171111712  sdk_http_response: Optional[HttpResponse] = Field(11713      default=None, description="""Used to retain the full HTTP response."""11714  )11715  total_tokens: Optional[int] = Field(11716      default=None, description="""Total number of tokens."""11717  )11718  cached_content_token_count: Optional[int] = Field(11719      default=None,11720      description="""Number of tokens in the cached part of the prompt (the cached content).""",11721  )117221172311724class CountTokensResponseDict(TypedDict, total=False):11725  """Response for counting tokens."""1172611727  sdk_http_response: Optional[HttpResponseDict]11728  """Used to retain the full HTTP response."""1172911730  total_tokens: Optional[int]11731  """Total number of tokens."""1173211733  cached_content_token_count: Optional[int]11734  """Number of tokens in the cached part of the prompt (the cached content)."""117351173611737CountTokensResponseOrDict = Union[CountTokensResponse, CountTokensResponseDict]117381173911740class ComputeTokensConfig(_common.BaseModel):11741  """Optional parameters for computing tokens."""1174211743  http_options: Optional[HttpOptions] = Field(11744      default=None, description="""Used to override HTTP request options."""11745  )117461174711748class ComputeTokensConfigDict(TypedDict, total=False):11749  """Optional parameters for computing tokens."""1175011751  http_options: Optional[HttpOptionsDict]11752  """Used to override HTTP request options."""117531175411755ComputeTokensConfigOrDict = Union[ComputeTokensConfig, ComputeTokensConfigDict]117561175711758class _ComputeTokensParameters(_common.BaseModel):11759  """Parameters for computing tokens."""1176011761  model: Optional[str] = Field(11762      default=None,11763      description="""ID of the model to use. For a list of models, see `Google models11764    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",11765  )11766  contents: Optional[ContentListUnion] = Field(11767      default=None, description="""Input content."""11768  )11769  config: Optional[ComputeTokensConfig] = Field(11770      default=None,11771      description="""Optional parameters for the request.11772      """,11773  )117741177511776class _ComputeTokensParametersDict(TypedDict, total=False):11777  """Parameters for computing tokens."""1177811779  model: Optional[str]11780  """ID of the model to use. For a list of models, see `Google models11781    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""1178211783  contents: Optional[ContentListUnionDict]11784  """Input content."""1178511786  config: Optional[ComputeTokensConfigDict]11787  """Optional parameters for the request.11788      """117891179011791_ComputeTokensParametersOrDict = Union[11792    _ComputeTokensParameters, _ComputeTokensParametersDict11793]117941179511796class TokensInfo(_common.BaseModel):11797  """Tokens info with a list of tokens and the corresponding list of token ids."""1179811799  role: Optional[str] = Field(11800      default=None,11801      description="""Optional fields for the role from the corresponding Content.""",11802  )11803  token_ids: Optional[list[int]] = Field(11804      default=None, description="""A list of token ids from the input."""11805  )11806  tokens: Optional[list[bytes]] = Field(11807      default=None, description="""A list of tokens from the input."""11808  )118091181011811class TokensInfoDict(TypedDict, total=False):11812  """Tokens info with a list of tokens and the corresponding list of token ids."""1181311814  role: Optional[str]11815  """Optional fields for the role from the corresponding Content."""1181611817  token_ids: Optional[list[int]]11818  """A list of token ids from the input."""1181911820  tokens: Optional[list[bytes]]11821  """A list of tokens from the input."""118221182311824TokensInfoOrDict = Union[TokensInfo, TokensInfoDict]118251182611827class ComputeTokensResponse(_common.BaseModel):11828  """Response for computing tokens."""1182911830  sdk_http_response: Optional[HttpResponse] = Field(11831      default=None, description="""Used to retain the full HTTP response."""11832  )11833  tokens_info: Optional[list[TokensInfo]] = Field(11834      default=None,11835      description="""Lists of tokens info from the input. A ComputeTokensRequest could have multiple instances with a prompt in each instance. We also need to return lists of tokens info for the request with multiple instances.""",11836  )118371183811839class ComputeTokensResponseDict(TypedDict, total=False):11840  """Response for computing tokens."""1184111842  sdk_http_response: Optional[HttpResponseDict]11843  """Used to retain the full HTTP response."""1184411845  tokens_info: Optional[list[TokensInfoDict]]11846  """Lists of tokens info from the input. A ComputeTokensRequest could have multiple instances with a prompt in each instance. We also need to return lists of tokens info for the request with multiple instances."""118471184811849ComputeTokensResponseOrDict = Union[11850    ComputeTokensResponse, ComputeTokensResponseDict11851]118521185311854class Video(_common.BaseModel):11855  """A generated video."""1185611857  uri: Optional[str] = Field(11858      default=None, description="""Path to another storage."""11859  )11860  video_bytes: Optional[bytes] = Field(11861      default=None, description="""Video bytes."""11862  )11863  mime_type: Optional[str] = Field(11864      default=None, description="""Video encoding, for example ``video/mp4``."""11865  )1186611867  @classmethod11868  def from_file(11869      cls, *, location: str, mime_type: Optional[str] = None11870  ) -> 'Video':11871    """Loads a video from a local file.1187211873    Args:11874        location: The local path to load the video from.11875        mime_type: The MIME type of the video. If not provided, the MIME type11876          will be automatically determined.1187711878    Returns:11879        A loaded video as an `Video` object.11880    """11881    import mimetypes  # pylint: disable=g-import-not-at-top11882    import pathlib  # pylint: disable=g-import-not-at-top1188311884    video_bytes = pathlib.Path(location).read_bytes()1188511886    if not mime_type:11887      mime_type, _ = mimetypes.guess_type(location)11888    video = cls(video_bytes=video_bytes, mime_type=mime_type)11889    return video1189011891  def save(11892      self,11893      path: str,11894  ) -> None:11895    """Saves the video to a file.1189611897    Args:11898        path: Local path where to save the video.11899    """11900    import pathlib  # pylint: disable=g-import-not-at-top1190111902    if not self.video_bytes:11903      raise NotImplementedError('Saving remote videos is not supported.')1190411905    pathlib.Path(path).write_bytes(self.video_bytes)1190611907  def show(self) -> None:11908    """Shows the video.1190911910    If the video has no mime_type, it is assumed to be video/mp4.1191111912    This method only works in a notebook environment.11913    """11914    if self.uri and not self.video_bytes:11915      raise ValueError('Showing remote videos is not supported.')11916    if not self.video_bytes:11917      raise ValueError('Video has no bytes.')1191811919    mime_type = self.mime_type or 'video/mp4'1192011921    try:11922      from IPython import display as IPython_display11923    except ImportError:11924      IPython_display = None1192511926    if IPython_display:11927      IPython_display.display(11928          IPython_display.Video(11929              data=self.video_bytes, mimetype=mime_type, embed=True11930          )11931      )1193211933  def __repr__(self) -> str:11934    video_bytes = '<video_bytes>' if self.video_bytes else 'None'11935    return (11936        f'Video(uri={self.uri}, video_bytes={video_bytes},'11937        f' mime_type={self.mime_type})'11938    )119391194011941class VideoDict(TypedDict, total=False):11942  """A generated video."""1194311944  uri: Optional[str]11945  """Path to another storage."""1194611947  video_bytes: Optional[bytes]11948  """Video bytes."""1194911950  mime_type: Optional[str]11951  """Video encoding, for example ``video/mp4``."""119521195311954VideoOrDict = Union[Video, VideoDict]119551195611957class GenerateVideosSource(_common.BaseModel):11958  """A set of source input(s) for video generation."""1195911960  prompt: Optional[str] = Field(11961      default=None,11962      description="""The text prompt for generating the videos.11963      Optional if image or video is provided.""",11964  )11965  image: Optional[Image] = Field(11966      default=None,11967      description="""The input image for generating the videos.11968      Optional if prompt is provided. Not allowed if video is provided.""",11969  )11970  video: Optional[Video] = Field(11971      default=None,11972      description="""The input video for video extension use cases.11973      Optional if prompt is provided. Not allowed if image is provided.""",11974  )119751197611977class GenerateVideosSourceDict(TypedDict, total=False):11978  """A set of source input(s) for video generation."""1197911980  prompt: Optional[str]11981  """The text prompt for generating the videos.11982      Optional if image or video is provided."""1198311984  image: Optional[ImageDict]11985  """The input image for generating the videos.11986      Optional if prompt is provided. Not allowed if video is provided."""1198711988  video: Optional[VideoDict]11989  """The input video for video extension use cases.11990      Optional if prompt is provided. Not allowed if image is provided."""119911199211993GenerateVideosSourceOrDict = Union[11994    GenerateVideosSource, GenerateVideosSourceDict11995]119961199711998class VideoGenerationReferenceImage(_common.BaseModel):11999  """A reference image for video generation."""1200012001  image: Optional[Image] = Field(12002      default=None, description="""The reference image."""12003  )12004  reference_type: Optional[VideoGenerationReferenceType] = Field(12005      default=None,12006      description="""The type of the reference image, which defines how the reference12007      image will be used to generate the video.""",12008  )120091201012011class VideoGenerationReferenceImageDict(TypedDict, total=False):12012  """A reference image for video generation."""1201312014  image: Optional[ImageDict]12015  """The reference image."""1201612017  reference_type: Optional[VideoGenerationReferenceType]12018  """The type of the reference image, which defines how the reference12019      image will be used to generate the video."""120201202112022VideoGenerationReferenceImageOrDict = Union[12023    VideoGenerationReferenceImage, VideoGenerationReferenceImageDict12024]120251202612027class VideoGenerationMask(_common.BaseModel):12028  """A mask for video generation."""1202912030  image: Optional[Image] = Field(12031      default=None,12032      description="""The image mask to use for generating videos.""",12033  )12034  mask_mode: Optional[VideoGenerationMaskMode] = Field(12035      default=None,12036      description="""Describes how the mask will be used. Inpainting masks must12037      match the aspect ratio of the input video. Outpainting masks can be12038      either 9:16 or 16:9.""",12039  )120401204112042class VideoGenerationMaskDict(TypedDict, total=False):12043  """A mask for video generation."""1204412045  image: Optional[ImageDict]12046  """The image mask to use for generating videos."""1204712048  mask_mode: Optional[VideoGenerationMaskMode]12049  """Describes how the mask will be used. Inpainting masks must12050      match the aspect ratio of the input video. Outpainting masks can be12051      either 9:16 or 16:9."""120521205312054VideoGenerationMaskOrDict = Union[VideoGenerationMask, VideoGenerationMaskDict]120551205612057class WebhookConfig(_common.BaseModel):12058  """Configuration for webhook notifications.1205912060  Used to configure webhook endpoints that will receive notifications12061  when long-running operations (e.g., batch jobs, video generation) complete.12062  """1206312064  uris: Optional[list[str]] = Field(12065      default=None,12066      description="""The webhook URIs to receive notifications. If set, these12067      webhook URIs will be used instead of the registered webhooks.""",12068  )12069  user_metadata: Optional[dict[str, Any]] = Field(12070      default=None,12071      description="""User metadata that will be included in each webhook event12072      notification. Use this to attach custom key-value data to correlate12073      webhook events with your internal systems.""",12074  )120751207612077class WebhookConfigDict(TypedDict, total=False):12078  """Configuration for webhook notifications.1207912080  Used to configure webhook endpoints that will receive notifications12081  when long-running operations (e.g., batch jobs, video generation) complete.12082  """1208312084  uris: Optional[list[str]]12085  """The webhook URIs to receive notifications. If set, these12086      webhook URIs will be used instead of the registered webhooks."""1208712088  user_metadata: Optional[dict[str, Any]]12089  """User metadata that will be included in each webhook event12090      notification. Use this to attach custom key-value data to correlate12091      webhook events with your internal systems."""120921209312094WebhookConfigOrDict = Union[WebhookConfig, WebhookConfigDict]120951209612097class GenerateVideosConfig(_common.BaseModel):12098  """Configuration for generating videos."""1209912100  http_options: Optional[HttpOptions] = Field(12101      default=None, description="""Used to override HTTP request options."""12102  )12103  number_of_videos: Optional[int] = Field(12104      default=None, description="""Number of output videos."""12105  )12106  output_gcs_uri: Optional[str] = Field(12107      default=None,12108      description="""The gcs bucket where to save the generated videos.""",12109  )12110  fps: Optional[int] = Field(12111      default=None, description="""Frames per second for video generation."""12112  )12113  duration_seconds: Optional[int] = Field(12114      default=None,12115      description="""Duration of the clip for video generation in seconds.""",12116  )12117  seed: Optional[int] = Field(12118      default=None,12119      description="""The RNG seed. If RNG seed is exactly same for each request with12120      unchanged inputs, the prediction results will be consistent. Otherwise,12121      a random RNG seed will be used each time to produce a different12122      result.""",12123  )12124  aspect_ratio: Optional[str] = Field(12125      default=None,12126      description="""The aspect ratio for the generated video. 16:9 (landscape) and12127      9:16 (portrait) are supported.""",12128  )12129  resolution: Optional[str] = Field(12130      default=None,12131      description="""The resolution for the generated video. 720p and 1080p are12132      supported.""",12133  )12134  person_generation: Optional[str] = Field(12135      default=None,12136      description="""Whether allow to generate person videos, and restrict to specific12137      ages. Supported values are: dont_allow, allow_adult.""",12138  )12139  pubsub_topic: Optional[str] = Field(12140      default=None,12141      description="""The pubsub topic where to publish the video generation12142      progress.""",12143  )12144  negative_prompt: Optional[str] = Field(12145      default=None,12146      description="""Explicitly state what should not be included in the generated12147      videos.""",12148  )12149  enhance_prompt: Optional[bool] = Field(12150      default=None, description="""Whether to use the prompt rewriting logic."""12151  )12152  generate_audio: Optional[bool] = Field(12153      default=None,12154      description="""Whether to generate audio along with the video.""",12155  )12156  last_frame: Optional[Image] = Field(12157      default=None,12158      description="""Image to use as the last frame of generated videos.12159      Only supported for image to video use cases.""",12160  )12161  reference_images: Optional[list[VideoGenerationReferenceImage]] = Field(12162      default=None,12163      description="""The images to use as the references to generate the videos.12164      If this field is provided, the text prompt field must also be provided.12165      The image, video, or last_frame field are not supported. Each image must12166      be associated with a type. Veo 2 supports up to 3 asset images *or* 112167      style image.""",12168  )12169  mask: Optional[VideoGenerationMask] = Field(12170      default=None, description="""The mask to use for generating videos."""12171  )12172  compression_quality: Optional[VideoCompressionQuality] = Field(12173      default=None,12174      description="""Compression quality of the generated videos.""",12175  )12176  labels: Optional[dict[str, str]] = Field(12177      default=None,12178      description="""User specified labels to track billing usage.""",12179  )12180  webhook_config: Optional[WebhookConfig] = Field(12181      default=None,12182      description="""Webhook configuration for receiving notifications when the12183      video generation operation completes.""",12184  )12185  resize_mode: Optional[ImageResizeMode] = Field(12186      default=None,12187      description="""Resize mode of the image input for video generation.""",12188  )121891219012191class GenerateVideosConfigDict(TypedDict, total=False):12192  """Configuration for generating videos."""1219312194  http_options: Optional[HttpOptionsDict]12195  """Used to override HTTP request options."""1219612197  number_of_videos: Optional[int]12198  """Number of output videos."""1219912200  output_gcs_uri: Optional[str]12201  """The gcs bucket where to save the generated videos."""1220212203  fps: Optional[int]12204  """Frames per second for video generation."""1220512206  duration_seconds: Optional[int]12207  """Duration of the clip for video generation in seconds."""1220812209  seed: Optional[int]12210  """The RNG seed. If RNG seed is exactly same for each request with12211      unchanged inputs, the prediction results will be consistent. Otherwise,12212      a random RNG seed will be used each time to produce a different12213      result."""1221412215  aspect_ratio: Optional[str]12216  """The aspect ratio for the generated video. 16:9 (landscape) and12217      9:16 (portrait) are supported."""1221812219  resolution: Optional[str]12220  """The resolution for the generated video. 720p and 1080p are12221      supported."""1222212223  person_generation: Optional[str]12224  """Whether allow to generate person videos, and restrict to specific12225      ages. Supported values are: dont_allow, allow_adult."""1222612227  pubsub_topic: Optional[str]12228  """The pubsub topic where to publish the video generation12229      progress."""1223012231  negative_prompt: Optional[str]12232  """Explicitly state what should not be included in the generated12233      videos."""1223412235  enhance_prompt: Optional[bool]12236  """Whether to use the prompt rewriting logic."""1223712238  generate_audio: Optional[bool]12239  """Whether to generate audio along with the video."""1224012241  last_frame: Optional[ImageDict]12242  """Image to use as the last frame of generated videos.12243      Only supported for image to video use cases."""1224412245  reference_images: Optional[list[VideoGenerationReferenceImageDict]]12246  """The images to use as the references to generate the videos.12247      If this field is provided, the text prompt field must also be provided.12248      The image, video, or last_frame field are not supported. Each image must12249      be associated with a type. Veo 2 supports up to 3 asset images *or* 112250      style image."""1225112252  mask: Optional[VideoGenerationMaskDict]12253  """The mask to use for generating videos."""1225412255  compression_quality: Optional[VideoCompressionQuality]12256  """Compression quality of the generated videos."""1225712258  labels: Optional[dict[str, str]]12259  """User specified labels to track billing usage."""1226012261  webhook_config: Optional[WebhookConfigDict]12262  """Webhook configuration for receiving notifications when the12263      video generation operation completes."""1226412265  resize_mode: Optional[ImageResizeMode]12266  """Resize mode of the image input for video generation."""122671226812269GenerateVideosConfigOrDict = Union[12270    GenerateVideosConfig, GenerateVideosConfigDict12271]122721227312274class _GenerateVideosParameters(_common.BaseModel):12275  """Class that represents the parameters for generating videos."""1227612277  model: Optional[str] = Field(12278      default=None,12279      description="""ID of the model to use. For a list of models, see `Google models12280    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",12281  )12282  prompt: Optional[str] = Field(12283      default=None,12284      description="""The text prompt for generating the videos.12285      Optional if image or video is provided.""",12286  )12287  image: Optional[Image] = Field(12288      default=None,12289      description="""The input image for generating the videos.12290      Optional if prompt is provided. Not allowed if video is provided.""",12291  )12292  video: Optional[Video] = Field(12293      default=None,12294      description="""The input video for video extension use cases.12295      Optional if prompt is provided. Not allowed if image is provided.""",12296  )12297  source: Optional[GenerateVideosSource] = Field(12298      default=None,12299      description="""A set of source input(s) for video generation.""",12300  )12301  config: Optional[GenerateVideosConfig] = Field(12302      default=None, description="""Configuration for generating videos."""12303  )123041230512306class _GenerateVideosParametersDict(TypedDict, total=False):12307  """Class that represents the parameters for generating videos."""1230812309  model: Optional[str]12310  """ID of the model to use. For a list of models, see `Google models12311    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""1231212313  prompt: Optional[str]12314  """The text prompt for generating the videos.12315      Optional if image or video is provided."""1231612317  image: Optional[ImageDict]12318  """The input image for generating the videos.12319      Optional if prompt is provided. Not allowed if video is provided."""1232012321  video: Optional[VideoDict]12322  """The input video for video extension use cases.12323      Optional if prompt is provided. Not allowed if image is provided."""1232412325  source: Optional[GenerateVideosSourceDict]12326  """A set of source input(s) for video generation."""1232712328  config: Optional[GenerateVideosConfigDict]12329  """Configuration for generating videos."""123301233112332_GenerateVideosParametersOrDict = Union[12333    _GenerateVideosParameters, _GenerateVideosParametersDict12334]123351233612337class GeneratedVideo(_common.BaseModel):12338  """A generated video."""1233912340  video: Optional[Video] = Field(12341      default=None, description="""The output video"""12342  )123431234412345class GeneratedVideoDict(TypedDict, total=False):12346  """A generated video."""1234712348  video: Optional[VideoDict]12349  """The output video"""123501235112352GeneratedVideoOrDict = Union[GeneratedVideo, GeneratedVideoDict]123531235412355class GenerateVideosResponse(_common.BaseModel):12356  """Response with generated videos."""1235712358  generated_videos: Optional[list[GeneratedVideo]] = Field(12359      default=None, description="""List of the generated videos"""12360  )12361  rai_media_filtered_count: Optional[int] = Field(12362      default=None,12363      description="""Returns if any videos were filtered due to RAI policies.""",12364  )12365  rai_media_filtered_reasons: Optional[list[str]] = Field(12366      default=None, description="""Returns rai failure reasons if any."""12367  )123681236912370class GenerateVideosResponseDict(TypedDict, total=False):12371  """Response with generated videos."""1237212373  generated_videos: Optional[list[GeneratedVideoDict]]12374  """List of the generated videos"""1237512376  rai_media_filtered_count: Optional[int]12377  """Returns if any videos were filtered due to RAI policies."""1237812379  rai_media_filtered_reasons: Optional[list[str]]12380  """Returns rai failure reasons if any."""123811238212383GenerateVideosResponseOrDict = Union[12384    GenerateVideosResponse, GenerateVideosResponseDict12385]123861238712388class Operation(ABC):12389  """A long-running operation."""1239012391  name: Optional[str] = Field(12392      default=None,12393      description="""The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.""",12394  )12395  metadata: Optional[dict[str, Any]] = Field(12396      default=None,12397      description="""Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata.  Any method that returns a long-running operation should document the metadata type, if any.""",12398  )12399  done: Optional[bool] = Field(12400      default=None,12401      description="""If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.""",12402  )12403  error: Optional[dict[str, Any]] = Field(12404      default=None,12405      description="""The error result of the operation in case of failure or cancellation.""",12406  )1240712408  @classmethod12409  @abstractmethod12410  def from_api_response(12411      cls, api_response: Any, is_vertex_ai: bool = False12412  ) -> Self:12413    """Creates an Operation from an API response."""12414    pass124151241612417class GenerateVideosOperation(_common.BaseModel, Operation):12418  """A video generation operation."""1241912420  response: Optional[GenerateVideosResponse] = Field(12421      default=None, description="""The generated videos."""12422  )12423  result: Optional[GenerateVideosResponse] = Field(12424      default=None, description="""The generated videos."""12425  )1242612427  @classmethod12428  def from_api_response(12429      cls, api_response: Any, is_vertex_ai: bool = False12430  ) -> Self:12431    """Instantiates a GenerateVideosOperation from an API response."""1243212433    if is_vertex_ai:12434      response_dict = _GenerateVideosOperation_from_vertex(api_response)12435    else:12436      response_dict = _GenerateVideosOperation_from_mldev(api_response)1243712438    return cls._from_response(response=response_dict, kwargs={})124391244012441class GetTuningJobConfig(_common.BaseModel):12442  """Optional parameters for tunings.get method."""1244312444  http_options: Optional[HttpOptions] = Field(12445      default=None, description="""Used to override HTTP request options."""12446  )124471244812449class GetTuningJobConfigDict(TypedDict, total=False):12450  """Optional parameters for tunings.get method."""1245112452  http_options: Optional[HttpOptionsDict]12453  """Used to override HTTP request options."""124541245512456GetTuningJobConfigOrDict = Union[GetTuningJobConfig, GetTuningJobConfigDict]124571245812459class _GetTuningJobParameters(_common.BaseModel):12460  """Parameters for the get method."""1246112462  name: Optional[str] = Field(default=None, description="""""")12463  config: Optional[GetTuningJobConfig] = Field(12464      default=None, description="""Optional parameters for the request."""12465  )124661246712468class _GetTuningJobParametersDict(TypedDict, total=False):12469  """Parameters for the get method."""1247012471  name: Optional[str]12472  """"""1247312474  config: Optional[GetTuningJobConfigDict]12475  """Optional parameters for the request."""124761247712478_GetTuningJobParametersOrDict = Union[12479    _GetTuningJobParameters, _GetTuningJobParametersDict12480]124811248212483class TunedModelCheckpoint(_common.BaseModel):12484  """TunedModelCheckpoint for the Tuned Model of a Tuning Job."""1248512486  checkpoint_id: Optional[str] = Field(12487      default=None,12488      description="""The ID of the checkpoint.12489      """,12490  )12491  epoch: Optional[int] = Field(12492      default=None,12493      description="""The epoch of the checkpoint.12494      """,12495  )12496  step: Optional[int] = Field(12497      default=None,12498      description="""The step of the checkpoint.12499      """,12500  )12501  endpoint: Optional[str] = Field(12502      default=None,12503      description="""The Endpoint resource name that the checkpoint is deployed to.12504      Format: `projects/{project}/locations/{location}/endpoints/{endpoint}`.12505      """,12506  )125071250812509class TunedModelCheckpointDict(TypedDict, total=False):12510  """TunedModelCheckpoint for the Tuned Model of a Tuning Job."""1251112512  checkpoint_id: Optional[str]12513  """The ID of the checkpoint.12514      """1251512516  epoch: Optional[int]12517  """The epoch of the checkpoint.12518      """1251912520  step: Optional[int]12521  """The step of the checkpoint.12522      """1252312524  endpoint: Optional[str]12525  """The Endpoint resource name that the checkpoint is deployed to.12526      Format: `projects/{project}/locations/{location}/endpoints/{endpoint}`.12527      """125281252912530TunedModelCheckpointOrDict = Union[12531    TunedModelCheckpoint, TunedModelCheckpointDict12532]125331253412535class TunedModel(_common.BaseModel):12536  """TunedModel for the Tuned Model of a Tuning Job."""1253712538  model: Optional[str] = Field(12539      default=None,12540      description="""Output only. The resource name of the TunedModel.12541      Format: `projects/{project}/locations/{location}/models/{model}@{version_id}`12542      When tuning from a base model, the version_id will be 1.12543      For continuous tuning, the version id will be incremented by 1 from the12544      last version id in the parent model. E.g., `projects/{project}/locations/{location}/models/{model}@{last_version_id + 1}`12545      """,12546  )12547  endpoint: Optional[str] = Field(12548      default=None,12549      description="""Output only. A resource name of an Endpoint.12550      Format: `projects/{project}/locations/{location}/endpoints/{endpoint}`.12551      """,12552  )12553  checkpoints: Optional[list[TunedModelCheckpoint]] = Field(12554      default=None,12555      description="""The checkpoints associated with this TunedModel.12556      This field is only populated for tuning jobs that enable intermediate12557      checkpoints.""",12558  )125591256012561class TunedModelDict(TypedDict, total=False):12562  """TunedModel for the Tuned Model of a Tuning Job."""1256312564  model: Optional[str]12565  """Output only. The resource name of the TunedModel.12566      Format: `projects/{project}/locations/{location}/models/{model}@{version_id}`12567      When tuning from a base model, the version_id will be 1.12568      For continuous tuning, the version id will be incremented by 1 from the12569      last version id in the parent model. E.g., `projects/{project}/locations/{location}/models/{model}@{last_version_id + 1}`12570      """1257112572  endpoint: Optional[str]12573  """Output only. A resource name of an Endpoint.12574      Format: `projects/{project}/locations/{location}/endpoints/{endpoint}`.12575      """1257612577  checkpoints: Optional[list[TunedModelCheckpointDict]]12578  """The checkpoints associated with this TunedModel.12579      This field is only populated for tuning jobs that enable intermediate12580      checkpoints."""125811258212583TunedModelOrDict = Union[TunedModel, TunedModelDict]125841258512586class SupervisedHyperParameters(_common.BaseModel):12587  """Hyperparameters for SFT. This data type is not supported in Gemini API."""1258812589  adapter_size: Optional[AdapterSize] = Field(12590      default=None, description="""Optional. Adapter size for tuning."""12591  )12592  batch_size: Optional[int] = Field(12593      default=None,12594      description="""Optional. Batch size for tuning. This feature is only available for open source models.""",12595  )12596  epoch_count: Optional[int] = Field(12597      default=None,12598      description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""",12599  )12600  learning_rate: Optional[float] = Field(12601      default=None,12602      description="""Optional. Learning rate for tuning. Mutually exclusive with `learning_rate_multiplier`. This feature is only available for open source models.""",12603  )12604  learning_rate_multiplier: Optional[float] = Field(12605      default=None,12606      description="""Optional. Multiplier for adjusting the default learning rate. Mutually exclusive with `learning_rate`. This feature is only available for 1P models.""",12607  )126081260912610class SupervisedHyperParametersDict(TypedDict, total=False):12611  """Hyperparameters for SFT. This data type is not supported in Gemini API."""1261212613  adapter_size: Optional[AdapterSize]12614  """Optional. Adapter size for tuning."""1261512616  batch_size: Optional[int]12617  """Optional. Batch size for tuning. This feature is only available for open source models."""1261812619  epoch_count: Optional[int]12620  """Optional. Number of complete passes the model makes over the entire training dataset during training."""1262112622  learning_rate: Optional[float]12623  """Optional. Learning rate for tuning. Mutually exclusive with `learning_rate_multiplier`. This feature is only available for open source models."""1262412625  learning_rate_multiplier: Optional[float]12626  """Optional. Multiplier for adjusting the default learning rate. Mutually exclusive with `learning_rate`. This feature is only available for 1P models."""126271262812629SupervisedHyperParametersOrDict = Union[12630    SupervisedHyperParameters, SupervisedHyperParametersDict12631]126321263312634class SupervisedTuningSpec(_common.BaseModel):12635  """Supervised tuning spec for tuning."""1263612637  export_last_checkpoint_only: Optional[bool] = Field(12638      default=None,12639      description="""Optional. If set to true, disable intermediate checkpoints for SFT and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints for SFT. Default is false.""",12640  )12641  hyper_parameters: Optional[SupervisedHyperParameters] = Field(12642      default=None, description="""Optional. Hyperparameters for SFT."""12643  )12644  training_dataset_uri: Optional[str] = Field(12645      default=None,12646      description="""Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""",12647  )12648  tuning_mode: Optional[TuningMode] = Field(12649      default=None, description="""Tuning mode."""12650  )12651  validation_dataset_uri: Optional[str] = Field(12652      default=None,12653      description="""Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""",12654  )126551265612657class SupervisedTuningSpecDict(TypedDict, total=False):12658  """Supervised tuning spec for tuning."""1265912660  export_last_checkpoint_only: Optional[bool]12661  """Optional. If set to true, disable intermediate checkpoints for SFT and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints for SFT. Default is false."""1266212663  hyper_parameters: Optional[SupervisedHyperParametersDict]12664  """Optional. Hyperparameters for SFT."""1266512666  training_dataset_uri: Optional[str]12667  """Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset."""1266812669  tuning_mode: Optional[TuningMode]12670  """Tuning mode."""1267112672  validation_dataset_uri: Optional[str]12673  """Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset."""126741267512676SupervisedTuningSpecOrDict = Union[12677    SupervisedTuningSpec, SupervisedTuningSpecDict12678]126791268012681class PreferenceOptimizationHyperParameters(_common.BaseModel):12682  """Hyperparameters for Preference Optimization.1268312684  This data type is not supported in Gemini API.12685  """1268612687  adapter_size: Optional[AdapterSize] = Field(12688      default=None,12689      description="""Optional. Adapter size for preference optimization.""",12690  )12691  beta: Optional[float] = Field(12692      default=None,12693      description="""Optional. Weight for KL Divergence regularization.""",12694  )12695  epoch_count: Optional[int] = Field(12696      default=None,12697      description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""",12698  )12699  learning_rate_multiplier: Optional[float] = Field(12700      default=None,12701      description="""Optional. Multiplier for adjusting the default learning rate.""",12702  )127031270412705class PreferenceOptimizationHyperParametersDict(TypedDict, total=False):12706  """Hyperparameters for Preference Optimization.1270712708  This data type is not supported in Gemini API.12709  """1271012711  adapter_size: Optional[AdapterSize]12712  """Optional. Adapter size for preference optimization."""1271312714  beta: Optional[float]12715  """Optional. Weight for KL Divergence regularization."""1271612717  epoch_count: Optional[int]12718  """Optional. Number of complete passes the model makes over the entire training dataset during training."""1271912720  learning_rate_multiplier: Optional[float]12721  """Optional. Multiplier for adjusting the default learning rate."""127221272312724PreferenceOptimizationHyperParametersOrDict = Union[12725    PreferenceOptimizationHyperParameters,12726    PreferenceOptimizationHyperParametersDict,12727]127281272912730class PreferenceOptimizationSpec(_common.BaseModel):12731  """Preference optimization tuning spec for tuning."""1273212733  export_last_checkpoint_only: Optional[bool] = Field(12734      default=None,12735      description="""Optional. If set to true, disable intermediate checkpoints for Preference Optimization and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints for Preference Optimization. Default is false.""",12736  )12737  hyper_parameters: Optional[PreferenceOptimizationHyperParameters] = Field(12738      default=None,12739      description="""Optional. Hyperparameters for Preference Optimization.""",12740  )12741  training_dataset_uri: Optional[str] = Field(12742      default=None,12743      description="""Required. Cloud Storage path to file containing training dataset for preference optimization tuning. The dataset must be formatted as a JSONL file.""",12744  )12745  validation_dataset_uri: Optional[str] = Field(12746      default=None,12747      description="""Optional. Cloud Storage path to file containing validation dataset for preference optimization tuning. The dataset must be formatted as a JSONL file.""",12748  )127491275012751class PreferenceOptimizationSpecDict(TypedDict, total=False):12752  """Preference optimization tuning spec for tuning."""1275312754  export_last_checkpoint_only: Optional[bool]12755  """Optional. If set to true, disable intermediate checkpoints for Preference Optimization and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints for Preference Optimization. Default is false."""1275612757  hyper_parameters: Optional[PreferenceOptimizationHyperParametersDict]12758  """Optional. Hyperparameters for Preference Optimization."""1275912760  training_dataset_uri: Optional[str]12761  """Required. Cloud Storage path to file containing training dataset for preference optimization tuning. The dataset must be formatted as a JSONL file."""1276212763  validation_dataset_uri: Optional[str]12764  """Optional. Cloud Storage path to file containing validation dataset for preference optimization tuning. The dataset must be formatted as a JSONL file."""127651276612767PreferenceOptimizationSpecOrDict = Union[12768    PreferenceOptimizationSpec, PreferenceOptimizationSpecDict12769]127701277112772class DistillationHyperParameters(_common.BaseModel):12773  """Distillation hyperparameters for tuning."""1277412775  adapter_size: Optional[AdapterSize] = Field(12776      default=None,12777      description="""The size of the adapter. Can be 'small', 'medium', or 'large'.""",12778  )12779  epoch_count: Optional[int] = Field(12780      default=None,12781      description="""Number of complete passes the model makes over the entire training dataset12782      during training.""",12783  )12784  learning_rate_multiplier: Optional[float] = Field(12785      default=None,12786      description="""Multiplier for adjusting the default learning rate.""",12787  )12788  generation_config: Optional[GenerationConfig] = Field(12789      default=None,12790      description="""Generation config for Distillation teacher model sampling. Only the12791      following fields are supported for distillation teacher samplings:12792      - temperature12793      - top_p12794      - top_k12795      - candidate_count12796      - thinking_config""",12797  )12798  learning_rate: Optional[float] = Field(12799      default=None, description="""The learning rate for distillation tuning."""12800  )12801  batch_size: Optional[int] = Field(12802      default=None,12803      description="""Batch size for tuning. This feature is only available for open12804      source models.""",12805  )128061280712808class DistillationHyperParametersDict(TypedDict, total=False):12809  """Distillation hyperparameters for tuning."""1281012811  adapter_size: Optional[AdapterSize]12812  """The size of the adapter. Can be 'small', 'medium', or 'large'."""1281312814  epoch_count: Optional[int]12815  """Number of complete passes the model makes over the entire training dataset12816      during training."""1281712818  learning_rate_multiplier: Optional[float]12819  """Multiplier for adjusting the default learning rate."""1282012821  generation_config: Optional[GenerationConfigDict]12822  """Generation config for Distillation teacher model sampling. Only the12823      following fields are supported for distillation teacher samplings:12824      - temperature12825      - top_p12826      - top_k12827      - candidate_count12828      - thinking_config"""1282912830  learning_rate: Optional[float]12831  """The learning rate for distillation tuning."""1283212833  batch_size: Optional[int]12834  """Batch size for tuning. This feature is only available for open12835      source models."""128361283712838DistillationHyperParametersOrDict = Union[12839    DistillationHyperParameters, DistillationHyperParametersDict12840]128411284212843class DistillationSamplingSpec(_common.BaseModel):12844  """Distillation sampling spec for tuning."""1284512846  base_teacher_model: Optional[str] = Field(12847      default=None,12848      description="""The base teacher model that is being distilled. See [Supported12849       models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).""",12850  )12851  tuned_teacher_model_source: Optional[str] = Field(12852      default=None,12853      description="""The resource name of the Tuned teacher model. Format:12854      `projects/{project}/locations/{location}/models/{model}`.""",12855  )12856  validation_dataset_uri: Optional[str] = Field(12857      default=None,12858      description="""Cloud Storage path to file containing validation dataset for distillation.12859     The dataset must be formatted as a JSONL file.""",12860  )12861  prompt_dataset_uri: Optional[str] = Field(12862      default=None,12863      description="""Cloud Storage path to file containing prompt dataset for distillation.12864      The dataset must be formatted as a JSONL file.""",12865  )12866  hyperparameters: Optional[DistillationHyperParameters] = Field(12867      default=None, description="""Hyperparameters for distillation tuning."""12868  )128691287012871class DistillationSamplingSpecDict(TypedDict, total=False):12872  """Distillation sampling spec for tuning."""1287312874  base_teacher_model: Optional[str]12875  """The base teacher model that is being distilled. See [Supported12876       models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models)."""1287712878  tuned_teacher_model_source: Optional[str]12879  """The resource name of the Tuned teacher model. Format:12880      `projects/{project}/locations/{location}/models/{model}`."""1288112882  validation_dataset_uri: Optional[str]12883  """Cloud Storage path to file containing validation dataset for distillation.12884     The dataset must be formatted as a JSONL file."""1288512886  prompt_dataset_uri: Optional[str]12887  """Cloud Storage path to file containing prompt dataset for distillation.12888      The dataset must be formatted as a JSONL file."""1288912890  hyperparameters: Optional[DistillationHyperParametersDict]12891  """Hyperparameters for distillation tuning."""128921289312894DistillationSamplingSpecOrDict = Union[12895    DistillationSamplingSpec, DistillationSamplingSpecDict12896]128971289812899class DistillationSpec(_common.BaseModel):12900  """Distillation tuning spec for tuning."""1290112902  prompt_dataset_uri: Optional[str] = Field(12903      default=None,12904      description="""Optional. Cloud Storage path to file containing prompt dataset for distillation. The dataset must be formatted as a JSONL file.""",12905  )12906  base_teacher_model: Optional[str] = Field(12907      default=None,12908      description="""The base teacher model that is being distilled. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).""",12909  )12910  hyper_parameters: Optional[DistillationHyperParameters] = Field(12911      default=None,12912      description="""Optional. Hyperparameters for Distillation.""",12913  )12914  pipeline_root_directory: Optional[str] = Field(12915      default=None,12916      description="""Deprecated. A path in a Cloud Storage bucket, which will be treated as the root output directory of the distillation pipeline. It is used by the system to generate the paths of output artifacts.""",12917  )12918  student_model: Optional[str] = Field(12919      default=None,12920      description="""The student model that is being tuned, e.g., "google/gemma-2b-1.1-it". Deprecated. Use base_model instead.""",12921  )12922  training_dataset_uri: Optional[str] = Field(12923      default=None,12924      description="""Deprecated. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""",12925  )12926  tuned_teacher_model_source: Optional[str] = Field(12927      default=None,12928      description="""The resource name of the Tuned teacher model. Format: `projects/{project}/locations/{location}/models/{model}`.""",12929  )12930  validation_dataset_uri: Optional[str] = Field(12931      default=None,12932      description="""Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""",12933  )12934  tuning_mode: Optional[TuningMode] = Field(12935      default=None,12936      description="""Optional. Specifies the tuning mode for distillation (sft part). This feature is only available for open source models.""",12937  )129381293912940class DistillationSpecDict(TypedDict, total=False):12941  """Distillation tuning spec for tuning."""1294212943  prompt_dataset_uri: Optional[str]12944  """Optional. Cloud Storage path to file containing prompt dataset for distillation. The dataset must be formatted as a JSONL file."""1294512946  base_teacher_model: Optional[str]12947  """The base teacher model that is being distilled. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models)."""1294812949  hyper_parameters: Optional[DistillationHyperParametersDict]12950  """Optional. Hyperparameters for Distillation."""1295112952  pipeline_root_directory: Optional[str]12953  """Deprecated. A path in a Cloud Storage bucket, which will be treated as the root output directory of the distillation pipeline. It is used by the system to generate the paths of output artifacts."""1295412955  student_model: Optional[str]12956  """The student model that is being tuned, e.g., "google/gemma-2b-1.1-it". Deprecated. Use base_model instead."""1295712958  training_dataset_uri: Optional[str]12959  """Deprecated. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file."""1296012961  tuned_teacher_model_source: Optional[str]12962  """The resource name of the Tuned teacher model. Format: `projects/{project}/locations/{location}/models/{model}`."""1296312964  validation_dataset_uri: Optional[str]12965  """Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file."""1296612967  tuning_mode: Optional[TuningMode]12968  """Optional. Specifies the tuning mode for distillation (sft part). This feature is only available for open source models."""129691297012971DistillationSpecOrDict = Union[DistillationSpec, DistillationSpecDict]129721297312974class AutoraterConfig(_common.BaseModel):12975  """Autorater config used for evaluation."""1297612977  sampling_count: Optional[int] = Field(12978      default=None,12979      description="""Number of samples for each instance in the dataset.12980  If not specified, the default is 4. Minimum value is 1, maximum value12981  is 32.""",12982  )12983  flip_enabled: Optional[bool] = Field(12984      default=None,12985      description="""Optional. Default is true. Whether to flip the candidate and baseline12986  responses. This is only applicable to the pairwise metric. If enabled, also12987  provide PairwiseMetricSpec.candidate_response_field_name and12988  PairwiseMetricSpec.baseline_response_field_name. When rendering12989  PairwiseMetricSpec.metric_prompt_template, the candidate and baseline12990  fields will be flipped for half of the samples to reduce bias.""",12991  )12992  autorater_model: Optional[str] = Field(12993      default=None,12994      description="""The fully qualified name of the publisher model or tuned autorater12995  endpoint to use.1299612997  Publisher model format:12998  `projects/{project}/locations/{location}/publishers/{publisher}/models/{model}`1299913000  Tuned model endpoint format:13001  `projects/{project}/locations/{location}/endpoints/{endpoint}`""",13002  )13003  generation_config: Optional[GenerationConfig] = Field(13004      default=None,13005      description="""Configuration options for model generation and outputs.""",13006  )130071300813009class AutoraterConfigDict(TypedDict, total=False):13010  """Autorater config used for evaluation."""1301113012  sampling_count: Optional[int]13013  """Number of samples for each instance in the dataset.13014  If not specified, the default is 4. Minimum value is 1, maximum value13015  is 32."""1301613017  flip_enabled: Optional[bool]13018  """Optional. Default is true. Whether to flip the candidate and baseline13019  responses. This is only applicable to the pairwise metric. If enabled, also13020  provide PairwiseMetricSpec.candidate_response_field_name and13021  PairwiseMetricSpec.baseline_response_field_name. When rendering13022  PairwiseMetricSpec.metric_prompt_template, the candidate and baseline13023  fields will be flipped for half of the samples to reduce bias."""1302413025  autorater_model: Optional[str]13026  """The fully qualified name of the publisher model or tuned autorater13027  endpoint to use.1302813029  Publisher model format:13030  `projects/{project}/locations/{location}/publishers/{publisher}/models/{model}`1303113032  Tuned model endpoint format:13033  `projects/{project}/locations/{location}/endpoints/{endpoint}`"""1303413035  generation_config: Optional[GenerationConfigDict]13036  """Configuration options for model generation and outputs."""130371303813039AutoraterConfigOrDict = Union[AutoraterConfig, AutoraterConfigDict]130401304113042class ReinforcementTuningParseResponseConfig(_common.BaseModel):13043  """Defines how to parse sample response config for reinforcement tuning.1304413045  The parsed response (i.e., substring) will be passed to the reward functions.13046  For example, the input prompt might be: > "Perform step-by-step thoughts first13047  to problem A, finally output answer in the <ans> </ans> block." The sample13048  response from the model under tuning might look like: > "<ans>Yes</ans>" Here,13049  users can define the following parse config: ``` { "parseType":13050  "REGEX_EXTRACT", "regexExtractExpression": ".*(.*?)" } ``` The resulting13051  parsed response would be `"Yes"` and will be passed to the reward functions13052  for evaluating rewards. This data type is not supported in Gemini API.13053  """1305413055  parse_type: Optional[ResponseParseType] = Field(13056      default=None,13057      description="""Defines the type for parsing sample response.""",13058  )13059  regex_extract_expression: Optional[str] = Field(13060      default=None,13061      description="""Defines the regex for extracting the important part of sample response. This field is only used when parse_type is ResponseParseType.REGEX_EXTRACT.""",13062  )130631306413065class ReinforcementTuningParseResponseConfigDict(TypedDict, total=False):13066  """Defines how to parse sample response config for reinforcement tuning.1306713068  The parsed response (i.e., substring) will be passed to the reward functions.13069  For example, the input prompt might be: > "Perform step-by-step thoughts first13070  to problem A, finally output answer in the <ans> </ans> block." The sample13071  response from the model under tuning might look like: > "<ans>Yes</ans>" Here,13072  users can define the following parse config: ``` { "parseType":13073  "REGEX_EXTRACT", "regexExtractExpression": ".*(.*?)" } ``` The resulting13074  parsed response would be `"Yes"` and will be passed to the reward functions13075  for evaluating rewards. This data type is not supported in Gemini API.13076  """1307713078  parse_type: Optional[ResponseParseType]13079  """Defines the type for parsing sample response."""1308013081  regex_extract_expression: Optional[str]13082  """Defines the regex for extracting the important part of sample response. This field is only used when parse_type is ResponseParseType.REGEX_EXTRACT."""130831308413085ReinforcementTuningParseResponseConfigOrDict = Union[13086    ReinforcementTuningParseResponseConfig,13087    ReinforcementTuningParseResponseConfigDict,13088]130891309013091class ReinforcementTuningAutoraterScorerParsedResponseConversionScorer(13092    _common.BaseModel13093):13094  """Scores responses by directly converting the parsed autorater response to a float reward.1309513096  Note: Reward is clipped to be within `[-1, 1]`, i.e., `reward =13097  max(min(reward, 1.0), -1.0)`. This data type is not supported in Gemini API.13098  """1309913100  pass131011310213103class ReinforcementTuningAutoraterScorerParsedResponseConversionScorerDict(13104    TypedDict, total=False13105):13106  """Scores responses by directly converting the parsed autorater response to a float reward.1310713108  Note: Reward is clipped to be within `[-1, 1]`, i.e., `reward =13109  max(min(reward, 1.0), -1.0)`. This data type is not supported in Gemini API.13110  """1311113112  pass131131311413115ReinforcementTuningAutoraterScorerParsedResponseConversionScorerOrDict = Union[13116    ReinforcementTuningAutoraterScorerParsedResponseConversionScorer,13117    ReinforcementTuningAutoraterScorerParsedResponseConversionScorerDict,13118]131191312013121class ReinforcementTuningAutoraterScorerExactMatchScorer(_common.BaseModel):13122  """Scores autorater responses by using exact string match reward scorer.1312313124  This data type is not supported in Gemini API.13125  """1312613127  correct_answer_reward: Optional[float] = Field(13128      default=None,13129      description="""Assigns this reward score if the parsed response string equals the expression.""",13130  )13131  wrong_answer_reward: Optional[float] = Field(13132      default=None,13133      description="""Assigns this reward score if the parsed reward value does not equal the expression.""",13134  )13135  expression: Optional[str] = Field(13136      default=None,13137      description="""The string expression to match against for scoring. This field supports placeholders in the format of {{references.key}} that will be replaced before matching. Regex is not supported for this expression. For example, users can define an ExactMatchScorer as follows: { "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": "{{references.concise_answer}}" } When evaluating the reward for each parsed autorater response, if the prompt references in the training/validation dataset has the following fields: ``` { "example": ..., "references": { "concise_ansser": "Yes", "verbose_answer": "The answer is Yes" } } ``` The above ExactMatchScorer will be replaced as follows for scoring: ``` { "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": "Yes" } ``` If the *parsed* autorater response is equal to the string `"Yes"`, then the reward is `1.0`, otherwise the reward is `-1.0`.""",13138  )131391314013141class ReinforcementTuningAutoraterScorerExactMatchScorerDict(13142    TypedDict, total=False13143):13144  """Scores autorater responses by using exact string match reward scorer.1314513146  This data type is not supported in Gemini API.13147  """1314813149  correct_answer_reward: Optional[float]13150  """Assigns this reward score if the parsed response string equals the expression."""1315113152  wrong_answer_reward: Optional[float]13153  """Assigns this reward score if the parsed reward value does not equal the expression."""1315413155  expression: Optional[str]13156  """The string expression to match against for scoring. This field supports placeholders in the format of {{references.key}} that will be replaced before matching. Regex is not supported for this expression. For example, users can define an ExactMatchScorer as follows: { "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": "{{references.concise_answer}}" } When evaluating the reward for each parsed autorater response, if the prompt references in the training/validation dataset has the following fields: ``` { "example": ..., "references": { "concise_ansser": "Yes", "verbose_answer": "The answer is Yes" } } ``` The above ExactMatchScorer will be replaced as follows for scoring: ``` { "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": "Yes" } ``` If the *parsed* autorater response is equal to the string `"Yes"`, then the reward is `1.0`, otherwise the reward is `-1.0`."""131571315813159ReinforcementTuningAutoraterScorerExactMatchScorerOrDict = Union[13160    ReinforcementTuningAutoraterScorerExactMatchScorer,13161    ReinforcementTuningAutoraterScorerExactMatchScorerDict,13162]131631316413165class ReinforcementTuningAutoraterScorer(_common.BaseModel):13166  """Reinforcement tuning autorater scorer."""1316713168  autorater_config: Optional[AutoraterConfig] = Field(13169      default=None, description="""Autorater config for evaluation."""13170  )13171  autorater_prompt: Optional[str] = Field(13172      default=None,13173      description="""The prompt for an autorater to scorer the parsed sample response. This field supports the following placeholders that will be replaced before scoring: - {{prompt}} - {{response}} - {{system_instruction}} - {{references.key}} """,13174  )13175  autorater_response_parse_config: Optional[13176      ReinforcementTuningParseResponseConfig13177  ] = Field(13178      default=None,13179      description="""Parses autorater returned response for scoring. For example, if the autorater response has reward stored in the `2.0` block, defining a parsing response config using regex `".*(.*?)"` will return a score `"2.0"`.""",13180  )13181  parsed_response_conversion_scorer: Optional[13182      ReinforcementTuningAutoraterScorerParsedResponseConversionScorer13183  ] = Field(13184      default=None,13185      description="""Scores autorater responses by directly converting parsed autorater response to a float reward. Note: Reward is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`.""",13186  )13187  exact_match_scorer: Optional[13188      ReinforcementTuningAutoraterScorerExactMatchScorer13189  ] = Field(13190      default=None,13191      description="""Scores autorater responses by using string match reward scorer.""",13192  )131931319413195class ReinforcementTuningAutoraterScorerDict(TypedDict, total=False):13196  """Reinforcement tuning autorater scorer."""1319713198  autorater_config: Optional[AutoraterConfigDict]13199  """Autorater config for evaluation."""1320013201  autorater_prompt: Optional[str]13202  """The prompt for an autorater to scorer the parsed sample response. This field supports the following placeholders that will be replaced before scoring: - {{prompt}} - {{response}} - {{system_instruction}} - {{references.key}} """1320313204  autorater_response_parse_config: Optional[13205      ReinforcementTuningParseResponseConfigDict13206  ]13207  """Parses autorater returned response for scoring. For example, if the autorater response has reward stored in the `2.0` block, defining a parsing response config using regex `".*(.*?)"` will return a score `"2.0"`."""1320813209  parsed_response_conversion_scorer: Optional[13210      ReinforcementTuningAutoraterScorerParsedResponseConversionScorerDict13211  ]13212  """Scores autorater responses by directly converting parsed autorater response to a float reward. Note: Reward is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`."""1321313214  exact_match_scorer: Optional[13215      ReinforcementTuningAutoraterScorerExactMatchScorerDict13216  ]13217  """Scores autorater responses by using string match reward scorer."""132181321913220ReinforcementTuningAutoraterScorerOrDict = Union[13221    ReinforcementTuningAutoraterScorer, ReinforcementTuningAutoraterScorerDict13222]132231322413225class ReinforcementTuningCodeExecutionRewardScorer(_common.BaseModel):13226  """ReinforcementTuningCodeExecutionRewardScorer allows users to implement a function to evaluate rewards for the sample response.1322713228  The function signature is as follows: ``` def evaluate(example: dict[str,13229  Any], response: dict[str, Any]) -> float: ... ``` `example` is a13230  ReinforcementTuningExample in ProtoJSON format, (i.e., the format is the same13231  as as one line in the training/validation dataset except that the keys must be13232  in camel case). System instructions (i.e., `example.get("systemInstruction")`)13233  and references (i.e., `example.get("references")`) are also included in the13234  `example` provided that they are set in the training/validation dataset.13235  `response` is a Content in ProtoJSON format (i.e., keys must be in camel13236  case), which is the same as the Online Prediction response for Gemini models.13237  Note: Reward output by the `evaluate` function is clipped to be within `[-1,13238  1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`. This data type is not13239  supported in Gemini API.13240  """1324113242  python_code_snippet: Optional[str] = Field(13243      default=None,13244      description="""The python code snippet as a string for evaluating rewards. The following is an example python code snippet that returns a reward `1.0` for a parsed response matching the user-provided reference answer in per prompt references map. ``` def evaluate(example, response) -> float: response_str = response.get("parts", [])0 references = example.get("references", {}) if response_str == references.get("concise_answer"): return 1.0 return -1.0 ``` Note: Reward output by the evaluate function is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`.""",13245  )132461324713248class ReinforcementTuningCodeExecutionRewardScorerDict(TypedDict, total=False):13249  """ReinforcementTuningCodeExecutionRewardScorer allows users to implement a function to evaluate rewards for the sample response.1325013251  The function signature is as follows: ``` def evaluate(example: dict[str,13252  Any], response: dict[str, Any]) -> float: ... ``` `example` is a13253  ReinforcementTuningExample in ProtoJSON format, (i.e., the format is the same13254  as as one line in the training/validation dataset except that the keys must be13255  in camel case). System instructions (i.e., `example.get("systemInstruction")`)13256  and references (i.e., `example.get("references")`) are also included in the13257  `example` provided that they are set in the training/validation dataset.13258  `response` is a Content in ProtoJSON format (i.e., keys must be in camel13259  case), which is the same as the Online Prediction response for Gemini models.13260  Note: Reward output by the `evaluate` function is clipped to be within `[-1,13261  1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`. This data type is not13262  supported in Gemini API.13263  """1326413265  python_code_snippet: Optional[str]13266  """The python code snippet as a string for evaluating rewards. The following is an example python code snippet that returns a reward `1.0` for a parsed response matching the user-provided reference answer in per prompt references map. ``` def evaluate(example, response) -> float: response_str = response.get("parts", [])0 references = example.get("references", {}) if response_str == references.get("concise_answer"): return 1.0 return -1.0 ``` Note: Reward output by the evaluate function is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`."""132671326813269ReinforcementTuningCodeExecutionRewardScorerOrDict = Union[13270    ReinforcementTuningCodeExecutionRewardScorer,13271    ReinforcementTuningCodeExecutionRewardScorerDict,13272]132731327413275class ReinforcementTuningStringMatchRewardScorerStringMatchExpression(13276    _common.BaseModel13277):13278  """Evaluates parsed response using match type against the expression.1327913280  Returns `true` if `MatchOperation(target, expression)` evaluates to `true`,13281  and `false` otherwise. This data type is not supported in Gemini API.13282  """1328313284  match_operation: Optional[MatchOperation] = Field(13285      default=None,13286      description="""Match operation to use for evaluating rewards.""",13287  )13288  expression: Optional[str] = Field(13289      default=None,13290      description="""A string or a regular expression to match against for evaluating rewards. Users can also provide a references map of `{key: value}` whose `value` will be used to replace the placeholder {{references.key}} in the expression. For example, if the following `references` are defined in the training / validation dataset: ``` { "systemInstruction": ..., "contents": ..., "references": { "concise_answer": "Yes", "verbose_answer": "The answer is Yes" } } ``` and if users define the following StringMatchExpression: { "matchOperation": "REGEX_CONTAINS", "expression": ".*{{references.concise_answer}}.*" } On evaluating the reward for each sample response, this StringMatchExpression will be substituted as: ``` { "matchOperation": "REGEX_CONTAINS", "expression": ".*Yes.*" } ```""",13291  )132921329313294class ReinforcementTuningStringMatchRewardScorerStringMatchExpressionDict(13295    TypedDict, total=False13296):13297  """Evaluates parsed response using match type against the expression.1329813299  Returns `true` if `MatchOperation(target, expression)` evaluates to `true`,13300  and `false` otherwise. This data type is not supported in Gemini API.13301  """1330213303  match_operation: Optional[MatchOperation]13304  """Match operation to use for evaluating rewards."""1330513306  expression: Optional[str]13307  """A string or a regular expression to match against for evaluating rewards. Users can also provide a references map of `{key: value}` whose `value` will be used to replace the placeholder {{references.key}} in the expression. For example, if the following `references` are defined in the training / validation dataset: ``` { "systemInstruction": ..., "contents": ..., "references": { "concise_answer": "Yes", "verbose_answer": "The answer is Yes" } } ``` and if users define the following StringMatchExpression: { "matchOperation": "REGEX_CONTAINS", "expression": ".*{{references.concise_answer}}.*" } On evaluating the reward for each sample response, this StringMatchExpression will be substituted as: ``` { "matchOperation": "REGEX_CONTAINS", "expression": ".*Yes.*" } ```"""133081330913310ReinforcementTuningStringMatchRewardScorerStringMatchExpressionOrDict = Union[13311    ReinforcementTuningStringMatchRewardScorerStringMatchExpression,13312    ReinforcementTuningStringMatchRewardScorerStringMatchExpressionDict,13313]133141331513316class ReinforcementTuningStringMatchRewardScorerJsonMatchExpression(13317    _common.BaseModel13318):13319  """JsonMatchExpression supports converting the parsed responses to JSON format, finding the value in the JSON response that matches the key_name in the first level, and performing StringMatchExpression operation on the matched JSON value.1332013321  This data type is not supported in Gemini API.13322  """1332313324  key_name: Optional[str] = Field(13325      default=None,13326      description="""The key name to find the value in the parsed response that's in JSON format. Only first-level key matching is supported.""",13327  )13328  value_string_match_expression: Optional[13329      ReinforcementTuningStringMatchRewardScorerStringMatchExpression13330  ] = Field(13331      default=None,13332      description="""String match expression to match against the extracted value from the JSON representation of the parsed response.""",13333  )133341333513336class ReinforcementTuningStringMatchRewardScorerJsonMatchExpressionDict(13337    TypedDict, total=False13338):13339  """JsonMatchExpression supports converting the parsed responses to JSON format, finding the value in the JSON response that matches the key_name in the first level, and performing StringMatchExpression operation on the matched JSON value.1334013341  This data type is not supported in Gemini API.13342  """1334313344  key_name: Optional[str]13345  """The key name to find the value in the parsed response that's in JSON format. Only first-level key matching is supported."""1334613347  value_string_match_expression: Optional[13348      ReinforcementTuningStringMatchRewardScorerStringMatchExpressionDict13349  ]13350  """String match expression to match against the extracted value from the JSON representation of the parsed response."""133511335213353ReinforcementTuningStringMatchRewardScorerJsonMatchExpressionOrDict = Union[13354    ReinforcementTuningStringMatchRewardScorerJsonMatchExpression,13355    ReinforcementTuningStringMatchRewardScorerJsonMatchExpressionDict,13356]133571335813359class ReinforcementTuningStringMatchRewardScorer(_common.BaseModel):13360  """ReinforcementTuningStringMatchRewardScorer is used to score parsed responses for string matching use cases.1336113362  For example, for math problems, users can use string match scorer to check if13363  the correct exact answer is generated. Note: Reward returned by the string13364  match reward function is clipped to be within `[-1, 1]` if wrongAnswerReward13365  or correctAnswerReward are beyond the range, i.e., `reward = max(min(reward,13366  1.0), -1.0)`. This data type is not supported in Gemini API.13367  """1336813369  wrong_answer_reward: Optional[float] = Field(13370      default=None,13371      description="""Wrong answer reward is returned if the parsed response is evaluated as `false`. All wrong answers get the same reward.""",13372  )13373  correct_answer_reward: Optional[float] = Field(13374      default=None,13375      description="""Correct answer rewawrd is returned if the parsed response is evaluated as `true`. All correct answers get the same reward.""",13376  )13377  string_match_expression: Optional[13378      ReinforcementTuningStringMatchRewardScorerStringMatchExpression13379  ] = Field(13380      default=None,13381      description="""Uses string match expression to evaluate parsed response.""",13382  )13383  json_match_expression: Optional[13384      ReinforcementTuningStringMatchRewardScorerJsonMatchExpression13385  ] = Field(13386      default=None,13387      description="""Uses json match expression to evaluate parsed response.""",13388  )133891339013391class ReinforcementTuningStringMatchRewardScorerDict(TypedDict, total=False):13392  """ReinforcementTuningStringMatchRewardScorer is used to score parsed responses for string matching use cases.1339313394  For example, for math problems, users can use string match scorer to check if13395  the correct exact answer is generated. Note: Reward returned by the string13396  match reward function is clipped to be within `[-1, 1]` if wrongAnswerReward13397  or correctAnswerReward are beyond the range, i.e., `reward = max(min(reward,13398  1.0), -1.0)`. This data type is not supported in Gemini API.13399  """1340013401  wrong_answer_reward: Optional[float]13402  """Wrong answer reward is returned if the parsed response is evaluated as `false`. All wrong answers get the same reward."""1340313404  correct_answer_reward: Optional[float]13405  """Correct answer rewawrd is returned if the parsed response is evaluated as `true`. All correct answers get the same reward."""1340613407  string_match_expression: Optional[13408      ReinforcementTuningStringMatchRewardScorerStringMatchExpressionDict13409  ]13410  """Uses string match expression to evaluate parsed response."""1341113412  json_match_expression: Optional[13413      ReinforcementTuningStringMatchRewardScorerJsonMatchExpressionDict13414  ]13415  """Uses json match expression to evaluate parsed response."""134161341713418ReinforcementTuningStringMatchRewardScorerOrDict = Union[13419    ReinforcementTuningStringMatchRewardScorer,13420    ReinforcementTuningStringMatchRewardScorerDict,13421]134221342313424class ReinforcementTuningCloudRunRewardScorer(_common.BaseModel):13425  """ReinforcementTuningCloudRunRewardScorer allows users to implement a reward function through GCP Cloud Run.1342613427  Comparing with ReinforcementTuningCodeExecutionRewardScorer that runs in a13428  Sandbox and has no internet access, Cloud Run reward scorer is fully13429  controlled by users. The Cloud Run service should implement the following HTTP13430  API: HTTP method: `POST` HTTP request body: ``` { "example":13431  ReinforcementTuningExample, "response": Content, "metadata": { "step": int13432  "tuning_job_id": int64 } } ``` * `example` is a ReinforcementTuningExample in13433  ProtoJSON format, (i.e., the format is the same as as one line in the13434  training/validation dataset except that the keys must be in camel case).13435  System instructions (i.e., `example.get("systemInstruction")`) and references13436  (i.e., `example.get("references")`) are also included in the `example`13437  provided that they are set in the training/validation dataset. * `response` is13438  a Content in ProtoJSON format (i.e., keys must be in camel case), which is the13439  same as the Online Prediction response for Gemini models. HTTP response body:13440  { "reward": float, "user_requested_aux_info": str // Optional } where the13441  field "user_requested_aux_info" is any (optional) string provided by users for13442  assisting debugging. It's in snake case. This field is mostly useful when13443  calling the GenAiTuningService.ValidateReinforcementTuningReward API, where13444  the proto field (not Cloud Run HTTP response body) userRequestedAuxInfo will13445  be populated if the Cloud Run reward function sets this field in the HTTP13446  response. The following are examples for the HTTP request and response body.13447  Example HTTP request body: ``` { "example": { "contents": [ { "role": "user",13448  "parts": [ { "text": "What is the capital of France?" } ] } ], "references": {13449  "answer": "Paris" } }, "response": { "parts": [ { "text": "London" } ] },13450  "metadata": { "step": 1, "tuning_job_id": 123456789 } } ``` Example HTTP13451  response body: ``` { "reward": -1.0 } ``` Note: Reward output by Cloud Run13452  reward function is clipped to be within `[-1, 1]`, i.e., `reward =13453  max(min(reward, 1.0), -1.0)`. This data type is not supported in Gemini API.13454  """1345513456  cloud_run_uri: Optional[str] = Field(13457      default=None,13458      description="""URI of the Cloud Run service that will be used to compute the reward. The [Vertex AI Secure Fine Tuning Service Agent](https://docs.cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent) (`service-@gcp-sa-vertex-tune.iam.gserviceaccount.com`) must be granted the permission (e.g. by granting `roles/run.invoker` in IAM) to invoke the Cloud Run service.""",13459  )134601346113462class ReinforcementTuningCloudRunRewardScorerDict(TypedDict, total=False):13463  """ReinforcementTuningCloudRunRewardScorer allows users to implement a reward function through GCP Cloud Run.1346413465  Comparing with ReinforcementTuningCodeExecutionRewardScorer that runs in a13466  Sandbox and has no internet access, Cloud Run reward scorer is fully13467  controlled by users. The Cloud Run service should implement the following HTTP13468  API: HTTP method: `POST` HTTP request body: ``` { "example":13469  ReinforcementTuningExample, "response": Content, "metadata": { "step": int13470  "tuning_job_id": int64 } } ``` * `example` is a ReinforcementTuningExample in13471  ProtoJSON format, (i.e., the format is the same as as one line in the13472  training/validation dataset except that the keys must be in camel case).13473  System instructions (i.e., `example.get("systemInstruction")`) and references13474  (i.e., `example.get("references")`) are also included in the `example`13475  provided that they are set in the training/validation dataset. * `response` is13476  a Content in ProtoJSON format (i.e., keys must be in camel case), which is the13477  same as the Online Prediction response for Gemini models. HTTP response body:13478  { "reward": float, "user_requested_aux_info": str // Optional } where the13479  field "user_requested_aux_info" is any (optional) string provided by users for13480  assisting debugging. It's in snake case. This field is mostly useful when13481  calling the GenAiTuningService.ValidateReinforcementTuningReward API, where13482  the proto field (not Cloud Run HTTP response body) userRequestedAuxInfo will13483  be populated if the Cloud Run reward function sets this field in the HTTP13484  response. The following are examples for the HTTP request and response body.13485  Example HTTP request body: ``` { "example": { "contents": [ { "role": "user",13486  "parts": [ { "text": "What is the capital of France?" } ] } ], "references": {13487  "answer": "Paris" } }, "response": { "parts": [ { "text": "London" } ] },13488  "metadata": { "step": 1, "tuning_job_id": 123456789 } } ``` Example HTTP13489  response body: ``` { "reward": -1.0 } ``` Note: Reward output by Cloud Run13490  reward function is clipped to be within `[-1, 1]`, i.e., `reward =13491  max(min(reward, 1.0), -1.0)`. This data type is not supported in Gemini API.13492  """1349313494  cloud_run_uri: Optional[str]13495  """URI of the Cloud Run service that will be used to compute the reward. The [Vertex AI Secure Fine Tuning Service Agent](https://docs.cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent) (`service-@gcp-sa-vertex-tune.iam.gserviceaccount.com`) must be granted the permission (e.g. by granting `roles/run.invoker` in IAM) to invoke the Cloud Run service."""134961349713498ReinforcementTuningCloudRunRewardScorerOrDict = Union[13499    ReinforcementTuningCloudRunRewardScorer,13500    ReinforcementTuningCloudRunRewardScorerDict,13501]135021350313504class SingleReinforcementTuningRewardConfig(_common.BaseModel):13505  """Single reinforcement tuning reward config."""1350613507  autorater_scorer: Optional[ReinforcementTuningAutoraterScorer] = Field(13508      default=None,13509      description="""Scores parsed responses for autorater use cases by using a model to compute the reward.""",13510  )13511  reward_name: Optional[str] = Field(13512      default=None,13513      description="""A unique reward name for identifying each single reinforcement tuning reward.""",13514  )13515  parse_response_config: Optional[ReinforcementTuningParseResponseConfig] = (13516      Field(13517          default=None,13518          description="""Defines how to parse sample response. For example, given a sample response for evaluating the reward, users might want to extract the text only between `` and `` in the sample response, and keeps only the last one in case there are multiple such tags. To achieve such a purpose, they can define a regex `".*(.*?)"` using the ReinforcementTuningParseResponseConfig.ResponseParseType.REGEX_EXTRACT parse type.""",13519      )13520  )13521  code_execution_reward_scorer: Optional[13522      ReinforcementTuningCodeExecutionRewardScorer13523  ] = Field(13524      default=None,13525      description="""ReinforcementTuningCodeExecutionRewardScorer is used to score parsed responses for code execution use cases.""",13526  )13527  string_match_reward_scorer: Optional[13528      ReinforcementTuningStringMatchRewardScorer13529  ] = Field(13530      default=None,13531      description="""ReinforcementTuningStringMatchRewardScorer is used to score parsed responses for simple string matching use cases against reference answers.""",13532  )13533  cloud_run_reward_scorer: Optional[ReinforcementTuningCloudRunRewardScorer] = (13534      Field(13535          default=None,13536          description="""ReinforcementTuningCloudRunRewardScorer is used to score parsed responses by calling a Cloud Run service.""",13537      )13538  )135391354013541class SingleReinforcementTuningRewardConfigDict(TypedDict, total=False):13542  """Single reinforcement tuning reward config."""1354313544  autorater_scorer: Optional[ReinforcementTuningAutoraterScorerDict]13545  """Scores parsed responses for autorater use cases by using a model to compute the reward."""1354613547  reward_name: Optional[str]13548  """A unique reward name for identifying each single reinforcement tuning reward."""1354913550  parse_response_config: Optional[ReinforcementTuningParseResponseConfigDict]13551  """Defines how to parse sample response. For example, given a sample response for evaluating the reward, users might want to extract the text only between `` and `` in the sample response, and keeps only the last one in case there are multiple such tags. To achieve such a purpose, they can define a regex `".*(.*?)"` using the ReinforcementTuningParseResponseConfig.ResponseParseType.REGEX_EXTRACT parse type."""1355213553  code_execution_reward_scorer: Optional[13554      ReinforcementTuningCodeExecutionRewardScorerDict13555  ]13556  """ReinforcementTuningCodeExecutionRewardScorer is used to score parsed responses for code execution use cases."""1355713558  string_match_reward_scorer: Optional[13559      ReinforcementTuningStringMatchRewardScorerDict13560  ]13561  """ReinforcementTuningStringMatchRewardScorer is used to score parsed responses for simple string matching use cases against reference answers."""1356213563  cloud_run_reward_scorer: Optional[ReinforcementTuningCloudRunRewardScorerDict]13564  """ReinforcementTuningCloudRunRewardScorer is used to score parsed responses by calling a Cloud Run service."""135651356613567SingleReinforcementTuningRewardConfigOrDict = Union[13568    SingleReinforcementTuningRewardConfig,13569    SingleReinforcementTuningRewardConfigDict,13570]135711357213573class CompositeReinforcementTuningRewardConfigWeightedRewardConfig(13574    _common.BaseModel13575):13576  """Composite reinforcement tuning reward config weighted reward config."""1357713578  reward_config: Optional[SingleReinforcementTuningRewardConfig] = Field(13579      default=None, description="""Single reward configuration."""13580  )13581  weight: Optional[float] = Field(13582      default=None,13583      description="""How much this single reward contributes to the total overall reward. Total reward is a linear combination of single rewards with their corresponding weights, i.e., ``` total_reward = ( weight_a * reward_a + weight_b * reward_b + ... ) / (weight_a + weight_b + ...) ```""",13584  )135851358613587class CompositeReinforcementTuningRewardConfigWeightedRewardConfigDict(13588    TypedDict, total=False13589):13590  """Composite reinforcement tuning reward config weighted reward config."""1359113592  reward_config: Optional[SingleReinforcementTuningRewardConfigDict]13593  """Single reward configuration."""1359413595  weight: Optional[float]13596  """How much this single reward contributes to the total overall reward. Total reward is a linear combination of single rewards with their corresponding weights, i.e., ``` total_reward = ( weight_a * reward_a + weight_b * reward_b + ... ) / (weight_a + weight_b + ...) ```"""135971359813599CompositeReinforcementTuningRewardConfigWeightedRewardConfigOrDict = Union[13600    CompositeReinforcementTuningRewardConfigWeightedRewardConfig,13601    CompositeReinforcementTuningRewardConfigWeightedRewardConfigDict,13602]136031360413605class CompositeReinforcementTuningRewardConfig(_common.BaseModel):13606  """Composite reinforcement tuning reward config."""1360713608  weighted_reward_configs: Optional[13609      list[CompositeReinforcementTuningRewardConfigWeightedRewardConfig]13610  ] = Field(13611      default=None,13612      description="""List of reward function configurations with weights.""",13613  )136141361513616class CompositeReinforcementTuningRewardConfigDict(TypedDict, total=False):13617  """Composite reinforcement tuning reward config."""1361813619  weighted_reward_configs: Optional[13620      list[CompositeReinforcementTuningRewardConfigWeightedRewardConfigDict]13621  ]13622  """List of reward function configurations with weights."""136231362413625CompositeReinforcementTuningRewardConfigOrDict = Union[13626    CompositeReinforcementTuningRewardConfig,13627    CompositeReinforcementTuningRewardConfigDict,13628]136291363013631class ReinforcementTuningHyperParameters(_common.BaseModel):13632  """Hyperparameters for Reinforcement Tuning."""1363313634  epoch_count: Optional[int] = Field(13635      default=None,13636      description="""Optional. Number of training epoches for the tuning job.""",13637  )13638  learning_rate_multiplier: Optional[float] = Field(13639      default=None,13640      description="""Learning rate multiplier for Reinforcement Learning.""",13641  )13642  adapter_size: Optional[AdapterSize] = Field(13643      default=None,13644      description="""Optional. Adapter size for Reinforcement Tuning.""",13645  )13646  samples_per_prompt: Optional[int] = Field(13647      default=None,13648      description="""Optional. Number of different responses to generate per prompt during tuning.""",13649  )13650  batch_size: Optional[int] = Field(13651      default=None,13652      description="""Optional. Batch size for the tuning job. How many prompts to process at a train step. If not set, the batch size will be determined automatically.""",13653  )13654  evaluate_interval: Optional[int] = Field(13655      default=None,13656      description="""Optional. How often at steps to evaluate the tuning job during training. If not set, evel will be run per epoch. `total_steps = epoch_count * samples_per_prompt / total_prompts_in_dataset`""",13657  )13658  checkpoint_interval: Optional[int] = Field(13659      default=None,13660      description="""Optional. How often at steps to save checkpoints during training. If not set, one checkpoint per epoch will be set. ```total_steps = epoch_count * samples_per_prompt / total_prompts_in_dataset```""",13661  )13662  max_output_tokens: Optional[int] = Field(13663      default=None,13664      description="""Optional. The maximum number of tokens to generate per prompt. Default to 32768.""",13665  )13666  thinking_level: Optional[ReinforcementTuningThinkingLevel] = Field(13667      default=None,13668      description="""Indicates the maximum thinking depth during tuning. Starting from Gemini 3.5 models, the old thinking_budget will no longer be supported and will result in a user error if set. Instead, users should use the thinking_level parameter to control the maximum thinking depth.""",13669  )13670  thinking_budget: Optional[int] = Field(13671      default=None,13672      description="""Optional. The thinking budget for the tuning job to optimize for (Gemini 2.5 only). * -1 means dynamic thinking * 0 means no thinking * > 0 means thinking budget in tokens If not set, default to -1 (dynamic thinking).""",13673  )13674  step_count: Optional[int] = Field(13675      default=None,13676      description="""Optional. Number of steps for the tuning job (mutually exclusive with epoch_count).""",13677  )136781367913680class ReinforcementTuningHyperParametersDict(TypedDict, total=False):13681  """Hyperparameters for Reinforcement Tuning."""1368213683  epoch_count: Optional[int]13684  """Optional. Number of training epoches for the tuning job."""1368513686  learning_rate_multiplier: Optional[float]13687  """Learning rate multiplier for Reinforcement Learning."""1368813689  adapter_size: Optional[AdapterSize]13690  """Optional. Adapter size for Reinforcement Tuning."""1369113692  samples_per_prompt: Optional[int]13693  """Optional. Number of different responses to generate per prompt during tuning."""1369413695  batch_size: Optional[int]13696  """Optional. Batch size for the tuning job. How many prompts to process at a train step. If not set, the batch size will be determined automatically."""1369713698  evaluate_interval: Optional[int]13699  """Optional. How often at steps to evaluate the tuning job during training. If not set, evel will be run per epoch. `total_steps = epoch_count * samples_per_prompt / total_prompts_in_dataset`"""1370013701  checkpoint_interval: Optional[int]13702  """Optional. How often at steps to save checkpoints during training. If not set, one checkpoint per epoch will be set. ```total_steps = epoch_count * samples_per_prompt / total_prompts_in_dataset```"""1370313704  max_output_tokens: Optional[int]13705  """Optional. The maximum number of tokens to generate per prompt. Default to 32768."""1370613707  thinking_level: Optional[ReinforcementTuningThinkingLevel]13708  """Indicates the maximum thinking depth during tuning. Starting from Gemini 3.5 models, the old thinking_budget will no longer be supported and will result in a user error if set. Instead, users should use the thinking_level parameter to control the maximum thinking depth."""1370913710  thinking_budget: Optional[int]13711  """Optional. The thinking budget for the tuning job to optimize for (Gemini 2.5 only). * -1 means dynamic thinking * 0 means no thinking * > 0 means thinking budget in tokens If not set, default to -1 (dynamic thinking)."""1371213713  step_count: Optional[int]13714  """Optional. Number of steps for the tuning job (mutually exclusive with epoch_count)."""137151371613717ReinforcementTuningHyperParametersOrDict = Union[13718    ReinforcementTuningHyperParameters, ReinforcementTuningHyperParametersDict13719]137201372113722class ReinforcementTuningSpec(_common.BaseModel):13723  """Reinforcement tuning spec for tuning."""1372413725  composite_reward_config: Optional[13726      CompositeReinforcementTuningRewardConfig13727  ] = Field(13728      default=None,13729      description="""Composite reward function configuration for reinforcement tuning.""",13730  )13731  training_dataset_uri: Optional[str] = Field(13732      default=None,13733      description="""Cloud Storage path to the file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""",13734  )13735  validation_dataset_uri: Optional[str] = Field(13736      default=None,13737      description="""Cloud Storage path to the file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""",13738  )13739  hyper_parameters: Optional[ReinforcementTuningHyperParameters] = Field(13740      default=None,13741      description="""Additional hyper-parameters to use during tuning.""",13742  )13743  single_reward_config: Optional[SingleReinforcementTuningRewardConfig] = Field(13744      default=None,13745      description="""Single reward function configuration for reinforcement tuning.""",13746  )137471374813749class ReinforcementTuningSpecDict(TypedDict, total=False):13750  """Reinforcement tuning spec for tuning."""1375113752  composite_reward_config: Optional[13753      CompositeReinforcementTuningRewardConfigDict13754  ]13755  """Composite reward function configuration for reinforcement tuning."""1375613757  training_dataset_uri: Optional[str]13758  """Cloud Storage path to the file containing training dataset for tuning. The dataset must be formatted as a JSONL file."""1375913760  validation_dataset_uri: Optional[str]13761  """Cloud Storage path to the file containing validation dataset for tuning. The dataset must be formatted as a JSONL file."""1376213763  hyper_parameters: Optional[ReinforcementTuningHyperParametersDict]13764  """Additional hyper-parameters to use during tuning."""1376513766  single_reward_config: Optional[SingleReinforcementTuningRewardConfigDict]13767  """Single reward function configuration for reinforcement tuning."""137681376913770ReinforcementTuningSpecOrDict = Union[13771    ReinforcementTuningSpec, ReinforcementTuningSpecDict13772]137731377413775class GcsDestination(_common.BaseModel):13776  """The Google Cloud Storage location where the output is to be written to."""1377713778  output_uri_prefix: Optional[str] = Field(13779      default=None,13780      description="""Required. Google Cloud Storage URI to output directory. If the uri doesn't end with '/', a '/' will be automatically appended. The directory is created if it doesn't exist.""",13781  )1378213783  @pydantic.model_validator(mode='after')13784  def _validate_gcs_path(self) -> 'GcsDestination':13785    if self.output_uri_prefix and not self.output_uri_prefix.startswith(13786        'gs://'13787    ):13788      raise ValueError(13789          'output_uri_prefix must be a valid GCS path starting with "gs://".'13790      )13791    return self137921379313794class GcsDestinationDict(TypedDict, total=False):13795  """The Google Cloud Storage location where the output is to be written to."""1379613797  output_uri_prefix: Optional[str]13798  """Required. Google Cloud Storage URI to output directory. If the uri doesn't end with '/', a '/' will be automatically appended. The directory is created if it doesn't exist."""137991380013801GcsDestinationOrDict = Union[GcsDestination, GcsDestinationDict]138021380313804class OutputConfig(_common.BaseModel):13805  """Config for evaluation output."""1380613807  gcs_destination: Optional[GcsDestination] = Field(13808      default=None,13809      description="""Cloud storage destination for evaluation output.""",13810  )138111381213813class OutputConfigDict(TypedDict, total=False):13814  """Config for evaluation output."""1381513816  gcs_destination: Optional[GcsDestinationDict]13817  """Cloud storage destination for evaluation output."""138181381913820OutputConfigOrDict = Union[OutputConfig, OutputConfigDict]138211382213823class EvaluationConfig(_common.BaseModel):13824  """Evaluation config for tuning."""1382513826  metrics: Optional[list[MetricUnion]] = Field(13827      default=None, description="""The metrics used for evaluation."""13828  )13829  output_config: Optional[OutputConfig] = Field(13830      default=None, description="""Config for evaluation output."""13831  )13832  autorater_config: Optional[AutoraterConfig] = Field(13833      default=None, description="""Autorater config for evaluation."""13834  )13835  inference_generation_config: Optional[GenerationConfig] = Field(13836      default=None, description="""Generation config for inference."""13837  )138381383913840class EvaluationConfigDict(TypedDict, total=False):13841  """Evaluation config for tuning."""1384213843  metrics: Optional[list[MetricUnionDict]]13844  """The metrics used for evaluation."""1384513846  output_config: Optional[OutputConfigDict]13847  """Config for evaluation output."""1384813849  autorater_config: Optional[AutoraterConfigDict]13850  """Autorater config for evaluation."""1385113852  inference_generation_config: Optional[GenerationConfigDict]13853  """Generation config for inference."""138541385513856EvaluationConfigOrDict = Union[EvaluationConfig, EvaluationConfigDict]138571385813859class GoogleRpcStatus(_common.BaseModel):13860  """The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs.1386113862  It is used by [gRPC](https://github.com/grpc). Each `Status` message contains13863  three pieces of data: error code, error message, and error details. You can13864  find out more about this error model and how to work with it in the [API13865  Design Guide](https://cloud.google.com/apis/design/errors). This data type is13866  not supported in Gemini API.13867  """1386813869  code: Optional[int] = Field(13870      default=None,13871      description="""The status code, which should be an enum value of google.rpc.Code.""",13872  )13873  details: Optional[list[dict[str, Any]]] = Field(13874      default=None,13875      description="""A list of messages that carry the error details. There is a common set of message types for APIs to use.""",13876  )13877  message: Optional[str] = Field(13878      default=None,13879      description="""A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.""",13880  )138811388213883class GoogleRpcStatusDict(TypedDict, total=False):13884  """The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs.1388513886  It is used by [gRPC](https://github.com/grpc). Each `Status` message contains13887  three pieces of data: error code, error message, and error details. You can13888  find out more about this error model and how to work with it in the [API13889  Design Guide](https://cloud.google.com/apis/design/errors). This data type is13890  not supported in Gemini API.13891  """1389213893  code: Optional[int]13894  """The status code, which should be an enum value of google.rpc.Code."""1389513896  details: Optional[list[dict[str, Any]]]13897  """A list of messages that carry the error details. There is a common set of message types for APIs to use."""1389813899  message: Optional[str]13900  """A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client."""139011390213903GoogleRpcStatusOrDict = Union[GoogleRpcStatus, GoogleRpcStatusDict]139041390513906class PreTunedModel(_common.BaseModel):13907  """A pre-tuned model for continuous tuning.1390813909  This data type is not supported in Gemini API.13910  """1391113912  base_model: Optional[str] = Field(13913      default=None,13914      description="""Output only. The name of the base model this PreTunedModel was tuned from.""",13915  )13916  checkpoint_id: Optional[str] = Field(13917      default=None,13918      description="""Optional. The source checkpoint id. If not specified, the default checkpoint will be used.""",13919  )13920  tuned_model_name: Optional[str] = Field(13921      default=None,13922      description="""The resource name of the Model. E.g., a model resource name with a specified version id or alias: `projects/{project}/locations/{location}/models/{model}@{version_id}` `projects/{project}/locations/{location}/models/{model}@{alias}` Or, omit the version id to use the default version: `projects/{project}/locations/{location}/models/{model}`""",13923  )139241392513926class PreTunedModelDict(TypedDict, total=False):13927  """A pre-tuned model for continuous tuning.1392813929  This data type is not supported in Gemini API.13930  """1393113932  base_model: Optional[str]13933  """Output only. The name of the base model this PreTunedModel was tuned from."""1393413935  checkpoint_id: Optional[str]13936  """Optional. The source checkpoint id. If not specified, the default checkpoint will be used."""1393713938  tuned_model_name: Optional[str]13939  """The resource name of the Model. E.g., a model resource name with a specified version id or alias: `projects/{project}/locations/{location}/models/{model}@{version_id}` `projects/{project}/locations/{location}/models/{model}@{alias}` Or, omit the version id to use the default version: `projects/{project}/locations/{location}/models/{model}`"""139401394113942PreTunedModelOrDict = Union[PreTunedModel, PreTunedModelDict]139431394413945class DatasetDistributionDistributionBucket(_common.BaseModel):13946  """Dataset bucket used to create a histogram for the distribution given a population of values.1394713948  This data type is not supported in Gemini API.13949  """1395013951  count: Optional[int] = Field(13952      default=None,13953      description="""Output only. Number of values in the bucket.""",13954  )13955  left: Optional[float] = Field(13956      default=None, description="""Output only. Left bound of the bucket."""13957  )13958  right: Optional[float] = Field(13959      default=None, description="""Output only. Right bound of the bucket."""13960  )139611396213963class DatasetDistributionDistributionBucketDict(TypedDict, total=False):13964  """Dataset bucket used to create a histogram for the distribution given a population of values.1396513966  This data type is not supported in Gemini API.13967  """1396813969  count: Optional[int]13970  """Output only. Number of values in the bucket."""1397113972  left: Optional[float]13973  """Output only. Left bound of the bucket."""1397413975  right: Optional[float]13976  """Output only. Right bound of the bucket."""139771397813979DatasetDistributionDistributionBucketOrDict = Union[13980    DatasetDistributionDistributionBucket,13981    DatasetDistributionDistributionBucketDict,13982]139831398413985class DatasetDistribution(_common.BaseModel):13986  """Distribution computed over a tuning dataset.1398713988  This data type is not supported in Gemini API.13989  """1399013991  buckets: Optional[list[DatasetDistributionDistributionBucket]] = Field(13992      default=None, description="""Output only. Defines the histogram bucket."""13993  )13994  max: Optional[float] = Field(13995      default=None,13996      description="""Output only. The maximum of the population values.""",13997  )13998  mean: Optional[float] = Field(13999      default=None,14000      description="""Output only. The arithmetic mean of the values in the population.""",14001  )14002  median: Optional[float] = Field(14003      default=None,14004      description="""Output only. The median of the values in the population.""",14005  )14006  min: Optional[float] = Field(14007      default=None,14008      description="""Output only. The minimum of the population values.""",14009  )14010  p5: Optional[float] = Field(14011      default=None,14012      description="""Output only. The 5th percentile of the values in the population.""",14013  )14014  p95: Optional[float] = Field(14015      default=None,14016      description="""Output only. The 95th percentile of the values in the population.""",14017  )14018  sum: Optional[float] = Field(14019      default=None,14020      description="""Output only. Sum of a given population of values.""",14021  )140221402314024class DatasetDistributionDict(TypedDict, total=False):14025  """Distribution computed over a tuning dataset.1402614027  This data type is not supported in Gemini API.14028  """1402914030  buckets: Optional[list[DatasetDistributionDistributionBucketDict]]14031  """Output only. Defines the histogram bucket."""1403214033  max: Optional[float]14034  """Output only. The maximum of the population values."""1403514036  mean: Optional[float]14037  """Output only. The arithmetic mean of the values in the population."""1403814039  median: Optional[float]14040  """Output only. The median of the values in the population."""1404114042  min: Optional[float]14043  """Output only. The minimum of the population values."""1404414045  p5: Optional[float]14046  """Output only. The 5th percentile of the values in the population."""1404714048  p95: Optional[float]14049  """Output only. The 95th percentile of the values in the population."""1405014051  sum: Optional[float]14052  """Output only. Sum of a given population of values."""140531405414055DatasetDistributionOrDict = Union[DatasetDistribution, DatasetDistributionDict]140561405714058class ReinforcementTuningExample(_common.BaseModel):14059  """User-facing format for Gemini Reinforcement Tuning examples on Vertex."""1406014061  contents: Optional[list[Content]] = Field(14062      default=None,14063      description="""Multi-turn contents that represents the Prompt.""",14064  )14065  references: Optional[dict[str, str]] = Field(14066      default=None,14067      description="""References for the given prompt. The key is the name of the reference, and the value is the reference itself.""",14068  )14069  system_instruction: Optional[Content] = Field(14070      default=None,14071      description="""Corresponds to system_instruction in user-facing GenerateContentRequest.""",14072  )14073  tools: Optional[list[Tool]] = Field(14074      default=None,14075      description="""Optional. Corresponds to tools in user-facing GenerateContentRequest.""",14076  )140771407814079class ReinforcementTuningExampleDict(TypedDict, total=False):14080  """User-facing format for Gemini Reinforcement Tuning examples on Vertex."""1408114082  contents: Optional[list[ContentDict]]14083  """Multi-turn contents that represents the Prompt."""1408414085  references: Optional[dict[str, str]]14086  """References for the given prompt. The key is the name of the reference, and the value is the reference itself."""1408714088  system_instruction: Optional[ContentDict]14089  """Corresponds to system_instruction in user-facing GenerateContentRequest."""1409014091  tools: Optional[list[ToolDict]]14092  """Optional. Corresponds to tools in user-facing GenerateContentRequest."""140931409414095ReinforcementTuningExampleOrDict = Union[14096    ReinforcementTuningExample, ReinforcementTuningExampleDict14097]140981409914100class ReinforcementTuningUserDatasetExamples(_common.BaseModel):14101  """Sample reinforcement tuning user data in the training dataset.1410214103  The contents are truncated for better UI showing. This data type is not14104  supported in Gemini API.14105  """1410614107  user_dataset_examples: Optional[list[ReinforcementTuningExample]] = Field(14108      default=None,14109      description="""List of user datasset examples showing to user.""",14110  )141111411214113class ReinforcementTuningUserDatasetExamplesDict(TypedDict, total=False):14114  """Sample reinforcement tuning user data in the training dataset.1411514116  The contents are truncated for better UI showing. This data type is not14117  supported in Gemini API.14118  """1411914120  user_dataset_examples: Optional[list[ReinforcementTuningExampleDict]]14121  """List of user datasset examples showing to user."""141221412314124ReinforcementTuningUserDatasetExamplesOrDict = Union[14125    ReinforcementTuningUserDatasetExamples,14126    ReinforcementTuningUserDatasetExamplesDict,14127]141281412914130class DatasetStats(_common.BaseModel):14131  """Statistics computed over a tuning dataset.1413214133  This data type is not supported in Gemini API.14134  """1413514136  dropped_example_indices: Optional[list[int]] = Field(14137      default=None,14138      description="""Output only. A partial sample of the indices (starting from 1) of the dropped examples.""",14139  )14140  dropped_example_reasons: Optional[list[str]] = Field(14141      default=None,14142      description="""Output only. For each index in `dropped_example_indices`, the user-facing reason why the example was dropped.""",14143  )14144  total_billable_character_count: Optional[int] = Field(14145      default=None,14146      description="""Output only. Number of billable characters in the tuning dataset.""",14147  )14148  total_tuning_character_count: Optional[int] = Field(14149      default=None,14150      description="""Output only. Number of tuning characters in the tuning dataset.""",14151  )14152  tuning_dataset_example_count: Optional[int] = Field(14153      default=None,14154      description="""Output only. Number of examples in the tuning dataset.""",14155  )14156  tuning_step_count: Optional[int] = Field(14157      default=None,14158      description="""Output only. Number of tuning steps for this Tuning Job.""",14159  )14160  user_dataset_examples: Optional[list[Content]] = Field(14161      default=None,14162      description="""Output only. Sample user messages in the training dataset uri.""",14163  )14164  user_input_token_distribution: Optional[DatasetDistribution] = Field(14165      default=None,14166      description="""Output only. Dataset distributions for the user input tokens.""",14167  )14168  user_message_per_example_distribution: Optional[DatasetDistribution] = Field(14169      default=None,14170      description="""Output only. Dataset distributions for the messages per example.""",14171  )14172  user_output_token_distribution: Optional[DatasetDistribution] = Field(14173      default=None,14174      description="""Output only. Dataset distributions for the user output tokens.""",14175  )14176  contents_per_example_distribution: Optional[DatasetDistribution] = Field(14177      default=None,14178      description="""Output only. Dataset distributions for the number of contents per example.""",14179  )14180  reinforcement_tuning_user_dataset_examples: Optional[14181      ReinforcementTuningUserDatasetExamples14182  ] = Field(14183      default=None,14184      description="""Output only. Sample user dataset examples in the training dataset uri for Reinforcement Tuning.""",14185  )14186  total_billable_token_count: Optional[int] = Field(14187      default=None,14188      description="""Output only. Number of billable tokens in the tuning dataset.""",14189  )141901419114192class DatasetStatsDict(TypedDict, total=False):14193  """Statistics computed over a tuning dataset.1419414195  This data type is not supported in Gemini API.14196  """1419714198  dropped_example_indices: Optional[list[int]]14199  """Output only. A partial sample of the indices (starting from 1) of the dropped examples."""1420014201  dropped_example_reasons: Optional[list[str]]14202  """Output only. For each index in `dropped_example_indices`, the user-facing reason why the example was dropped."""1420314204  total_billable_character_count: Optional[int]14205  """Output only. Number of billable characters in the tuning dataset."""1420614207  total_tuning_character_count: Optional[int]14208  """Output only. Number of tuning characters in the tuning dataset."""1420914210  tuning_dataset_example_count: Optional[int]14211  """Output only. Number of examples in the tuning dataset."""1421214213  tuning_step_count: Optional[int]14214  """Output only. Number of tuning steps for this Tuning Job."""1421514216  user_dataset_examples: Optional[list[ContentDict]]14217  """Output only. Sample user messages in the training dataset uri."""1421814219  user_input_token_distribution: Optional[DatasetDistributionDict]14220  """Output only. Dataset distributions for the user input tokens."""1422114222  user_message_per_example_distribution: Optional[DatasetDistributionDict]14223  """Output only. Dataset distributions for the messages per example."""1422414225  user_output_token_distribution: Optional[DatasetDistributionDict]14226  """Output only. Dataset distributions for the user output tokens."""1422714228  contents_per_example_distribution: Optional[DatasetDistributionDict]14229  """Output only. Dataset distributions for the number of contents per example."""1423014231  reinforcement_tuning_user_dataset_examples: Optional[14232      ReinforcementTuningUserDatasetExamplesDict14233  ]14234  """Output only. Sample user dataset examples in the training dataset uri for Reinforcement Tuning."""1423514236  total_billable_token_count: Optional[int]14237  """Output only. Number of billable tokens in the tuning dataset."""142381423914240DatasetStatsOrDict = Union[DatasetStats, DatasetStatsDict]142411424214243class DistillationDataStats(_common.BaseModel):14244  """Statistics for distillation prompt dataset.1424514246  These statistics do not include the responses sampled from the teacher model.14247  This data type is not supported in Gemini API.14248  """1424914250  training_dataset_stats: Optional[DatasetStats] = Field(14251      default=None,14252      description="""Output only. Statistics computed for the training dataset.""",14253  )142541425514256class DistillationDataStatsDict(TypedDict, total=False):14257  """Statistics for distillation prompt dataset.1425814259  These statistics do not include the responses sampled from the teacher model.14260  This data type is not supported in Gemini API.14261  """1426214263  training_dataset_stats: Optional[DatasetStatsDict]14264  """Output only. Statistics computed for the training dataset."""142651426614267DistillationDataStatsOrDict = Union[14268    DistillationDataStats, DistillationDataStatsDict14269]142701427114272class GeminiPreferenceExampleCompletion(_common.BaseModel):14273  """Completion and its preference score.1427414275  This data type is not supported in Gemini API.14276  """1427714278  completion: Optional[Content] = Field(14279      default=None,14280      description="""Single turn completion for the given prompt.""",14281  )14282  score: Optional[float] = Field(14283      default=None, description="""The score for the given completion."""14284  )142851428614287class GeminiPreferenceExampleCompletionDict(TypedDict, total=False):14288  """Completion and its preference score.1428914290  This data type is not supported in Gemini API.14291  """1429214293  completion: Optional[ContentDict]14294  """Single turn completion for the given prompt."""1429514296  score: Optional[float]14297  """The score for the given completion."""142981429914300GeminiPreferenceExampleCompletionOrDict = Union[14301    GeminiPreferenceExampleCompletion, GeminiPreferenceExampleCompletionDict14302]143031430414305class GeminiPreferenceExample(_common.BaseModel):14306  """Input example for preference optimization.1430714308  This data type is not supported in Gemini API.14309  """1431014311  completions: Optional[list[GeminiPreferenceExampleCompletion]] = Field(14312      default=None, description="""List of completions for a given prompt."""14313  )14314  contents: Optional[list[Content]] = Field(14315      default=None,14316      description="""Multi-turn contents that represents the Prompt.""",14317  )143181431914320class GeminiPreferenceExampleDict(TypedDict, total=False):14321  """Input example for preference optimization.1432214323  This data type is not supported in Gemini API.14324  """1432514326  completions: Optional[list[GeminiPreferenceExampleCompletionDict]]14327  """List of completions for a given prompt."""1432814329  contents: Optional[list[ContentDict]]14330  """Multi-turn contents that represents the Prompt."""143311433214333GeminiPreferenceExampleOrDict = Union[14334    GeminiPreferenceExample, GeminiPreferenceExampleDict14335]143361433714338class PreferenceOptimizationDataStats(_common.BaseModel):14339  """Statistics computed for datasets used for preference optimization.1434014341  This data type is not supported in Gemini API.14342  """1434314344  dropped_example_indices: Optional[list[int]] = Field(14345      default=None,14346      description="""Output only. A partial sample of the indices (starting from 1) of the dropped examples.""",14347  )14348  dropped_example_reasons: Optional[list[str]] = Field(14349      default=None,14350      description="""Output only. For each index in `dropped_example_indices`, the user-facing reason why the example was dropped.""",14351  )14352  score_variance_per_example_distribution: Optional[DatasetDistribution] = (14353      Field(14354          default=None,14355          description="""Output only. Dataset distributions for scores variance per example.""",14356      )14357  )14358  scores_distribution: Optional[DatasetDistribution] = Field(14359      default=None,14360      description="""Output only. Dataset distributions for scores.""",14361  )14362  total_billable_token_count: Optional[int] = Field(14363      default=None,14364      description="""Output only. Number of billable tokens in the tuning dataset.""",14365  )14366  tuning_dataset_example_count: Optional[int] = Field(14367      default=None,14368      description="""Output only. Number of examples in the tuning dataset.""",14369  )14370  tuning_step_count: Optional[int] = Field(14371      default=None,14372      description="""Output only. Number of tuning steps for this Tuning Job.""",14373  )14374  user_dataset_examples: Optional[list[GeminiPreferenceExample]] = Field(14375      default=None,14376      description="""Output only. Sample user examples in the training dataset.""",14377  )14378  user_input_token_distribution: Optional[DatasetDistribution] = Field(14379      default=None,14380      description="""Output only. Dataset distributions for the user input tokens.""",14381  )14382  user_output_token_distribution: Optional[DatasetDistribution] = Field(14383      default=None,14384      description="""Output only. Dataset distributions for the user output tokens.""",14385  )143861438714388class PreferenceOptimizationDataStatsDict(TypedDict, total=False):14389  """Statistics computed for datasets used for preference optimization.1439014391  This data type is not supported in Gemini API.14392  """1439314394  dropped_example_indices: Optional[list[int]]14395  """Output only. A partial sample of the indices (starting from 1) of the dropped examples."""1439614397  dropped_example_reasons: Optional[list[str]]14398  """Output only. For each index in `dropped_example_indices`, the user-facing reason why the example was dropped."""1439914400  score_variance_per_example_distribution: Optional[DatasetDistributionDict]14401  """Output only. Dataset distributions for scores variance per example."""1440214403  scores_distribution: Optional[DatasetDistributionDict]14404  """Output only. Dataset distributions for scores."""1440514406  total_billable_token_count: Optional[int]14407  """Output only. Number of billable tokens in the tuning dataset."""1440814409  tuning_dataset_example_count: Optional[int]14410  """Output only. Number of examples in the tuning dataset."""1441114412  tuning_step_count: Optional[int]14413  """Output only. Number of tuning steps for this Tuning Job."""1441414415  user_dataset_examples: Optional[list[GeminiPreferenceExampleDict]]14416  """Output only. Sample user examples in the training dataset."""1441714418  user_input_token_distribution: Optional[DatasetDistributionDict]14419  """Output only. Dataset distributions for the user input tokens."""1442014421  user_output_token_distribution: Optional[DatasetDistributionDict]14422  """Output only. Dataset distributions for the user output tokens."""144231442414425PreferenceOptimizationDataStatsOrDict = Union[14426    PreferenceOptimizationDataStats, PreferenceOptimizationDataStatsDict14427]144281442914430class SupervisedTuningDatasetDistributionDatasetBucket(_common.BaseModel):14431  """Dataset bucket used to create a histogram for the distribution given a population of values.1443214433  This data type is not supported in Gemini API.14434  """1443514436  count: Optional[float] = Field(14437      default=None,14438      description="""Output only. Number of values in the bucket.""",14439  )14440  left: Optional[float] = Field(14441      default=None, description="""Output only. Left bound of the bucket."""14442  )14443  right: Optional[float] = Field(14444      default=None, description="""Output only. Right bound of the bucket."""14445  )144461444714448class SupervisedTuningDatasetDistributionDatasetBucketDict(14449    TypedDict, total=False14450):14451  """Dataset bucket used to create a histogram for the distribution given a population of values.1445214453  This data type is not supported in Gemini API.14454  """1445514456  count: Optional[float]14457  """Output only. Number of values in the bucket."""1445814459  left: Optional[float]14460  """Output only. Left bound of the bucket."""1446114462  right: Optional[float]14463  """Output only. Right bound of the bucket."""144641446514466SupervisedTuningDatasetDistributionDatasetBucketOrDict = Union[14467    SupervisedTuningDatasetDistributionDatasetBucket,14468    SupervisedTuningDatasetDistributionDatasetBucketDict,14469]144701447114472class SupervisedTuningDatasetDistribution(_common.BaseModel):14473  """Dataset distribution for Supervised Tuning.1447414475  This data type is not supported in Gemini API.14476  """1447714478  billable_sum: Optional[int] = Field(14479      default=None,14480      description="""Output only. Sum of a given population of values that are billable.""",14481  )14482  buckets: Optional[list[SupervisedTuningDatasetDistributionDatasetBucket]] = (14483      Field(14484          default=None,14485          description="""Output only. Defines the histogram bucket.""",14486      )14487  )14488  max: Optional[float] = Field(14489      default=None,14490      description="""Output only. The maximum of the population values.""",14491  )14492  mean: Optional[float] = Field(14493      default=None,14494      description="""Output only. The arithmetic mean of the values in the population.""",14495  )14496  median: Optional[float] = Field(14497      default=None,14498      description="""Output only. The median of the values in the population.""",14499  )14500  min: Optional[float] = Field(14501      default=None,14502      description="""Output only. The minimum of the population values.""",14503  )14504  p5: Optional[float] = Field(14505      default=None,14506      description="""Output only. The 5th percentile of the values in the population.""",14507  )14508  p95: Optional[float] = Field(14509      default=None,14510      description="""Output only. The 95th percentile of the values in the population.""",14511  )14512  sum: Optional[int] = Field(14513      default=None,14514      description="""Output only. Sum of a given population of values.""",14515  )145161451714518class SupervisedTuningDatasetDistributionDict(TypedDict, total=False):14519  """Dataset distribution for Supervised Tuning.1452014521  This data type is not supported in Gemini API.14522  """1452314524  billable_sum: Optional[int]14525  """Output only. Sum of a given population of values that are billable."""1452614527  buckets: Optional[list[SupervisedTuningDatasetDistributionDatasetBucketDict]]14528  """Output only. Defines the histogram bucket."""1452914530  max: Optional[float]14531  """Output only. The maximum of the population values."""1453214533  mean: Optional[float]14534  """Output only. The arithmetic mean of the values in the population."""1453514536  median: Optional[float]14537  """Output only. The median of the values in the population."""1453814539  min: Optional[float]14540  """Output only. The minimum of the population values."""1454114542  p5: Optional[float]14543  """Output only. The 5th percentile of the values in the population."""1454414545  p95: Optional[float]14546  """Output only. The 95th percentile of the values in the population."""1454714548  sum: Optional[int]14549  """Output only. Sum of a given population of values."""145501455114552SupervisedTuningDatasetDistributionOrDict = Union[14553    SupervisedTuningDatasetDistribution, SupervisedTuningDatasetDistributionDict14554]145551455614557class SupervisedTuningDataStats(_common.BaseModel):14558  """Tuning data statistics for Supervised Tuning.1455914560  This data type is not supported in Gemini API.14561  """1456214563  dropped_example_reasons: Optional[list[str]] = Field(14564      default=None,14565      description="""Output only. For each index in `truncated_example_indices`, the user-facing reason why the example was dropped.""",14566  )14567  total_billable_character_count: Optional[int] = Field(14568      default=None,14569      description="""Output only. Number of billable characters in the tuning dataset.""",14570  )14571  total_billable_token_count: Optional[int] = Field(14572      default=None,14573      description="""Output only. Number of billable tokens in the tuning dataset.""",14574  )14575  total_truncated_example_count: Optional[int] = Field(14576      default=None,14577      description="""Output only. The number of examples in the dataset that have been dropped. An example can be dropped for reasons including: too many tokens, contains an invalid image, contains too many images, etc.""",14578  )14579  total_tuning_character_count: Optional[int] = Field(14580      default=None,14581      description="""Output only. Number of tuning characters in the tuning dataset.""",14582  )14583  truncated_example_indices: Optional[list[int]] = Field(14584      default=None,14585      description="""Output only. A partial sample of the indices (starting from 1) of the dropped examples.""",14586  )14587  tuning_dataset_example_count: Optional[int] = Field(14588      default=None,14589      description="""Output only. Number of examples in the tuning dataset.""",14590  )14591  tuning_step_count: Optional[int] = Field(14592      default=None,14593      description="""Output only. Number of tuning steps for this Tuning Job.""",14594  )14595  user_dataset_examples: Optional[list[Content]] = Field(14596      default=None,14597      description="""Output only. Sample user messages in the training dataset uri.""",14598  )14599  user_input_token_distribution: Optional[14600      SupervisedTuningDatasetDistribution14601  ] = Field(14602      default=None,14603      description="""Output only. Dataset distributions for the user input tokens.""",14604  )14605  user_message_per_example_distribution: Optional[14606      SupervisedTuningDatasetDistribution14607  ] = Field(14608      default=None,14609      description="""Output only. Dataset distributions for the messages per example.""",14610  )14611  user_output_token_distribution: Optional[14612      SupervisedTuningDatasetDistribution14613  ] = Field(14614      default=None,14615      description="""Output only. Dataset distributions for the user output tokens.""",14616  )146171461814619class SupervisedTuningDataStatsDict(TypedDict, total=False):14620  """Tuning data statistics for Supervised Tuning.1462114622  This data type is not supported in Gemini API.14623  """1462414625  dropped_example_reasons: Optional[list[str]]14626  """Output only. For each index in `truncated_example_indices`, the user-facing reason why the example was dropped."""1462714628  total_billable_character_count: Optional[int]14629  """Output only. Number of billable characters in the tuning dataset."""1463014631  total_billable_token_count: Optional[int]14632  """Output only. Number of billable tokens in the tuning dataset."""1463314634  total_truncated_example_count: Optional[int]14635  """Output only. The number of examples in the dataset that have been dropped. An example can be dropped for reasons including: too many tokens, contains an invalid image, contains too many images, etc."""1463614637  total_tuning_character_count: Optional[int]14638  """Output only. Number of tuning characters in the tuning dataset."""1463914640  truncated_example_indices: Optional[list[int]]14641  """Output only. A partial sample of the indices (starting from 1) of the dropped examples."""1464214643  tuning_dataset_example_count: Optional[int]14644  """Output only. Number of examples in the tuning dataset."""1464514646  tuning_step_count: Optional[int]14647  """Output only. Number of tuning steps for this Tuning Job."""1464814649  user_dataset_examples: Optional[list[ContentDict]]14650  """Output only. Sample user messages in the training dataset uri."""1465114652  user_input_token_distribution: Optional[14653      SupervisedTuningDatasetDistributionDict14654  ]14655  """Output only. Dataset distributions for the user input tokens."""1465614657  user_message_per_example_distribution: Optional[14658      SupervisedTuningDatasetDistributionDict14659  ]14660  """Output only. Dataset distributions for the messages per example."""1466114662  user_output_token_distribution: Optional[14663      SupervisedTuningDatasetDistributionDict14664  ]14665  """Output only. Dataset distributions for the user output tokens."""146661466714668SupervisedTuningDataStatsOrDict = Union[14669    SupervisedTuningDataStats, SupervisedTuningDataStatsDict14670]146711467214673class TuningDataStats(_common.BaseModel):14674  """The tuning data statistic values for TuningJob.1467514676  This data type is not supported in Gemini API.14677  """1467814679  distillation_data_stats: Optional[DistillationDataStats] = Field(14680      default=None,14681      description="""Output only. Statistics for distillation prompt dataset. These statistics do not include the responses sampled from the teacher model.""",14682  )14683  preference_optimization_data_stats: Optional[14684      PreferenceOptimizationDataStats14685  ] = Field(14686      default=None,14687      description="""Output only. Statistics for preference optimization.""",14688  )14689  supervised_tuning_data_stats: Optional[SupervisedTuningDataStats] = Field(14690      default=None, description="""The SFT Tuning data stats."""14691  )14692  reinforcement_tuning_data_stats: Optional[DatasetStats] = Field(14693      default=None,14694      description="""Output only. Statistics for reinforcement tuning.""",14695  )146961469714698class TuningDataStatsDict(TypedDict, total=False):14699  """The tuning data statistic values for TuningJob.1470014701  This data type is not supported in Gemini API.14702  """1470314704  distillation_data_stats: Optional[DistillationDataStatsDict]14705  """Output only. Statistics for distillation prompt dataset. These statistics do not include the responses sampled from the teacher model."""1470614707  preference_optimization_data_stats: Optional[14708      PreferenceOptimizationDataStatsDict14709  ]14710  """Output only. Statistics for preference optimization."""1471114712  supervised_tuning_data_stats: Optional[SupervisedTuningDataStatsDict]14713  """The SFT Tuning data stats."""1471414715  reinforcement_tuning_data_stats: Optional[DatasetStatsDict]14716  """Output only. Statistics for reinforcement tuning."""147171471814719TuningDataStatsOrDict = Union[TuningDataStats, TuningDataStatsDict]147201472114722class EncryptionSpec(_common.BaseModel):14723  """Represents a customer-managed encryption key specification that can be applied to a Vertex AI resource.1472414725  This data type is not supported in Gemini API.14726  """1472714728  kms_key_name: Optional[str] = Field(14729      default=None,14730      description="""Required. Resource name of the Cloud KMS key used to protect the resource. The Cloud KMS key must be in the same region as the resource. It must have the format `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.""",14731  )147321473314734class EncryptionSpecDict(TypedDict, total=False):14735  """Represents a customer-managed encryption key specification that can be applied to a Vertex AI resource.1473614737  This data type is not supported in Gemini API.14738  """1473914740  kms_key_name: Optional[str]14741  """Required. Resource name of the Cloud KMS key used to protect the resource. The Cloud KMS key must be in the same region as the resource. It must have the format `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`."""147421474314744EncryptionSpecOrDict = Union[EncryptionSpec, EncryptionSpecDict]147451474614747class PartnerModelTuningSpec(_common.BaseModel):14748  """Tuning spec for Partner models.1474914750  This data type is not supported in Gemini API.14751  """1475214753  hyper_parameters: Optional[dict[str, Any]] = Field(14754      default=None,14755      description="""Hyperparameters for tuning. The accepted hyper_parameters and their valid range of values will differ depending on the base model.""",14756  )14757  training_dataset_uri: Optional[str] = Field(14758      default=None,14759      description="""Required. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""",14760  )14761  validation_dataset_uri: Optional[str] = Field(14762      default=None,14763      description="""Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""",14764  )147651476614767class PartnerModelTuningSpecDict(TypedDict, total=False):14768  """Tuning spec for Partner models.1476914770  This data type is not supported in Gemini API.14771  """1477214773  hyper_parameters: Optional[dict[str, Any]]14774  """Hyperparameters for tuning. The accepted hyper_parameters and their valid range of values will differ depending on the base model."""1477514776  training_dataset_uri: Optional[str]14777  """Required. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file."""1477814779  validation_dataset_uri: Optional[str]14780  """Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file."""147811478214783PartnerModelTuningSpecOrDict = Union[14784    PartnerModelTuningSpec, PartnerModelTuningSpecDict14785]147861478714788class BleuMetricValue(_common.BaseModel):14789  """Bleu metric value for an instance.1479014791  This data type is not supported in Gemini API.14792  """1479314794  score: Optional[float] = Field(14795      default=None, description="""Output only. Bleu score."""14796  )147971479814799class BleuMetricValueDict(TypedDict, total=False):14800  """Bleu metric value for an instance.1480114802  This data type is not supported in Gemini API.14803  """1480414805  score: Optional[float]14806  """Output only. Bleu score."""148071480814809BleuMetricValueOrDict = Union[BleuMetricValue, BleuMetricValueDict]148101481114812class CustomCodeExecutionResult(_common.BaseModel):14813  """Result for custom code execution metric.1481414815  This data type is not supported in Gemini API.14816  """1481714818  score: Optional[float] = Field(14819      default=None, description="""Output only. Custom code execution score."""14820  )148211482214823class CustomCodeExecutionResultDict(TypedDict, total=False):14824  """Result for custom code execution metric.1482514826  This data type is not supported in Gemini API.14827  """1482814829  score: Optional[float]14830  """Output only. Custom code execution score."""148311483214833CustomCodeExecutionResultOrDict = Union[14834    CustomCodeExecutionResult, CustomCodeExecutionResultDict14835]148361483714838class ExactMatchMetricValue(_common.BaseModel):14839  """Exact match metric value for an instance.1484014841  This data type is not supported in Gemini API.14842  """1484314844  score: Optional[float] = Field(14845      default=None, description="""Output only. Exact match score."""14846  )148471484814849class ExactMatchMetricValueDict(TypedDict, total=False):14850  """Exact match metric value for an instance.1485114852  This data type is not supported in Gemini API.14853  """1485414855  score: Optional[float]14856  """Output only. Exact match score."""148571485814859ExactMatchMetricValueOrDict = Union[14860    ExactMatchMetricValue, ExactMatchMetricValueDict14861]148621486314864class RawOutput(_common.BaseModel):14865  """Raw output. This data type is not supported in Gemini API."""1486614867  raw_output: Optional[list[str]] = Field(14868      default=None, description="""Output only. Raw output string."""14869  )148701487114872class RawOutputDict(TypedDict, total=False):14873  """Raw output. This data type is not supported in Gemini API."""1487414875  raw_output: Optional[list[str]]14876  """Output only. Raw output string."""148771487814879RawOutputOrDict = Union[RawOutput, RawOutputDict]148801488114882class CustomOutput(_common.BaseModel):14883  """Spec for custom output. This data type is not supported in Gemini API."""1488414885  raw_outputs: Optional[RawOutput] = Field(14886      default=None, description="""Output only. List of raw output strings."""14887  )148881488914890class CustomOutputDict(TypedDict, total=False):14891  """Spec for custom output. This data type is not supported in Gemini API."""1489214893  raw_outputs: Optional[RawOutputDict]14894  """Output only. List of raw output strings."""148951489614897CustomOutputOrDict = Union[CustomOutput, CustomOutputDict]148981489914900class PairwiseMetricResult(_common.BaseModel):14901  """Spec for pairwise metric result.1490214903  This data type is not supported in Gemini API.14904  """1490514906  custom_output: Optional[CustomOutput] = Field(14907      default=None, description="""Output only. Spec for custom output."""14908  )14909  explanation: Optional[str] = Field(14910      default=None,14911      description="""Output only. Explanation for pairwise metric score.""",14912  )14913  pairwise_choice: Optional[PairwiseChoice] = Field(14914      default=None, description="""Output only. Pairwise metric choice."""14915  )149161491714918class PairwiseMetricResultDict(TypedDict, total=False):14919  """Spec for pairwise metric result.1492014921  This data type is not supported in Gemini API.14922  """1492314924  custom_output: Optional[CustomOutputDict]14925  """Output only. Spec for custom output."""1492614927  explanation: Optional[str]14928  """Output only. Explanation for pairwise metric score."""1492914930  pairwise_choice: Optional[PairwiseChoice]14931  """Output only. Pairwise metric choice."""149321493314934PairwiseMetricResultOrDict = Union[14935    PairwiseMetricResult, PairwiseMetricResultDict14936]149371493814939class PointwiseMetricResult(_common.BaseModel):14940  """Spec for pointwise metric result.1494114942  This data type is not supported in Gemini API.14943  """1494414945  custom_output: Optional[CustomOutput] = Field(14946      default=None, description="""Output only. Spec for custom output."""14947  )14948  explanation: Optional[str] = Field(14949      default=None,14950      description="""Output only. Explanation for pointwise metric score.""",14951  )14952  score: Optional[float] = Field(14953      default=None, description="""Output only. Pointwise metric score."""14954  )149551495614957class PointwiseMetricResultDict(TypedDict, total=False):14958  """Spec for pointwise metric result.1495914960  This data type is not supported in Gemini API.14961  """1496214963  custom_output: Optional[CustomOutputDict]14964  """Output only. Spec for custom output."""1496514966  explanation: Optional[str]14967  """Output only. Explanation for pointwise metric score."""1496814969  score: Optional[float]14970  """Output only. Pointwise metric score."""149711497214973PointwiseMetricResultOrDict = Union[14974    PointwiseMetricResult, PointwiseMetricResultDict14975]149761497714978class RougeMetricValue(_common.BaseModel):14979  """Rouge metric value for an instance.1498014981  This data type is not supported in Gemini API.14982  """1498314984  score: Optional[float] = Field(14985      default=None, description="""Output only. Rouge score."""14986  )149871498814989class RougeMetricValueDict(TypedDict, total=False):14990  """Rouge metric value for an instance.1499114992  This data type is not supported in Gemini API.14993  """1499414995  score: Optional[float]14996  """Output only. Rouge score."""149971499814999RougeMetricValueOrDict = Union[RougeMetricValue, RougeMetricValueDict]150001500115002class AggregationResult(_common.BaseModel):15003  """The aggregation result for a single metric.1500415005  This data type is not supported in Gemini API.15006  """1500715008  aggregation_metric: Optional[AggregationMetric] = Field(15009      default=None, description="""Aggregation metric."""15010  )15011  bleu_metric_value: Optional[BleuMetricValue] = Field(15012      default=None, description="""Results for bleu metric."""15013  )15014  custom_code_execution_result: Optional[CustomCodeExecutionResult] = Field(15015      default=None, description="""Result for code execution metric."""15016  )15017  exact_match_metric_value: Optional[ExactMatchMetricValue] = Field(15018      default=None, description="""Results for exact match metric."""15019  )15020  pairwise_metric_result: Optional[PairwiseMetricResult] = Field(15021      default=None, description="""Result for pairwise metric."""15022  )15023  pointwise_metric_result: Optional[PointwiseMetricResult] = Field(15024      default=None, description="""Result for pointwise metric."""15025  )15026  rouge_metric_value: Optional[RougeMetricValue] = Field(15027      default=None, description="""Results for rouge metric."""15028  )150291503015031class AggregationResultDict(TypedDict, total=False):15032  """The aggregation result for a single metric.1503315034  This data type is not supported in Gemini API.15035  """1503615037  aggregation_metric: Optional[AggregationMetric]15038  """Aggregation metric."""1503915040  bleu_metric_value: Optional[BleuMetricValueDict]15041  """Results for bleu metric."""1504215043  custom_code_execution_result: Optional[CustomCodeExecutionResultDict]15044  """Result for code execution metric."""1504515046  exact_match_metric_value: Optional[ExactMatchMetricValueDict]15047  """Results for exact match metric."""1504815049  pairwise_metric_result: Optional[PairwiseMetricResultDict]15050  """Result for pairwise metric."""1505115052  pointwise_metric_result: Optional[PointwiseMetricResultDict]15053  """Result for pointwise metric."""1505415055  rouge_metric_value: Optional[RougeMetricValueDict]15056  """Results for rouge metric."""150571505815059AggregationResultOrDict = Union[AggregationResult, AggregationResultDict]150601506115062class BigQuerySource(_common.BaseModel):15063  """The BigQuery location for the input content.1506415065  This data type is not supported in Gemini API.15066  """1506715068  input_uri: Optional[str] = Field(15069      default=None,15070      description="""Required. BigQuery URI to a table, up to 2000 characters long. Accepted forms: * BigQuery path. For example: `bq://projectId.bqDatasetId.bqTableId`.""",15071  )150721507315074class BigQuerySourceDict(TypedDict, total=False):15075  """The BigQuery location for the input content.1507615077  This data type is not supported in Gemini API.15078  """1507915080  input_uri: Optional[str]15081  """Required. BigQuery URI to a table, up to 2000 characters long. Accepted forms: * BigQuery path. For example: `bq://projectId.bqDatasetId.bqTableId`."""150821508315084BigQuerySourceOrDict = Union[BigQuerySource, BigQuerySourceDict]150851508615087class GcsSource(_common.BaseModel):15088  """The Google Cloud Storage location for the input content.1508915090  This data type is not supported in Gemini API.15091  """1509215093  uris: Optional[list[str]] = Field(15094      default=None,15095      description="""Required. Google Cloud Storage URI(-s) to the input file(s). May contain wildcards. For more information on wildcards, see https://cloud.google.com/storage/docs/wildcards.""",15096  )150971509815099class GcsSourceDict(TypedDict, total=False):15100  """The Google Cloud Storage location for the input content.1510115102  This data type is not supported in Gemini API.15103  """1510415105  uris: Optional[list[str]]15106  """Required. Google Cloud Storage URI(-s) to the input file(s). May contain wildcards. For more information on wildcards, see https://cloud.google.com/storage/docs/wildcards."""151071510815109GcsSourceOrDict = Union[GcsSource, GcsSourceDict]151101511115112class EvaluationDataset(_common.BaseModel):15113  """The dataset used for evaluation.1511415115  This data type is not supported in Gemini API.15116  """1511715118  bigquery_source: Optional[BigQuerySource] = Field(15119      default=None, description="""BigQuery source holds the dataset."""15120  )15121  gcs_source: Optional[GcsSource] = Field(15122      default=None,15123      description="""Cloud storage source holds the dataset. Currently only one Cloud Storage file path is supported.""",15124  )151251512615127class EvaluationDatasetDict(TypedDict, total=False):15128  """The dataset used for evaluation.1512915130  This data type is not supported in Gemini API.15131  """1513215133  bigquery_source: Optional[BigQuerySourceDict]15134  """BigQuery source holds the dataset."""1513515136  gcs_source: Optional[GcsSourceDict]15137  """Cloud storage source holds the dataset. Currently only one Cloud Storage file path is supported."""151381513915140EvaluationDatasetOrDict = Union[EvaluationDataset, EvaluationDatasetDict]151411514215143class AggregationOutput(_common.BaseModel):15144  """The aggregation result for the entire dataset and all metrics.1514515146  This data type is not supported in Gemini API.15147  """1514815149  aggregation_results: Optional[list[AggregationResult]] = Field(15150      default=None, description="""One AggregationResult per metric."""15151  )15152  dataset: Optional[EvaluationDataset] = Field(15153      default=None,15154      description="""The dataset used for evaluation & aggregation.""",15155  )151561515715158class AggregationOutputDict(TypedDict, total=False):15159  """The aggregation result for the entire dataset and all metrics.1516015161  This data type is not supported in Gemini API.15162  """1516315164  aggregation_results: Optional[list[AggregationResultDict]]15165  """One AggregationResult per metric."""1516615167  dataset: Optional[EvaluationDatasetDict]15168  """The dataset used for evaluation & aggregation."""151691517015171AggregationOutputOrDict = Union[AggregationOutput, AggregationOutputDict]151721517315174class OutputInfo(_common.BaseModel):15175  """Describes the info for output of EvaluationService.1517615177  This data type is not supported in Gemini API.15178  """1517915180  gcs_output_directory: Optional[str] = Field(15181      default=None,15182      description="""Output only. The full path of the Cloud Storage directory created, into which the evaluation results and aggregation results are written.""",15183  )151841518515186class OutputInfoDict(TypedDict, total=False):15187  """Describes the info for output of EvaluationService.1518815189  This data type is not supported in Gemini API.15190  """1519115192  gcs_output_directory: Optional[str]15193  """Output only. The full path of the Cloud Storage directory created, into which the evaluation results and aggregation results are written."""151941519515196OutputInfoOrDict = Union[OutputInfo, OutputInfoDict]151971519815199class EvaluateDatasetResponse(_common.BaseModel):15200  """The results from an evaluation run performed by the EvaluationService.1520115202  This data type is not supported in Gemini API.15203  """1520415205  aggregation_output: Optional[AggregationOutput] = Field(15206      default=None,15207      description="""Output only. Aggregation statistics derived from results of EvaluationService.""",15208  )15209  output_info: Optional[OutputInfo] = Field(15210      default=None,15211      description="""Output only. Output info for EvaluationService.""",15212  )152131521415215class EvaluateDatasetResponseDict(TypedDict, total=False):15216  """The results from an evaluation run performed by the EvaluationService.1521715218  This data type is not supported in Gemini API.15219  """1522015221  aggregation_output: Optional[AggregationOutputDict]15222  """Output only. Aggregation statistics derived from results of EvaluationService."""1522315224  output_info: Optional[OutputInfoDict]15225  """Output only. Output info for EvaluationService."""152261522715228EvaluateDatasetResponseOrDict = Union[15229    EvaluateDatasetResponse, EvaluateDatasetResponseDict15230]152311523215233class EvaluateDatasetRun(_common.BaseModel):15234  """Evaluate Dataset Run Result for Tuning Job.1523515236  This data type is not supported in Gemini API.15237  """1523815239  checkpoint_id: Optional[str] = Field(15240      default=None,15241      description="""Output only. The checkpoint id used in the evaluation run. Only populated when evaluating checkpoints.""",15242  )15243  error: Optional[GoogleRpcStatus] = Field(15244      default=None,15245      description="""Output only. The error of the evaluation run if any.""",15246  )15247  evaluate_dataset_response: Optional[EvaluateDatasetResponse] = Field(15248      default=None,15249      description="""Output only. Results for EvaluationService.""",15250  )15251  evaluation_run: Optional[str] = Field(15252      default=None,15253      description="""Output only. The resource name of the evaluation run. Format: `projects/{project}/locations/{location}/evaluationRuns/{evaluation_run_id}`.""",15254  )15255  operation_name: Optional[str] = Field(15256      default=None,15257      description="""Output only. Deprecated: The updated architecture uses evaluation_run instead.""",15258  )152591526015261class EvaluateDatasetRunDict(TypedDict, total=False):15262  """Evaluate Dataset Run Result for Tuning Job.1526315264  This data type is not supported in Gemini API.15265  """1526615267  checkpoint_id: Optional[str]15268  """Output only. The checkpoint id used in the evaluation run. Only populated when evaluating checkpoints."""1526915270  error: Optional[GoogleRpcStatusDict]15271  """Output only. The error of the evaluation run if any."""1527215273  evaluate_dataset_response: Optional[EvaluateDatasetResponseDict]15274  """Output only. Results for EvaluationService."""1527515276  evaluation_run: Optional[str]15277  """Output only. The resource name of the evaluation run. Format: `projects/{project}/locations/{location}/evaluationRuns/{evaluation_run_id}`."""1527815279  operation_name: Optional[str]15280  """Output only. Deprecated: The updated architecture uses evaluation_run instead."""152811528215283EvaluateDatasetRunOrDict = Union[EvaluateDatasetRun, EvaluateDatasetRunDict]152841528515286class FullFineTuningSpec(_common.BaseModel):15287  """Tuning Spec for Full Fine Tuning.1528815289  This data type is not supported in Gemini API.15290  """1529115292  hyper_parameters: Optional[SupervisedHyperParameters] = Field(15293      default=None,15294      description="""Optional. Hyperparameters for Full Fine Tuning.""",15295  )15296  training_dataset_uri: Optional[str] = Field(15297      default=None,15298      description="""Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""",15299  )15300  validation_dataset_uri: Optional[str] = Field(15301      default=None,15302      description="""Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""",15303  )153041530515306class FullFineTuningSpecDict(TypedDict, total=False):15307  """Tuning Spec for Full Fine Tuning.1530815309  This data type is not supported in Gemini API.15310  """1531115312  hyper_parameters: Optional[SupervisedHyperParametersDict]15313  """Optional. Hyperparameters for Full Fine Tuning."""1531415315  training_dataset_uri: Optional[str]15316  """Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset."""1531715318  validation_dataset_uri: Optional[str]15319  """Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset."""153201532115322FullFineTuningSpecOrDict = Union[FullFineTuningSpec, FullFineTuningSpecDict]153231532415325class VeoHyperParameters(_common.BaseModel):15326  """Hyperparameters for Veo. This data type is not supported in Gemini API."""1532715328  epoch_count: Optional[int] = Field(15329      default=None,15330      description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""",15331  )15332  learning_rate_multiplier: Optional[float] = Field(15333      default=None,15334      description="""Optional. Multiplier for adjusting the default learning rate.""",15335  )15336  tuning_task: Optional[TuningTask] = Field(15337      default=None, description="""The tuning task for Veo."""15338  )15339  veo_data_mixture_ratio: Optional[float] = Field(15340      default=None,15341      description="""Optional. The ratio of Google internal dataset to use in the training mixture, in range of `[0, 1)`. If `0.2`, it means 20% of Google internal dataset and 80% of user dataset will be used for training. If not set, the default value is 0.1.""",15342  )15343  adapter_size: Optional[AdapterSize] = Field(15344      default=None,15345      description="""Optional. The adapter size for LoRA tuning.""",15346  )15347  tuning_speed: Optional[TuningSpeed] = Field(15348      default=None,15349      description="""The speed of the tuning job. Only supported for Veo 3.0 models.""",15350  )153511535215353class VeoHyperParametersDict(TypedDict, total=False):15354  """Hyperparameters for Veo. This data type is not supported in Gemini API."""1535515356  epoch_count: Optional[int]15357  """Optional. Number of complete passes the model makes over the entire training dataset during training."""1535815359  learning_rate_multiplier: Optional[float]15360  """Optional. Multiplier for adjusting the default learning rate."""1536115362  tuning_task: Optional[TuningTask]15363  """The tuning task for Veo."""1536415365  veo_data_mixture_ratio: Optional[float]15366  """Optional. The ratio of Google internal dataset to use in the training mixture, in range of `[0, 1)`. If `0.2`, it means 20% of Google internal dataset and 80% of user dataset will be used for training. If not set, the default value is 0.1."""1536715368  adapter_size: Optional[AdapterSize]15369  """Optional. The adapter size for LoRA tuning."""1537015371  tuning_speed: Optional[TuningSpeed]15372  """The speed of the tuning job. Only supported for Veo 3.0 models."""153731537415375VeoHyperParametersOrDict = Union[VeoHyperParameters, VeoHyperParametersDict]153761537715378class VeoTuningSpec(_common.BaseModel):15379  """Tuning Spec for Veo Model Tuning.1538015381  This data type is not supported in Gemini API.15382  """1538315384  hyper_parameters: Optional[VeoHyperParameters] = Field(15385      default=None, description="""Optional. Hyperparameters for Veo."""15386  )15387  training_dataset_uri: Optional[str] = Field(15388      default=None,15389      description="""Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""",15390  )15391  validation_dataset_uri: Optional[str] = Field(15392      default=None,15393      description="""Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""",15394  )153951539615397class VeoTuningSpecDict(TypedDict, total=False):15398  """Tuning Spec for Veo Model Tuning.1539915400  This data type is not supported in Gemini API.15401  """1540215403  hyper_parameters: Optional[VeoHyperParametersDict]15404  """Optional. Hyperparameters for Veo."""1540515406  training_dataset_uri: Optional[str]15407  """Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset."""1540815409  validation_dataset_uri: Optional[str]15410  """Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset."""154111541215413VeoTuningSpecOrDict = Union[VeoTuningSpec, VeoTuningSpecDict]154141541515416class TuningJobMetadata(_common.BaseModel):15417  """Tuning job metadata. This data type is not supported in Gemini API."""1541815419  completed_epoch_count: Optional[int] = Field(15420      default=None,15421      description="""Output only. The number of epochs that have been completed.""",15422  )15423  completed_step_count: Optional[int] = Field(15424      default=None,15425      description="""Output only. The number of steps that have been completed. Set for Multi-Step RL.""",15426  )154271542815429class TuningJobMetadataDict(TypedDict, total=False):15430  """Tuning job metadata. This data type is not supported in Gemini API."""1543115432  completed_epoch_count: Optional[int]15433  """Output only. The number of epochs that have been completed."""1543415435  completed_step_count: Optional[int]15436  """Output only. The number of steps that have been completed. Set for Multi-Step RL."""154371543815439TuningJobMetadataOrDict = Union[TuningJobMetadata, TuningJobMetadataDict]154401544115442class VeoLoraTuningSpec(_common.BaseModel):15443  """Tuning Spec for Veo LoRA Model Tuning.1544415445  This data type is not supported in Gemini API.15446  """1544715448  hyper_parameters: Optional[VeoHyperParameters] = Field(15449      default=None, description="""Optional. Hyperparameters for Veo LoRA."""15450  )15451  training_dataset_uri: Optional[str] = Field(15452      default=None,15453      description="""Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""",15454  )15455  validation_dataset_uri: Optional[str] = Field(15456      default=None,15457      description="""Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""",15458  )15459  video_orientation: Optional[VideoOrientation] = Field(15460      default=None,15461      description="""Optional. The orientation of the video. Defaults to LANDSCAPE.""",15462  )154631546415465class VeoLoraTuningSpecDict(TypedDict, total=False):15466  """Tuning Spec for Veo LoRA Model Tuning.1546715468  This data type is not supported in Gemini API.15469  """1547015471  hyper_parameters: Optional[VeoHyperParametersDict]15472  """Optional. Hyperparameters for Veo LoRA."""1547315474  training_dataset_uri: Optional[str]15475  """Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset."""1547615477  validation_dataset_uri: Optional[str]15478  """Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset."""1547915480  video_orientation: Optional[VideoOrientation]15481  """Optional. The orientation of the video. Defaults to LANDSCAPE."""154821548315484VeoLoraTuningSpecOrDict = Union[VeoLoraTuningSpec, VeoLoraTuningSpecDict]154851548615487class TuningJob(_common.BaseModel):15488  """A tuning job."""1548915490  sdk_http_response: Optional[HttpResponse] = Field(15491      default=None, description="""Used to retain the full HTTP response."""15492  )15493  name: Optional[str] = Field(15494      default=None,15495      description="""Output only. Identifier. Resource name of a TuningJob. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`""",15496  )15497  state: Optional[JobState] = Field(15498      default=None,15499      description="""Output only. The detailed state of the job.""",15500  )15501  create_time: Optional[datetime.datetime] = Field(15502      default=None,15503      description="""Output only. Time when the TuningJob was created.""",15504  )15505  start_time: Optional[datetime.datetime] = Field(15506      default=None,15507      description="""Output only. Time when the TuningJob for the first time entered the `JOB_STATE_RUNNING` state.""",15508  )15509  end_time: Optional[datetime.datetime] = Field(15510      default=None,15511      description="""Output only. Time when the TuningJob entered any of the following JobStates: `JOB_STATE_SUCCEEDED`, `JOB_STATE_FAILED`, `JOB_STATE_CANCELLED`, `JOB_STATE_EXPIRED`.""",15512  )15513  update_time: Optional[datetime.datetime] = Field(15514      default=None,15515      description="""Output only. Time when the TuningJob was most recently updated.""",15516  )15517  error: Optional[GoogleRpcStatus] = Field(15518      default=None,15519      description="""Output only. Only populated when job's state is `JOB_STATE_FAILED` or `JOB_STATE_CANCELLED`.""",15520  )15521  description: Optional[str] = Field(15522      default=None,15523      description="""Optional. The description of the TuningJob.""",15524  )15525  base_model: Optional[str] = Field(15526      default=None,15527      description="""The base model that is being tuned. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).""",15528  )15529  tuned_model: Optional[TunedModel] = Field(15530      default=None,15531      description="""Output only. The tuned model resources associated with this TuningJob.""",15532  )15533  pre_tuned_model: Optional[PreTunedModel] = Field(15534      default=None, description="""The pre-tuned model for continuous tuning."""15535  )15536  supervised_tuning_spec: Optional[SupervisedTuningSpec] = Field(15537      default=None, description="""Tuning Spec for Supervised Fine Tuning."""15538  )15539  preference_optimization_spec: Optional[PreferenceOptimizationSpec] = Field(15540      default=None, description="""Tuning Spec for Preference Optimization."""15541  )15542  distillation_spec: Optional[DistillationSpec] = Field(15543      default=None, description="""Tuning Spec for Distillation."""15544  )15545  reinforcement_tuning_spec: Optional[ReinforcementTuningSpec] = Field(15546      default=None, description="""Tuning Spec for Reinforcement Tuning."""15547  )15548  tuning_data_stats: Optional[TuningDataStats] = Field(15549      default=None,15550      description="""Output only. The tuning data statistics associated with this TuningJob.""",15551  )15552  encryption_spec: Optional[EncryptionSpec] = Field(15553      default=None,15554      description="""Customer-managed encryption key options for a TuningJob. If this is set, then all resources created by the TuningJob will be encrypted with the provided encryption key.""",15555  )15556  partner_model_tuning_spec: Optional[PartnerModelTuningSpec] = Field(15557      default=None,15558      description="""Tuning Spec for open sourced and third party Partner models.""",15559  )15560  evaluation_config: Optional[EvaluationConfig] = Field(15561      default=None, description="""Evaluation config for the tuning job."""15562  )15563  custom_base_model: Optional[str] = Field(15564      default=None,15565      description="""Optional. The user-provided path to custom model weights. Set this field to tune a custom model. The path must be a Cloud Storage directory that contains the model weights in .safetensors format along with associated model metadata files. If this field is set, the base_model field must still be set to indicate which base model the custom model is derived from. This feature is only available for open source models.""",15566  )15567  evaluate_dataset_runs: Optional[list[EvaluateDatasetRun]] = Field(15568      default=None,15569      description="""Output only. Evaluation runs for the Tuning Job.""",15570  )15571  experiment: Optional[str] = Field(15572      default=None,15573      description="""Output only. The Experiment associated with this TuningJob.""",15574  )15575  full_fine_tuning_spec: Optional[FullFineTuningSpec] = Field(15576      default=None, description="""Tuning Spec for Full Fine Tuning."""15577  )15578  labels: Optional[dict[str, str]] = Field(15579      default=None,15580      description="""Optional. The labels with user-defined metadata to organize TuningJob and generated resources such as Model and Endpoint. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.""",15581  )15582  output_uri: Optional[str] = Field(15583      default=None,15584      description="""Optional. Cloud Storage path to the directory where tuning job outputs are written to. This field is only available and required for open source models.""",15585  )15586  pipeline_job: Optional[str] = Field(15587      default=None,15588      description="""Output only. The resource name of the PipelineJob associated with the TuningJob. Format: `projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}`.""",15589  )15590  service_account: Optional[str] = Field(15591      default=None,15592      description="""The service account that the tuningJob workload runs as. If not specified, the Vertex AI Secure Fine-Tuned Service Agent in the project will be used. See https://cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent Users starting the pipeline must have the `iam.serviceAccounts.actAs` permission on this service account.""",15593  )15594  tuned_model_display_name: Optional[str] = Field(15595      default=None,15596      description="""Optional. The display name of the TunedModel. The name can be up to 128 characters long and can consist of any UTF-8 characters. For continuous tuning, tuned_model_display_name will by default use the same display name as the pre-tuned model. If a new display name is provided, the tuning job will create a new model instead of a new version.""",15597  )15598  tuning_job_state: Optional[TuningJobState] = Field(15599      default=None,15600      description="""Output only. The detail state of the tuning job (while the overall `JobState` is running).""",15601  )15602  veo_tuning_spec: Optional[VeoTuningSpec] = Field(15603      default=None, description="""Tuning Spec for Veo Tuning."""15604  )15605  tuning_job_metadata: Optional[TuningJobMetadata] = Field(15606      default=None, description="""Output only. Tuning Job metadata."""15607  )15608  veo_lora_tuning_spec: Optional[VeoLoraTuningSpec] = Field(15609      default=None, description="""Tuning Spec for Veo LoRA Tuning."""15610  )15611  distillation_sampling_spec: Optional[DistillationSamplingSpec] = Field(15612      default=None, description=""""""15613  )1561415615  @property15616  def has_ended(self) -> bool:15617    """Whether the tuning job has ended."""15618    return self.state in JOB_STATES_ENDED1561915620  @property15621  def has_succeeded(self) -> bool:15622    """Whether the tuning job has succeeded."""15623    return self.state in JOB_STATES_SUCCEEDED156241562515626class TuningJobDict(TypedDict, total=False):15627  """A tuning job."""1562815629  sdk_http_response: Optional[HttpResponseDict]15630  """Used to retain the full HTTP response."""1563115632  name: Optional[str]15633  """Output only. Identifier. Resource name of a TuningJob. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`"""1563415635  state: Optional[JobState]15636  """Output only. The detailed state of the job."""1563715638  create_time: Optional[datetime.datetime]15639  """Output only. Time when the TuningJob was created."""1564015641  start_time: Optional[datetime.datetime]15642  """Output only. Time when the TuningJob for the first time entered the `JOB_STATE_RUNNING` state."""1564315644  end_time: Optional[datetime.datetime]15645  """Output only. Time when the TuningJob entered any of the following JobStates: `JOB_STATE_SUCCEEDED`, `JOB_STATE_FAILED`, `JOB_STATE_CANCELLED`, `JOB_STATE_EXPIRED`."""1564615647  update_time: Optional[datetime.datetime]15648  """Output only. Time when the TuningJob was most recently updated."""1564915650  error: Optional[GoogleRpcStatusDict]15651  """Output only. Only populated when job's state is `JOB_STATE_FAILED` or `JOB_STATE_CANCELLED`."""1565215653  description: Optional[str]15654  """Optional. The description of the TuningJob."""1565515656  base_model: Optional[str]15657  """The base model that is being tuned. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models)."""1565815659  tuned_model: Optional[TunedModelDict]15660  """Output only. The tuned model resources associated with this TuningJob."""1566115662  pre_tuned_model: Optional[PreTunedModelDict]15663  """The pre-tuned model for continuous tuning."""1566415665  supervised_tuning_spec: Optional[SupervisedTuningSpecDict]15666  """Tuning Spec for Supervised Fine Tuning."""1566715668  preference_optimization_spec: Optional[PreferenceOptimizationSpecDict]15669  """Tuning Spec for Preference Optimization."""1567015671  distillation_spec: Optional[DistillationSpecDict]15672  """Tuning Spec for Distillation."""1567315674  reinforcement_tuning_spec: Optional[ReinforcementTuningSpecDict]15675  """Tuning Spec for Reinforcement Tuning."""1567615677  tuning_data_stats: Optional[TuningDataStatsDict]15678  """Output only. The tuning data statistics associated with this TuningJob."""1567915680  encryption_spec: Optional[EncryptionSpecDict]15681  """Customer-managed encryption key options for a TuningJob. If this is set, then all resources created by the TuningJob will be encrypted with the provided encryption key."""1568215683  partner_model_tuning_spec: Optional[PartnerModelTuningSpecDict]15684  """Tuning Spec for open sourced and third party Partner models."""1568515686  evaluation_config: Optional[EvaluationConfigDict]15687  """Evaluation config for the tuning job."""1568815689  custom_base_model: Optional[str]15690  """Optional. The user-provided path to custom model weights. Set this field to tune a custom model. The path must be a Cloud Storage directory that contains the model weights in .safetensors format along with associated model metadata files. If this field is set, the base_model field must still be set to indicate which base model the custom model is derived from. This feature is only available for open source models."""1569115692  evaluate_dataset_runs: Optional[list[EvaluateDatasetRunDict]]15693  """Output only. Evaluation runs for the Tuning Job."""1569415695  experiment: Optional[str]15696  """Output only. The Experiment associated with this TuningJob."""1569715698  full_fine_tuning_spec: Optional[FullFineTuningSpecDict]15699  """Tuning Spec for Full Fine Tuning."""1570015701  labels: Optional[dict[str, str]]15702  """Optional. The labels with user-defined metadata to organize TuningJob and generated resources such as Model and Endpoint. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels."""1570315704  output_uri: Optional[str]15705  """Optional. Cloud Storage path to the directory where tuning job outputs are written to. This field is only available and required for open source models."""1570615707  pipeline_job: Optional[str]15708  """Output only. The resource name of the PipelineJob associated with the TuningJob. Format: `projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}`."""1570915710  service_account: Optional[str]15711  """The service account that the tuningJob workload runs as. If not specified, the Vertex AI Secure Fine-Tuned Service Agent in the project will be used. See https://cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent Users starting the pipeline must have the `iam.serviceAccounts.actAs` permission on this service account."""1571215713  tuned_model_display_name: Optional[str]15714  """Optional. The display name of the TunedModel. The name can be up to 128 characters long and can consist of any UTF-8 characters. For continuous tuning, tuned_model_display_name will by default use the same display name as the pre-tuned model. If a new display name is provided, the tuning job will create a new model instead of a new version."""1571515716  tuning_job_state: Optional[TuningJobState]15717  """Output only. The detail state of the tuning job (while the overall `JobState` is running)."""1571815719  veo_tuning_spec: Optional[VeoTuningSpecDict]15720  """Tuning Spec for Veo Tuning."""1572115722  tuning_job_metadata: Optional[TuningJobMetadataDict]15723  """Output only. Tuning Job metadata."""1572415725  veo_lora_tuning_spec: Optional[VeoLoraTuningSpecDict]15726  """Tuning Spec for Veo LoRA Tuning."""1572715728  distillation_sampling_spec: Optional[DistillationSamplingSpecDict]15729  """"""157301573115732TuningJobOrDict = Union[TuningJob, TuningJobDict]157331573415735class ListTuningJobsConfig(_common.BaseModel):15736  """Configuration for the list tuning jobs method."""1573715738  http_options: Optional[HttpOptions] = Field(15739      default=None, description="""Used to override HTTP request options."""15740  )15741  page_size: Optional[int] = Field(default=None, description="""""")15742  page_token: Optional[str] = Field(default=None, description="""""")15743  filter: Optional[str] = Field(default=None, description="""""")157441574515746class ListTuningJobsConfigDict(TypedDict, total=False):15747  """Configuration for the list tuning jobs method."""1574815749  http_options: Optional[HttpOptionsDict]15750  """Used to override HTTP request options."""1575115752  page_size: Optional[int]15753  """"""1575415755  page_token: Optional[str]15756  """"""1575715758  filter: Optional[str]15759  """"""157601576115762ListTuningJobsConfigOrDict = Union[15763    ListTuningJobsConfig, ListTuningJobsConfigDict15764]157651576615767class _ListTuningJobsParameters(_common.BaseModel):15768  """Parameters for the list tuning jobs method."""1576915770  config: Optional[ListTuningJobsConfig] = Field(15771      default=None, description=""""""15772  )157731577415775class _ListTuningJobsParametersDict(TypedDict, total=False):15776  """Parameters for the list tuning jobs method."""1577715778  config: Optional[ListTuningJobsConfigDict]15779  """"""157801578115782_ListTuningJobsParametersOrDict = Union[15783    _ListTuningJobsParameters, _ListTuningJobsParametersDict15784]157851578615787class ListTuningJobsResponse(_common.BaseModel):15788  """Response for the list tuning jobs method."""1578915790  sdk_http_response: Optional[HttpResponse] = Field(15791      default=None, description="""Used to retain the full HTTP response."""15792  )15793  next_page_token: Optional[str] = Field(15794      default=None,15795      description="""A token to retrieve the next page of results. Pass this token in a subsequent [GenAiTuningService.ListTuningJobs] call to retrieve the next page of results.""",15796  )15797  tuning_jobs: Optional[list[TuningJob]] = Field(15798      default=None, description="""The tuning jobs that match the request."""15799  )158001580115802class ListTuningJobsResponseDict(TypedDict, total=False):15803  """Response for the list tuning jobs method."""1580415805  sdk_http_response: Optional[HttpResponseDict]15806  """Used to retain the full HTTP response."""1580715808  next_page_token: Optional[str]15809  """A token to retrieve the next page of results. Pass this token in a subsequent [GenAiTuningService.ListTuningJobs] call to retrieve the next page of results."""1581015811  tuning_jobs: Optional[list[TuningJobDict]]15812  """The tuning jobs that match the request."""158131581415815ListTuningJobsResponseOrDict = Union[15816    ListTuningJobsResponse, ListTuningJobsResponseDict15817]158181581915820class CancelTuningJobConfig(_common.BaseModel):15821  """Optional parameters for tunings.cancel method."""1582215823  http_options: Optional[HttpOptions] = Field(15824      default=None, description="""Used to override HTTP request options."""15825  )158261582715828class CancelTuningJobConfigDict(TypedDict, total=False):15829  """Optional parameters for tunings.cancel method."""1583015831  http_options: Optional[HttpOptionsDict]15832  """Used to override HTTP request options."""158331583415835CancelTuningJobConfigOrDict = Union[15836    CancelTuningJobConfig, CancelTuningJobConfigDict15837]158381583915840class _CancelTuningJobParameters(_common.BaseModel):15841  """Parameters for the cancel method."""1584215843  name: Optional[str] = Field(15844      default=None, description="""The resource name of the tuning job."""15845  )15846  config: Optional[CancelTuningJobConfig] = Field(15847      default=None, description="""Optional parameters for the request."""15848  )158491585015851class _CancelTuningJobParametersDict(TypedDict, total=False):15852  """Parameters for the cancel method."""1585315854  name: Optional[str]15855  """The resource name of the tuning job."""1585615857  config: Optional[CancelTuningJobConfigDict]15858  """Optional parameters for the request."""158591586015861_CancelTuningJobParametersOrDict = Union[15862    _CancelTuningJobParameters, _CancelTuningJobParametersDict15863]158641586515866class CancelTuningJobResponse(_common.BaseModel):15867  """Empty response for tunings.cancel method."""1586815869  sdk_http_response: Optional[HttpResponse] = Field(15870      default=None, description="""Used to retain the full HTTP response."""15871  )158721587315874class CancelTuningJobResponseDict(TypedDict, total=False):15875  """Empty response for tunings.cancel method."""1587615877  sdk_http_response: Optional[HttpResponseDict]15878  """Used to retain the full HTTP response."""158791588015881CancelTuningJobResponseOrDict = Union[15882    CancelTuningJobResponse, CancelTuningJobResponseDict15883]158841588515886class TuningExample(_common.BaseModel):15887  """A single example for tuning.1588815889  This data type is not supported in Vertex AI.15890  """1589115892  output: Optional[str] = Field(15893      default=None, description="""Required. The expected model output."""15894  )15895  text_input: Optional[str] = Field(15896      default=None, description="""Optional. Text model input."""15897  )158981589915900class TuningExampleDict(TypedDict, total=False):15901  """A single example for tuning.1590215903  This data type is not supported in Vertex AI.15904  """1590515906  output: Optional[str]15907  """Required. The expected model output."""1590815909  text_input: Optional[str]15910  """Optional. Text model input."""159111591215913TuningExampleOrDict = Union[TuningExample, TuningExampleDict]159141591515916class TuningDataset(_common.BaseModel):15917  """Supervised fine-tuning training dataset."""1591815919  gcs_uri: Optional[str] = Field(15920      default=None,15921      description="""GCS URI of the file containing training dataset in JSONL format.""",15922  )15923  vertex_dataset_resource: Optional[str] = Field(15924      default=None,15925      description="""The resource name of the Gemini Enterprise Agent Platform (previously known as Vertex AI) Multimodal Dataset that is used as training dataset. Example: 'projects/my-project-id-or-number/locations/my-location/datasets/my-dataset-id'.""",15926  )15927  examples: Optional[list[TuningExample]] = Field(15928      default=None,15929      description="""Inline examples with simple input/output text.""",15930  )159311593215933class TuningDatasetDict(TypedDict, total=False):15934  """Supervised fine-tuning training dataset."""1593515936  gcs_uri: Optional[str]15937  """GCS URI of the file containing training dataset in JSONL format."""1593815939  vertex_dataset_resource: Optional[str]15940  """The resource name of the Gemini Enterprise Agent Platform (previously known as Vertex AI) Multimodal Dataset that is used as training dataset. Example: 'projects/my-project-id-or-number/locations/my-location/datasets/my-dataset-id'."""1594115942  examples: Optional[list[TuningExampleDict]]15943  """Inline examples with simple input/output text."""159441594515946TuningDatasetOrDict = Union[TuningDataset, TuningDatasetDict]159471594815949class TuningValidationDataset(_common.BaseModel):1595015951  gcs_uri: Optional[str] = Field(15952      default=None,15953      description="""GCS URI of the file containing validation dataset in JSONL format.""",15954  )15955  vertex_dataset_resource: Optional[str] = Field(15956      default=None,15957      description="""The resource name of the Gemini Enterprise Agent Platform (previously known as Vertex AI) Multimodal Dataset that is used as validation dataset. Example: 'projects/my-project-id-or-number/locations/my-location/datasets/my-dataset-id'.""",15958  )159591596015961class TuningValidationDatasetDict(TypedDict, total=False):1596215963  gcs_uri: Optional[str]15964  """GCS URI of the file containing validation dataset in JSONL format."""1596515966  vertex_dataset_resource: Optional[str]15967  """The resource name of the Gemini Enterprise Agent Platform (previously known as Vertex AI) Multimodal Dataset that is used as validation dataset. Example: 'projects/my-project-id-or-number/locations/my-location/datasets/my-dataset-id'."""159681596915970TuningValidationDatasetOrDict = Union[15971    TuningValidationDataset, TuningValidationDatasetDict15972]159731597415975class CreateTuningJobConfig(_common.BaseModel):15976  """Fine-tuning job creation request - optional fields."""1597715978  http_options: Optional[HttpOptions] = Field(15979      default=None, description="""Used to override HTTP request options."""15980  )15981  method: Optional[TuningMethod] = Field(15982      default=None,15983      description="""The method to use for tuning (SUPERVISED_FINE_TUNING or PREFERENCE_TUNING or DISTILLATION or REINFORCEMENT_TUNING). If not set, the default method (SFT) will be used.""",15984  )15985  validation_dataset: Optional[TuningValidationDataset] = Field(15986      default=None,15987      description="""Validation dataset for tuning. The dataset must be formatted as a JSONL file.""",15988  )15989  tuned_model_display_name: Optional[str] = Field(15990      default=None,15991      description="""The display name of the tuned Model. The name can be up to 128 characters long and can consist of any UTF-8 characters.""",15992  )15993  description: Optional[str] = Field(15994      default=None, description="""The description of the TuningJob"""15995  )15996  epoch_count: Optional[int] = Field(15997      default=None,15998      description="""Number of complete passes the model makes over the entire training dataset during training.""",15999  )16000  learning_rate_multiplier: Optional[float] = Field(16001      default=None,16002      description="""Multiplier for adjusting the default learning rate. 1P models only. Mutually exclusive with learning_rate.""",16003  )16004  export_last_checkpoint_only: Optional[bool] = Field(16005      default=None,16006      description="""If set to true, disable intermediate checkpoints and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints.""",16007  )16008  pre_tuned_model_checkpoint_id: Optional[str] = Field(16009      default=None,16010      description="""The optional checkpoint id of the pre-tuned model to use for tuning, if applicable.""",16011  )16012  adapter_size: Optional[AdapterSize] = Field(16013      default=None, description="""Adapter size for tuning."""16014  )16015  tuning_mode: Optional[TuningMode] = Field(16016      default=None, description="""Tuning mode for tuning."""16017  )16018  custom_base_model: Optional[str] = Field(16019      default=None,16020      description="""Custom base model for tuning. This is only supported for OSS models in Gemini Enterprise Agent Platform.""",16021  )16022  batch_size: Optional[int] = Field(16023      default=None,16024      description="""The batch size hyperparameter for tuning. This is only supported for OSS models in Gemini Enterprise Agent Platform.""",16025  )16026  learning_rate: Optional[float] = Field(16027      default=None,16028      description="""The learning rate for tuning. OSS models only. Mutually exclusive with learning_rate_multiplier.""",16029  )16030  evaluation_config: Optional[EvaluationConfig] = Field(16031      default=None, description="""Evaluation config for the tuning job."""16032  )16033  labels: Optional[dict[str, str]] = Field(16034      default=None,16035      description="""Optional. The labels with user-defined metadata to organize TuningJob and generated resources such as Model and Endpoint. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels.""",16036  )16037  beta: Optional[float] = Field(16038      default=None,16039      description="""Weight for KL Divergence regularization, Preference Optimization tuning only.""",16040  )16041  base_teacher_model: Optional[str] = Field(16042      default=None,16043      description="""The base teacher model that is being distilled. Distillation only.""",16044  )16045  tuned_teacher_model_source: Optional[str] = Field(16046      default=None,16047      description="""The resource name of the Tuned teacher model. Distillation only.""",16048  )16049  sft_loss_weight_multiplier: Optional[float] = Field(16050      default=None,16051      description="""Multiplier for adjusting the weight of the SFT loss. Distillation only.""",16052  )16053  output_uri: Optional[str] = Field(16054      default=None,16055      description="""The Google Cloud Storage location where the tuning job outputs are written.""",16056  )16057  encryption_spec: Optional[EncryptionSpec] = Field(16058      default=None,16059      description="""The encryption spec of the tuning job. Customer-managed encryption key options for a TuningJob. If this is set, then all resources created by the TuningJob will be encrypted with provided encryption key.""",16060  )16061  reward_config: Optional[SingleReinforcementTuningRewardConfig] = Field(16062      default=None,16063      description="""Reward function configuration for reinforcement tuning. Reinforcement tuning only.""",16064  )16065  composite_reward_config: Optional[16066      CompositeReinforcementTuningRewardConfig16067  ] = Field(16068      default=None,16069      description="""Composite reward function configuration for reinforcement tuning. Reinforcement tuning only.""",16070  )16071  samples_per_prompt: Optional[int] = Field(16072      default=None,16073      description="""Number of different responses to generate per prompt during tuning. Reinforcement tuning only.""",16074  )16075  evaluate_interval: Optional[int] = Field(16076      default=None,16077      description="""How often at steps to evaluate the tuning job during training. Reinforcement tuning only.""",16078  )16079  checkpoint_interval: Optional[int] = Field(16080      default=None,16081      description="""How often at steps to save checkpoints during training. Reinforcement tuning only.""",16082  )16083  max_output_tokens: Optional[int] = Field(16084      default=None,16085      description="""The maximum number of tokens to generate per prompt. Reinforcement tuning only.""",16086  )16087  thinking_level: Optional[ReinforcementTuningThinkingLevel] = Field(16088      default=None,16089      description="""Indicates the maximum thinking depth. Use with earlier models shall result in error. Reinforcement tuning only.""",16090  )16091  validation_dataset_uri: Optional[str] = Field(16092      default=None,16093      description="""Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file. If no validation dataset is provided, by default the API splits 25% of the training dataset or 50 examples, whichever is larger, as the validation dataset. Reinforcement tuning only.""",16094  )160951609616097class CreateTuningJobConfigDict(TypedDict, total=False):16098  """Fine-tuning job creation request - optional fields."""1609916100  http_options: Optional[HttpOptionsDict]16101  """Used to override HTTP request options."""1610216103  method: Optional[TuningMethod]16104  """The method to use for tuning (SUPERVISED_FINE_TUNING or PREFERENCE_TUNING or DISTILLATION or REINFORCEMENT_TUNING). If not set, the default method (SFT) will be used."""1610516106  validation_dataset: Optional[TuningValidationDatasetDict]16107  """Validation dataset for tuning. The dataset must be formatted as a JSONL file."""1610816109  tuned_model_display_name: Optional[str]16110  """The display name of the tuned Model. The name can be up to 128 characters long and can consist of any UTF-8 characters."""1611116112  description: Optional[str]16113  """The description of the TuningJob"""1611416115  epoch_count: Optional[int]16116  """Number of complete passes the model makes over the entire training dataset during training."""1611716118  learning_rate_multiplier: Optional[float]16119  """Multiplier for adjusting the default learning rate. 1P models only. Mutually exclusive with learning_rate."""1612016121  export_last_checkpoint_only: Optional[bool]16122  """If set to true, disable intermediate checkpoints and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints."""1612316124  pre_tuned_model_checkpoint_id: Optional[str]16125  """The optional checkpoint id of the pre-tuned model to use for tuning, if applicable."""1612616127  adapter_size: Optional[AdapterSize]16128  """Adapter size for tuning."""1612916130  tuning_mode: Optional[TuningMode]16131  """Tuning mode for tuning."""1613216133  custom_base_model: Optional[str]16134  """Custom base model for tuning. This is only supported for OSS models in Gemini Enterprise Agent Platform."""1613516136  batch_size: Optional[int]16137  """The batch size hyperparameter for tuning. This is only supported for OSS models in Gemini Enterprise Agent Platform."""1613816139  learning_rate: Optional[float]16140  """The learning rate for tuning. OSS models only. Mutually exclusive with learning_rate_multiplier."""1614116142  evaluation_config: Optional[EvaluationConfigDict]16143  """Evaluation config for the tuning job."""1614416145  labels: Optional[dict[str, str]]16146  """Optional. The labels with user-defined metadata to organize TuningJob and generated resources such as Model and Endpoint. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information and examples of labels."""1614716148  beta: Optional[float]16149  """Weight for KL Divergence regularization, Preference Optimization tuning only."""1615016151  base_teacher_model: Optional[str]16152  """The base teacher model that is being distilled. Distillation only."""1615316154  tuned_teacher_model_source: Optional[str]16155  """The resource name of the Tuned teacher model. Distillation only."""1615616157  sft_loss_weight_multiplier: Optional[float]16158  """Multiplier for adjusting the weight of the SFT loss. Distillation only."""1615916160  output_uri: Optional[str]16161  """The Google Cloud Storage location where the tuning job outputs are written."""1616216163  encryption_spec: Optional[EncryptionSpecDict]16164  """The encryption spec of the tuning job. Customer-managed encryption key options for a TuningJob. If this is set, then all resources created by the TuningJob will be encrypted with provided encryption key."""1616516166  reward_config: Optional[SingleReinforcementTuningRewardConfigDict]16167  """Reward function configuration for reinforcement tuning. Reinforcement tuning only."""1616816169  composite_reward_config: Optional[16170      CompositeReinforcementTuningRewardConfigDict16171  ]16172  """Composite reward function configuration for reinforcement tuning. Reinforcement tuning only."""1617316174  samples_per_prompt: Optional[int]16175  """Number of different responses to generate per prompt during tuning. Reinforcement tuning only."""1617616177  evaluate_interval: Optional[int]16178  """How often at steps to evaluate the tuning job during training. Reinforcement tuning only."""1617916180  checkpoint_interval: Optional[int]16181  """How often at steps to save checkpoints during training. Reinforcement tuning only."""1618216183  max_output_tokens: Optional[int]16184  """The maximum number of tokens to generate per prompt. Reinforcement tuning only."""1618516186  thinking_level: Optional[ReinforcementTuningThinkingLevel]16187  """Indicates the maximum thinking depth. Use with earlier models shall result in error. Reinforcement tuning only."""1618816189  validation_dataset_uri: Optional[str]16190  """Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file. If no validation dataset is provided, by default the API splits 25% of the training dataset or 50 examples, whichever is larger, as the validation dataset. Reinforcement tuning only."""161911619216193CreateTuningJobConfigOrDict = Union[16194    CreateTuningJobConfig, CreateTuningJobConfigDict16195]161961619716198class _CreateTuningJobParametersPrivate(_common.BaseModel):16199  """Fine-tuning job creation parameters - optional fields."""1620016201  base_model: Optional[str] = Field(16202      default=None,16203      description="""The base model that is being tuned, e.g., "gemini-2.5-flash".""",16204  )16205  pre_tuned_model: Optional[PreTunedModel] = Field(16206      default=None, description="""The PreTunedModel that is being tuned."""16207  )16208  training_dataset: Optional[TuningDataset] = Field(16209      default=None,16210      description="""Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""",16211  )16212  config: Optional[CreateTuningJobConfig] = Field(16213      default=None, description="""Configuration for the tuning job."""16214  )162151621616217class _CreateTuningJobParametersPrivateDict(TypedDict, total=False):16218  """Fine-tuning job creation parameters - optional fields."""1621916220  base_model: Optional[str]16221  """The base model that is being tuned, e.g., "gemini-2.5-flash"."""1622216223  pre_tuned_model: Optional[PreTunedModelDict]16224  """The PreTunedModel that is being tuned."""1622516226  training_dataset: Optional[TuningDatasetDict]16227  """Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file."""1622816229  config: Optional[CreateTuningJobConfigDict]16230  """Configuration for the tuning job."""162311623216233_CreateTuningJobParametersPrivateOrDict = Union[16234    _CreateTuningJobParametersPrivate, _CreateTuningJobParametersPrivateDict16235]162361623716238class TuningOperation(_common.BaseModel):16239  """A long-running operation."""1624016241  sdk_http_response: Optional[HttpResponse] = Field(16242      default=None, description="""Used to retain the full HTTP response."""16243  )16244  name: Optional[str] = Field(16245      default=None,16246      description="""The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.""",16247  )16248  metadata: Optional[dict[str, Any]] = Field(16249      default=None,16250      description="""Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata.  Any method that returns a long-running operation should document the metadata type, if any.""",16251  )16252  done: Optional[bool] = Field(16253      default=None,16254      description="""If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.""",16255  )16256  error: Optional[dict[str, Any]] = Field(16257      default=None,16258      description="""The error result of the operation in case of failure or cancellation.""",16259  )162601626116262class TuningOperationDict(TypedDict, total=False):16263  """A long-running operation."""1626416265  sdk_http_response: Optional[HttpResponseDict]16266  """Used to retain the full HTTP response."""1626716268  name: Optional[str]16269  """The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`."""1627016271  metadata: Optional[dict[str, Any]]16272  """Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata.  Any method that returns a long-running operation should document the metadata type, if any."""1627316274  done: Optional[bool]16275  """If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available."""1627616277  error: Optional[dict[str, Any]]16278  """The error result of the operation in case of failure or cancellation."""162791628016281TuningOperationOrDict = Union[TuningOperation, TuningOperationDict]162821628316284class ValidateRewardConfig(_common.BaseModel):16285  """Optional parameters for tunings.validate_reward."""1628616287  http_options: Optional[HttpOptions] = Field(16288      default=None, description="""Used to override HTTP request options."""16289  )162901629116292class ValidateRewardConfigDict(TypedDict, total=False):16293  """Optional parameters for tunings.validate_reward."""1629416295  http_options: Optional[HttpOptionsDict]16296  """Used to override HTTP request options."""162971629816299ValidateRewardConfigOrDict = Union[16300    ValidateRewardConfig, ValidateRewardConfigDict16301]163021630316304class _ValidateRewardParameters(_common.BaseModel):16305  """Parameters for the validate_reward method.1630616307  Validates a reinforcement tuning reward configuration against a sample16308  response and example before creating a reinforcement tuning job.16309  """1631016311  parent: Optional[str] = Field(16312      default=None,16313      description="""Required. The resource name of the Location to validate the reward in, e.g. `projects/{project}/locations/{location}`.""",16314  )16315  sample_response: Optional[Content] = Field(16316      default=None,16317      description="""Required. The sample response for validating the reward configuration.""",16318  )16319  example: Optional[ReinforcementTuningExample] = Field(16320      default=None,16321      description="""Required. The example to validate the reward configuration.""",16322  )16323  single_reward_config: Optional[SingleReinforcementTuningRewardConfig] = Field(16324      default=None,16325      description="""Single reward function configuration for reinforcement tuning. Mutually exclusive with composite_reward_config.""",16326  )16327  composite_reward_config: Optional[16328      CompositeReinforcementTuningRewardConfig16329  ] = Field(16330      default=None,16331      description="""Composite reward function configuration for reinforcement tuning. Mutually exclusive with single_reward_config.""",16332  )16333  config: Optional[ValidateRewardConfig] = Field(16334      default=None, description="""Optional parameters for the request."""16335  )163361633716338class _ValidateRewardParametersDict(TypedDict, total=False):16339  """Parameters for the validate_reward method.1634016341  Validates a reinforcement tuning reward configuration against a sample16342  response and example before creating a reinforcement tuning job.16343  """1634416345  parent: Optional[str]16346  """Required. The resource name of the Location to validate the reward in, e.g. `projects/{project}/locations/{location}`."""1634716348  sample_response: Optional[ContentDict]16349  """Required. The sample response for validating the reward configuration."""1635016351  example: Optional[ReinforcementTuningExampleDict]16352  """Required. The example to validate the reward configuration."""1635316354  single_reward_config: Optional[SingleReinforcementTuningRewardConfigDict]16355  """Single reward function configuration for reinforcement tuning. Mutually exclusive with composite_reward_config."""1635616357  composite_reward_config: Optional[16358      CompositeReinforcementTuningRewardConfigDict16359  ]16360  """Composite reward function configuration for reinforcement tuning. Mutually exclusive with single_reward_config."""1636116362  config: Optional[ValidateRewardConfigDict]16363  """Optional parameters for the request."""163641636516366_ValidateRewardParametersOrDict = Union[16367    _ValidateRewardParameters, _ValidateRewardParametersDict16368]163691637016371class ReinforcementTuningRewardInfo(_common.BaseModel):16372  """The reward info for a reward function."""1637316374  reward: Optional[float] = Field(16375      default=None,16376      description="""Output only. The calculated reward for the reward function.""",16377  )16378  user_requested_aux_info: Optional[str] = Field(16379      default=None,16380      description="""Output only. The user-requested auxiliary info for the reward function. This field is set only if the Cloud Run reward function configured by user returns a "user_requested_aux_info". Refer to ReinforcementTuningCloudRunRewardScorer for more details.""",16381  )16382  error_status: Optional[GoogleRpcStatus] = Field(16383      default=None,16384      description="""Output only. In case of an error for this reward, this field will be populated with a detailed error status.""",16385  )163861638716388class ReinforcementTuningRewardInfoDict(TypedDict, total=False):16389  """The reward info for a reward function."""1639016391  reward: Optional[float]16392  """Output only. The calculated reward for the reward function."""1639316394  user_requested_aux_info: Optional[str]16395  """Output only. The user-requested auxiliary info for the reward function. This field is set only if the Cloud Run reward function configured by user returns a "user_requested_aux_info". Refer to ReinforcementTuningCloudRunRewardScorer for more details."""1639616397  error_status: Optional[GoogleRpcStatusDict]16398  """Output only. In case of an error for this reward, this field will be populated with a detailed error status."""163991640016401ReinforcementTuningRewardInfoOrDict = Union[16402    ReinforcementTuningRewardInfo, ReinforcementTuningRewardInfoDict16403]164041640516406class ValidateRewardResponse(_common.BaseModel):16407  """Response for the validate_reward method.1640816409  Contains the computed reward for a reinforcement tuning reward16410  configuration.16411  """1641216413  sdk_http_response: Optional[HttpResponse] = Field(16414      default=None, description="""Used to retain the full HTTP response."""16415  )16416  overall_reward: Optional[float] = Field(16417      default=None,16418      description="""Output only. The overall weighted reward. For a `CompositeReinforcementTuningRewardConfig`, this is the weighted average of all rewards. For a `SingleReinforcementTuningRewardConfig`, this will be the value of the single reward.""",16419  )16420  error: Optional[str] = Field(16421      default=None,16422      description="""Output only. In case of an error, this field will be populated with a detailed error message to help with debugging.""",16423  )16424  reward_info_details: Optional[dict[str, ReinforcementTuningRewardInfo]] = (16425      Field(16426          default=None, description="""A map from reward name to reward info."""16427      )16428  )164291643016431class ValidateRewardResponseDict(TypedDict, total=False):16432  """Response for the validate_reward method.1643316434  Contains the computed reward for a reinforcement tuning reward16435  configuration.16436  """1643716438  sdk_http_response: Optional[HttpResponseDict]16439  """Used to retain the full HTTP response."""1644016441  overall_reward: Optional[float]16442  """Output only. The overall weighted reward. For a `CompositeReinforcementTuningRewardConfig`, this is the weighted average of all rewards. For a `SingleReinforcementTuningRewardConfig`, this will be the value of the single reward."""1644316444  error: Optional[str]16445  """Output only. In case of an error, this field will be populated with a detailed error message to help with debugging."""1644616447  reward_info_details: Optional[dict[str, ReinforcementTuningRewardInfoDict]]16448  """A map from reward name to reward info."""164491645016451ValidateRewardResponseOrDict = Union[16452    ValidateRewardResponse, ValidateRewardResponseDict16453]164541645516456class CreateCachedContentConfig(_common.BaseModel):16457  """Optional configuration for cached content creation."""1645816459  http_options: Optional[HttpOptions] = Field(16460      default=None, description="""Used to override HTTP request options."""16461  )16462  ttl: Optional[str] = Field(16463      default=None,16464      description="""The TTL for this resource. The expiration time is computed: now + TTL. It is a duration string, with up to nine fractional digits, terminated by 's'. Example: "3.5s".""",16465  )16466  expire_time: Optional[datetime.datetime] = Field(16467      default=None,16468      description="""Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z.""",16469  )16470  display_name: Optional[str] = Field(16471      default=None,16472      description="""The user-generated meaningful display name of the cached content.16473      """,16474  )16475  contents: Optional[ContentListUnion] = Field(16476      default=None,16477      description="""The content to cache.16478      """,16479  )16480  system_instruction: Optional[ContentUnion] = Field(16481      default=None,16482      description="""Developer set system instruction.16483      """,16484  )16485  tools: Optional[list[Tool]] = Field(16486      default=None,16487      description="""A list of `Tools` the model may use to generate the next response.16488      """,16489  )16490  tool_config: Optional[ToolConfig] = Field(16491      default=None,16492      description="""Configuration for the tools to use. This config is shared for all tools.16493      """,16494  )16495  kms_key_name: Optional[str] = Field(16496      default=None,16497      description="""The Cloud KMS resource identifier of the customer managed16498      encryption key used to protect a resource.16499      The key needs to be in the same region as where the compute resource is16500      created. See16501      https://cloud.google.com/vertex-ai/docs/general/cmek for more16502      details. If this is set, then all created CachedContent objects16503      will be encrypted with the provided encryption key.16504      Allowed formats: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}16505      """,16506  )165071650816509class CreateCachedContentConfigDict(TypedDict, total=False):16510  """Optional configuration for cached content creation."""1651116512  http_options: Optional[HttpOptionsDict]16513  """Used to override HTTP request options."""1651416515  ttl: Optional[str]16516  """The TTL for this resource. The expiration time is computed: now + TTL. It is a duration string, with up to nine fractional digits, terminated by 's'. Example: "3.5s"."""1651716518  expire_time: Optional[datetime.datetime]16519  """Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z."""1652016521  display_name: Optional[str]16522  """The user-generated meaningful display name of the cached content.16523      """1652416525  contents: Optional[ContentListUnionDict]16526  """The content to cache.16527      """1652816529  system_instruction: Optional[ContentUnionDict]16530  """Developer set system instruction.16531      """1653216533  tools: Optional[list[ToolDict]]16534  """A list of `Tools` the model may use to generate the next response.16535      """1653616537  tool_config: Optional[ToolConfigDict]16538  """Configuration for the tools to use. This config is shared for all tools.16539      """1654016541  kms_key_name: Optional[str]16542  """The Cloud KMS resource identifier of the customer managed16543      encryption key used to protect a resource.16544      The key needs to be in the same region as where the compute resource is16545      created. See16546      https://cloud.google.com/vertex-ai/docs/general/cmek for more16547      details. If this is set, then all created CachedContent objects16548      will be encrypted with the provided encryption key.16549      Allowed formats: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}16550      """165511655216553CreateCachedContentConfigOrDict = Union[16554    CreateCachedContentConfig, CreateCachedContentConfigDict16555]165561655716558class _CreateCachedContentParameters(_common.BaseModel):16559  """Parameters for caches.create method."""1656016561  model: Optional[str] = Field(16562      default=None,16563      description="""ID of the model to use. Example: gemini-2.0-flash""",16564  )16565  config: Optional[CreateCachedContentConfig] = Field(16566      default=None,16567      description="""Configuration that contains optional parameters.16568      """,16569  )165701657116572class _CreateCachedContentParametersDict(TypedDict, total=False):16573  """Parameters for caches.create method."""1657416575  model: Optional[str]16576  """ID of the model to use. Example: gemini-2.0-flash"""1657716578  config: Optional[CreateCachedContentConfigDict]16579  """Configuration that contains optional parameters.16580      """165811658216583_CreateCachedContentParametersOrDict = Union[16584    _CreateCachedContentParameters, _CreateCachedContentParametersDict16585]165861658716588class CachedContentUsageMetadata(_common.BaseModel):16589  """Metadata on the usage of the cached content."""1659016591  audio_duration_seconds: Optional[int] = Field(16592      default=None,16593      description="""Duration of audio in seconds. This field is not supported in Gemini API.""",16594  )16595  image_count: Optional[int] = Field(16596      default=None,16597      description="""Number of images. This field is not supported in Gemini API.""",16598  )16599  text_count: Optional[int] = Field(16600      default=None,16601      description="""Number of text characters. This field is not supported in Gemini API.""",16602  )16603  total_token_count: Optional[int] = Field(16604      default=None,16605      description="""Total number of tokens that the cached content consumes.""",16606  )16607  video_duration_seconds: Optional[int] = Field(16608      default=None,16609      description="""Duration of video in seconds. This field is not supported in Gemini API.""",16610  )166111661216613class CachedContentUsageMetadataDict(TypedDict, total=False):16614  """Metadata on the usage of the cached content."""1661516616  audio_duration_seconds: Optional[int]16617  """Duration of audio in seconds. This field is not supported in Gemini API."""1661816619  image_count: Optional[int]16620  """Number of images. This field is not supported in Gemini API."""1662116622  text_count: Optional[int]16623  """Number of text characters. This field is not supported in Gemini API."""1662416625  total_token_count: Optional[int]16626  """Total number of tokens that the cached content consumes."""1662716628  video_duration_seconds: Optional[int]16629  """Duration of video in seconds. This field is not supported in Gemini API."""166301663116632CachedContentUsageMetadataOrDict = Union[16633    CachedContentUsageMetadata, CachedContentUsageMetadataDict16634]166351663616637class CachedContent(_common.BaseModel):16638  """A resource used in LLM queries for users to explicitly specify what to cache."""1663916640  name: Optional[str] = Field(16641      default=None,16642      description="""The server-generated resource name of the cached content.""",16643  )16644  display_name: Optional[str] = Field(16645      default=None,16646      description="""The user-generated meaningful display name of the cached content.""",16647  )16648  model: Optional[str] = Field(16649      default=None,16650      description="""The name of the publisher model to use for cached content.""",16651  )16652  create_time: Optional[datetime.datetime] = Field(16653      default=None, description="""Creation time of the cache entry."""16654  )16655  update_time: Optional[datetime.datetime] = Field(16656      default=None,16657      description="""When the cache entry was last updated in UTC time.""",16658  )16659  expire_time: Optional[datetime.datetime] = Field(16660      default=None, description="""Expiration time of the cached content."""16661  )16662  usage_metadata: Optional[CachedContentUsageMetadata] = Field(16663      default=None,16664      description="""Metadata on the usage of the cached content.""",16665  )166661666716668class CachedContentDict(TypedDict, total=False):16669  """A resource used in LLM queries for users to explicitly specify what to cache."""1667016671  name: Optional[str]16672  """The server-generated resource name of the cached content."""1667316674  display_name: Optional[str]16675  """The user-generated meaningful display name of the cached content."""1667616677  model: Optional[str]16678  """The name of the publisher model to use for cached content."""1667916680  create_time: Optional[datetime.datetime]16681  """Creation time of the cache entry."""1668216683  update_time: Optional[datetime.datetime]16684  """When the cache entry was last updated in UTC time."""1668516686  expire_time: Optional[datetime.datetime]16687  """Expiration time of the cached content."""1668816689  usage_metadata: Optional[CachedContentUsageMetadataDict]16690  """Metadata on the usage of the cached content."""166911669216693CachedContentOrDict = Union[CachedContent, CachedContentDict]166941669516696class GetCachedContentConfig(_common.BaseModel):16697  """Optional parameters for caches.get method."""1669816699  http_options: Optional[HttpOptions] = Field(16700      default=None, description="""Used to override HTTP request options."""16701  )167021670316704class GetCachedContentConfigDict(TypedDict, total=False):16705  """Optional parameters for caches.get method."""1670616707  http_options: Optional[HttpOptionsDict]16708  """Used to override HTTP request options."""167091671016711GetCachedContentConfigOrDict = Union[16712    GetCachedContentConfig, GetCachedContentConfigDict16713]167141671516716class _GetCachedContentParameters(_common.BaseModel):16717  """Parameters for caches.get method."""1671816719  name: Optional[str] = Field(16720      default=None,16721      description="""The server-generated resource name of the cached content.16722      """,16723  )16724  config: Optional[GetCachedContentConfig] = Field(16725      default=None,16726      description="""Optional parameters for the request.16727      """,16728  )167291673016731class _GetCachedContentParametersDict(TypedDict, total=False):16732  """Parameters for caches.get method."""1673316734  name: Optional[str]16735  """The server-generated resource name of the cached content.16736      """1673716738  config: Optional[GetCachedContentConfigDict]16739  """Optional parameters for the request.16740      """167411674216743_GetCachedContentParametersOrDict = Union[16744    _GetCachedContentParameters, _GetCachedContentParametersDict16745]167461674716748class DeleteCachedContentConfig(_common.BaseModel):16749  """Optional parameters for caches.delete method."""1675016751  http_options: Optional[HttpOptions] = Field(16752      default=None, description="""Used to override HTTP request options."""16753  )167541675516756class DeleteCachedContentConfigDict(TypedDict, total=False):16757  """Optional parameters for caches.delete method."""1675816759  http_options: Optional[HttpOptionsDict]16760  """Used to override HTTP request options."""167611676216763DeleteCachedContentConfigOrDict = Union[16764    DeleteCachedContentConfig, DeleteCachedContentConfigDict16765]167661676716768class _DeleteCachedContentParameters(_common.BaseModel):16769  """Parameters for caches.delete method."""1677016771  name: Optional[str] = Field(16772      default=None,16773      description="""The server-generated resource name of the cached content.16774      """,16775  )16776  config: Optional[DeleteCachedContentConfig] = Field(16777      default=None,16778      description="""Optional parameters for the request.16779      """,16780  )167811678216783class _DeleteCachedContentParametersDict(TypedDict, total=False):16784  """Parameters for caches.delete method."""1678516786  name: Optional[str]16787  """The server-generated resource name of the cached content.16788      """1678916790  config: Optional[DeleteCachedContentConfigDict]16791  """Optional parameters for the request.16792      """167931679416795_DeleteCachedContentParametersOrDict = Union[16796    _DeleteCachedContentParameters, _DeleteCachedContentParametersDict16797]167981679916800class DeleteCachedContentResponse(_common.BaseModel):16801  """Empty response for caches.delete method."""1680216803  sdk_http_response: Optional[HttpResponse] = Field(16804      default=None, description="""Used to retain the full HTTP response."""16805  )168061680716808class DeleteCachedContentResponseDict(TypedDict, total=False):16809  """Empty response for caches.delete method."""1681016811  sdk_http_response: Optional[HttpResponseDict]16812  """Used to retain the full HTTP response."""168131681416815DeleteCachedContentResponseOrDict = Union[16816    DeleteCachedContentResponse, DeleteCachedContentResponseDict16817]168181681916820class UpdateCachedContentConfig(_common.BaseModel):16821  """Optional parameters for caches.update method."""1682216823  http_options: Optional[HttpOptions] = Field(16824      default=None, description="""Used to override HTTP request options."""16825  )16826  ttl: Optional[str] = Field(16827      default=None,16828      description="""The TTL for this resource. The expiration time is computed: now + TTL. It is a duration string, with up to nine fractional digits, terminated by 's'. Example: "3.5s".""",16829  )16830  expire_time: Optional[datetime.datetime] = Field(16831      default=None,16832      description="""Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z.""",16833  )168341683516836class UpdateCachedContentConfigDict(TypedDict, total=False):16837  """Optional parameters for caches.update method."""1683816839  http_options: Optional[HttpOptionsDict]16840  """Used to override HTTP request options."""1684116842  ttl: Optional[str]16843  """The TTL for this resource. The expiration time is computed: now + TTL. It is a duration string, with up to nine fractional digits, terminated by 's'. Example: "3.5s"."""1684416845  expire_time: Optional[datetime.datetime]16846  """Timestamp of when this resource is considered expired. Uses RFC 3339 format, Example: 2014-10-02T15:01:23Z."""168471684816849UpdateCachedContentConfigOrDict = Union[16850    UpdateCachedContentConfig, UpdateCachedContentConfigDict16851]168521685316854class _UpdateCachedContentParameters(_common.BaseModel):1685516856  name: Optional[str] = Field(16857      default=None,16858      description="""The server-generated resource name of the cached content.16859      """,16860  )16861  config: Optional[UpdateCachedContentConfig] = Field(16862      default=None,16863      description="""Configuration that contains optional parameters.16864      """,16865  )168661686716868class _UpdateCachedContentParametersDict(TypedDict, total=False):1686916870  name: Optional[str]16871  """The server-generated resource name of the cached content.16872      """1687316874  config: Optional[UpdateCachedContentConfigDict]16875  """Configuration that contains optional parameters.16876      """168771687816879_UpdateCachedContentParametersOrDict = Union[16880    _UpdateCachedContentParameters, _UpdateCachedContentParametersDict16881]168821688316884class ListCachedContentsConfig(_common.BaseModel):16885  """Config for caches.list method."""1688616887  http_options: Optional[HttpOptions] = Field(16888      default=None, description="""Used to override HTTP request options."""16889  )16890  page_size: Optional[int] = Field(default=None, description="""""")16891  page_token: Optional[str] = Field(default=None, description="""""")168921689316894class ListCachedContentsConfigDict(TypedDict, total=False):16895  """Config for caches.list method."""1689616897  http_options: Optional[HttpOptionsDict]16898  """Used to override HTTP request options."""1689916900  page_size: Optional[int]16901  """"""1690216903  page_token: Optional[str]16904  """"""169051690616907ListCachedContentsConfigOrDict = Union[16908    ListCachedContentsConfig, ListCachedContentsConfigDict16909]169101691116912class _ListCachedContentsParameters(_common.BaseModel):16913  """Parameters for caches.list method."""1691416915  config: Optional[ListCachedContentsConfig] = Field(16916      default=None,16917      description="""Configuration that contains optional parameters.16918      """,16919  )169201692116922class _ListCachedContentsParametersDict(TypedDict, total=False):16923  """Parameters for caches.list method."""1692416925  config: Optional[ListCachedContentsConfigDict]16926  """Configuration that contains optional parameters.16927      """169281692916930_ListCachedContentsParametersOrDict = Union[16931    _ListCachedContentsParameters, _ListCachedContentsParametersDict16932]169331693416935class ListCachedContentsResponse(_common.BaseModel):1693616937  sdk_http_response: Optional[HttpResponse] = Field(16938      default=None, description="""Used to retain the full HTTP response."""16939  )16940  next_page_token: Optional[str] = Field(default=None, description="""""")16941  cached_contents: Optional[list[CachedContent]] = Field(16942      default=None,16943      description="""List of cached contents.16944      """,16945  )169461694716948class ListCachedContentsResponseDict(TypedDict, total=False):1694916950  sdk_http_response: Optional[HttpResponseDict]16951  """Used to retain the full HTTP response."""1695216953  next_page_token: Optional[str]16954  """"""1695516956  cached_contents: Optional[list[CachedContentDict]]16957  """List of cached contents.16958      """169591696016961ListCachedContentsResponseOrDict = Union[16962    ListCachedContentsResponse, ListCachedContentsResponseDict16963]169641696516966class GetDocumentConfig(_common.BaseModel):16967  """Optional Config."""1696816969  http_options: Optional[HttpOptions] = Field(16970      default=None, description="""Used to override HTTP request options."""16971  )169721697316974class GetDocumentConfigDict(TypedDict, total=False):16975  """Optional Config."""1697616977  http_options: Optional[HttpOptionsDict]16978  """Used to override HTTP request options."""169791698016981GetDocumentConfigOrDict = Union[GetDocumentConfig, GetDocumentConfigDict]169821698316984class _GetDocumentParameters(_common.BaseModel):16985  """Parameters for documents.get."""1698616987  name: Optional[str] = Field(16988      default=None,16989      description="""The resource name of the Document.16990    Example: fileSearchStores/file-search-store-foo/documents/documents-bar""",16991  )16992  config: Optional[GetDocumentConfig] = Field(16993      default=None, description="""Optional parameters for the request."""16994  )169951699616997class _GetDocumentParametersDict(TypedDict, total=False):16998  """Parameters for documents.get."""1699917000  name: Optional[str]17001  """The resource name of the Document.17002    Example: fileSearchStores/file-search-store-foo/documents/documents-bar"""1700317004  config: Optional[GetDocumentConfigDict]17005  """Optional parameters for the request."""170061700717008_GetDocumentParametersOrDict = Union[17009    _GetDocumentParameters, _GetDocumentParametersDict17010]170111701217013class StringList(_common.BaseModel):17014  """User provided string values assigned to a single metadata key.1701517016  This data type is not supported in Vertex AI.17017  """1701817019  values: Optional[list[str]] = Field(17020      default=None,17021      description="""The string values of the metadata to store.""",17022  )170231702417025class StringListDict(TypedDict, total=False):17026  """User provided string values assigned to a single metadata key.1702717028  This data type is not supported in Vertex AI.17029  """1703017031  values: Optional[list[str]]17032  """The string values of the metadata to store."""170331703417035StringListOrDict = Union[StringList, StringListDict]170361703717038class CustomMetadata(_common.BaseModel):17039  """User provided metadata stored as key-value pairs.1704017041  This data type is not supported in Vertex AI.17042  """1704317044  key: Optional[str] = Field(17045      default=None,17046      description="""Required. The key of the metadata to store.""",17047  )17048  numeric_value: Optional[float] = Field(17049      default=None,17050      description="""The numeric value of the metadata to store.""",17051  )17052  string_list_value: Optional[StringList] = Field(17053      default=None,17054      description="""The StringList value of the metadata to store.""",17055  )17056  string_value: Optional[str] = Field(17057      default=None, description="""The string value of the metadata to store."""17058  )170591706017061class CustomMetadataDict(TypedDict, total=False):17062  """User provided metadata stored as key-value pairs.1706317064  This data type is not supported in Vertex AI.17065  """1706617067  key: Optional[str]17068  """Required. The key of the metadata to store."""1706917070  numeric_value: Optional[float]17071  """The numeric value of the metadata to store."""1707217073  string_list_value: Optional[StringListDict]17074  """The StringList value of the metadata to store."""1707517076  string_value: Optional[str]17077  """The string value of the metadata to store."""170781707917080CustomMetadataOrDict = Union[CustomMetadata, CustomMetadataDict]170811708217083class Document(_common.BaseModel):17084  """A Document is a collection of Chunks."""1708517086  name: Optional[str] = Field(17087      default=None,17088      description="""Immutable. Identifier. The `Document` resource name. The ID (name excluding the "fileSearchStores/&#42;/documents/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/{file_search_store_id}/documents/my-awesome-doc-123a456b789c`""",17089  )17090  display_name: Optional[str] = Field(17091      default=None,17092      description="""Optional. The human-readable display name for the `Document`. The display name must be no more than 512 characters in length, including spaces. Example: "Semantic Retriever Documentation".""",17093  )17094  state: Optional[DocumentState] = Field(17095      default=None,17096      description="""Output only. Current state of the `Document`.""",17097  )17098  size_bytes: Optional[int] = Field(17099      default=None,17100      description="""Output only. The size of raw bytes ingested into the Document.""",17101  )17102  mime_type: Optional[str] = Field(17103      default=None,17104      description="""Output only. The mime type of the Document.""",17105  )17106  create_time: Optional[datetime.datetime] = Field(17107      default=None,17108      description="""Output only. The Timestamp of when the `Document` was created.""",17109  )17110  custom_metadata: Optional[list[CustomMetadata]] = Field(17111      default=None,17112      description="""Optional. User provided custom metadata stored as key-value pairs used for querying. A `Document` can have a maximum of 20 `CustomMetadata`.""",17113  )17114  update_time: Optional[datetime.datetime] = Field(17115      default=None,17116      description="""Output only. The Timestamp of when the `Document` was last updated.""",17117  )171181711917120class DocumentDict(TypedDict, total=False):17121  """A Document is a collection of Chunks."""1712217123  name: Optional[str]17124  """Immutable. Identifier. The `Document` resource name. The ID (name excluding the "fileSearchStores/&#42;/documents/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/{file_search_store_id}/documents/my-awesome-doc-123a456b789c`"""1712517126  display_name: Optional[str]17127  """Optional. The human-readable display name for the `Document`. The display name must be no more than 512 characters in length, including spaces. Example: "Semantic Retriever Documentation"."""1712817129  state: Optional[DocumentState]17130  """Output only. Current state of the `Document`."""1713117132  size_bytes: Optional[int]17133  """Output only. The size of raw bytes ingested into the Document."""1713417135  mime_type: Optional[str]17136  """Output only. The mime type of the Document."""1713717138  create_time: Optional[datetime.datetime]17139  """Output only. The Timestamp of when the `Document` was created."""1714017141  custom_metadata: Optional[list[CustomMetadataDict]]17142  """Optional. User provided custom metadata stored as key-value pairs used for querying. A `Document` can have a maximum of 20 `CustomMetadata`."""1714317144  update_time: Optional[datetime.datetime]17145  """Output only. The Timestamp of when the `Document` was last updated."""171461714717148DocumentOrDict = Union[Document, DocumentDict]171491715017151class DeleteDocumentConfig(_common.BaseModel):17152  """Config for optional parameters."""1715317154  http_options: Optional[HttpOptions] = Field(17155      default=None, description="""Used to override HTTP request options."""17156  )17157  force: Optional[bool] = Field(17158      default=None,17159      description="""If set to true, any `Chunk`s and objects related to this `Document` will17160      also be deleted.17161      """,17162  )171631716417165class DeleteDocumentConfigDict(TypedDict, total=False):17166  """Config for optional parameters."""1716717168  http_options: Optional[HttpOptionsDict]17169  """Used to override HTTP request options."""1717017171  force: Optional[bool]17172  """If set to true, any `Chunk`s and objects related to this `Document` will17173      also be deleted.17174      """171751717617177DeleteDocumentConfigOrDict = Union[17178    DeleteDocumentConfig, DeleteDocumentConfigDict17179]171801718117182class _DeleteDocumentParameters(_common.BaseModel):17183  """Config for documents.delete parameters."""1718417185  name: Optional[str] = Field(17186      default=None,17187      description="""The resource name of the Document.17188    Example: fileSearchStores/file-search-store-foo/documents/documents-bar""",17189  )17190  config: Optional[DeleteDocumentConfig] = Field(17191      default=None, description="""Optional parameters for the request."""17192  )171931719417195class _DeleteDocumentParametersDict(TypedDict, total=False):17196  """Config for documents.delete parameters."""1719717198  name: Optional[str]17199  """The resource name of the Document.17200    Example: fileSearchStores/file-search-store-foo/documents/documents-bar"""1720117202  config: Optional[DeleteDocumentConfigDict]17203  """Optional parameters for the request."""172041720517206_DeleteDocumentParametersOrDict = Union[17207    _DeleteDocumentParameters, _DeleteDocumentParametersDict17208]172091721017211class ListDocumentsConfig(_common.BaseModel):17212  """Config for optional parameters."""1721317214  http_options: Optional[HttpOptions] = Field(17215      default=None, description="""Used to override HTTP request options."""17216  )17217  page_size: Optional[int] = Field(default=None, description="""""")17218  page_token: Optional[str] = Field(default=None, description="""""")172191722017221class ListDocumentsConfigDict(TypedDict, total=False):17222  """Config for optional parameters."""1722317224  http_options: Optional[HttpOptionsDict]17225  """Used to override HTTP request options."""1722617227  page_size: Optional[int]17228  """"""1722917230  page_token: Optional[str]17231  """"""172321723317234ListDocumentsConfigOrDict = Union[ListDocumentsConfig, ListDocumentsConfigDict]172351723617237class _ListDocumentsParameters(_common.BaseModel):17238  """Config for documents.list parameters."""1723917240  parent: Optional[str] = Field(17241      default=None,17242      description="""The resource name of the FileSearchStores. Example: `fileSearchStore/file-search-store-foo`""",17243  )17244  config: Optional[ListDocumentsConfig] = Field(17245      default=None, description=""""""17246  )172471724817249class _ListDocumentsParametersDict(TypedDict, total=False):17250  """Config for documents.list parameters."""1725117252  parent: Optional[str]17253  """The resource name of the FileSearchStores. Example: `fileSearchStore/file-search-store-foo`"""1725417255  config: Optional[ListDocumentsConfigDict]17256  """"""172571725817259_ListDocumentsParametersOrDict = Union[17260    _ListDocumentsParameters, _ListDocumentsParametersDict17261]172621726317264class ListDocumentsResponse(_common.BaseModel):17265  """Config for documents.list return value."""1726617267  sdk_http_response: Optional[HttpResponse] = Field(17268      default=None, description="""Used to retain the full HTTP response."""17269  )17270  next_page_token: Optional[str] = Field(17271      default=None,17272      description="""A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages.""",17273  )17274  documents: Optional[list[Document]] = Field(17275      default=None, description="""The returned `Document`s."""17276  )172771727817279class ListDocumentsResponseDict(TypedDict, total=False):17280  """Config for documents.list return value."""1728117282  sdk_http_response: Optional[HttpResponseDict]17283  """Used to retain the full HTTP response."""1728417285  next_page_token: Optional[str]17286  """A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages."""1728717288  documents: Optional[list[DocumentDict]]17289  """The returned `Document`s."""172901729117292ListDocumentsResponseOrDict = Union[17293    ListDocumentsResponse, ListDocumentsResponseDict17294]172951729617297class CreateFileSearchStoreConfig(_common.BaseModel):17298  """Optional parameters for creating a file search store."""1729917300  http_options: Optional[HttpOptions] = Field(17301      default=None, description="""Used to override HTTP request options."""17302  )17303  display_name: Optional[str] = Field(17304      default=None,17305      description="""The human-readable display name for the file search store.17306      """,17307  )17308  embedding_model: Optional[str] = Field(17309      default=None,17310      description="""The embedding model to use for the FileSearchStore.17311      Format: `models/{model}`. If not specified, the default embedding model will be used.17312      """,17313  )173141731517316class CreateFileSearchStoreConfigDict(TypedDict, total=False):17317  """Optional parameters for creating a file search store."""1731817319  http_options: Optional[HttpOptionsDict]17320  """Used to override HTTP request options."""1732117322  display_name: Optional[str]17323  """The human-readable display name for the file search store.17324      """1732517326  embedding_model: Optional[str]17327  """The embedding model to use for the FileSearchStore.17328      Format: `models/{model}`. If not specified, the default embedding model will be used.17329      """173301733117332CreateFileSearchStoreConfigOrDict = Union[17333    CreateFileSearchStoreConfig, CreateFileSearchStoreConfigDict17334]173351733617337class _CreateFileSearchStoreParameters(_common.BaseModel):17338  """Config for file_search_stores.create parameters."""1733917340  config: Optional[CreateFileSearchStoreConfig] = Field(17341      default=None,17342      description="""Optional parameters for creating a file search store.17343      """,17344  )173451734617347class _CreateFileSearchStoreParametersDict(TypedDict, total=False):17348  """Config for file_search_stores.create parameters."""1734917350  config: Optional[CreateFileSearchStoreConfigDict]17351  """Optional parameters for creating a file search store.17352      """173531735417355_CreateFileSearchStoreParametersOrDict = Union[17356    _CreateFileSearchStoreParameters, _CreateFileSearchStoreParametersDict17357]173581735917360class FileSearchStore(_common.BaseModel):17361  """A collection of Documents."""1736217363  name: Optional[str] = Field(17364      default=None,17365      description="""Output only. Immutable. Identifier. The `FileSearchStore` resource name. It is an ID (name excluding the "fileSearchStores/" prefix) that can contain up to 40 characters that are lowercase alphanumeric or dashes (-). It is output only. The unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/my-awesome-file-search-store-123a456b789c` If `display_name` is not provided, the name will be randomly generated.""",17366  )17367  display_name: Optional[str] = Field(17368      default=None,17369      description="""Optional. The human-readable display name for the `FileSearchStore`. The display name must be no more than 512 characters in length, including spaces. Example: "Docs on Semantic Retriever".""",17370  )17371  create_time: Optional[datetime.datetime] = Field(17372      default=None,17373      description="""Output only. The Timestamp of when the `FileSearchStore` was created.""",17374  )17375  update_time: Optional[datetime.datetime] = Field(17376      default=None,17377      description="""Output only. The Timestamp of when the `FileSearchStore` was last updated.""",17378  )17379  active_documents_count: Optional[int] = Field(17380      default=None,17381      description="""Output only. The number of documents in the `FileSearchStore` that are active and ready for retrieval.""",17382  )17383  pending_documents_count: Optional[int] = Field(17384      default=None,17385      description="""Output only. The number of documents in the `FileSearchStore` that are being processed.""",17386  )17387  failed_documents_count: Optional[int] = Field(17388      default=None,17389      description="""Output only. The number of documents in the `FileSearchStore` that have failed processing.""",17390  )17391  size_bytes: Optional[int] = Field(17392      default=None,17393      description="""Output only. The size of raw bytes ingested into the `FileSearchStore`. This is the total size of all the documents in the `FileSearchStore`.""",17394  )17395  embedding_model: Optional[str] = Field(17396      default=None,17397      description="""The embedding model used by the FileSearchStore.""",17398  )173991740017401class FileSearchStoreDict(TypedDict, total=False):17402  """A collection of Documents."""1740317404  name: Optional[str]17405  """Output only. Immutable. Identifier. The `FileSearchStore` resource name. It is an ID (name excluding the "fileSearchStores/" prefix) that can contain up to 40 characters that are lowercase alphanumeric or dashes (-). It is output only. The unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/my-awesome-file-search-store-123a456b789c` If `display_name` is not provided, the name will be randomly generated."""1740617407  display_name: Optional[str]17408  """Optional. The human-readable display name for the `FileSearchStore`. The display name must be no more than 512 characters in length, including spaces. Example: "Docs on Semantic Retriever"."""1740917410  create_time: Optional[datetime.datetime]17411  """Output only. The Timestamp of when the `FileSearchStore` was created."""1741217413  update_time: Optional[datetime.datetime]17414  """Output only. The Timestamp of when the `FileSearchStore` was last updated."""1741517416  active_documents_count: Optional[int]17417  """Output only. The number of documents in the `FileSearchStore` that are active and ready for retrieval."""1741817419  pending_documents_count: Optional[int]17420  """Output only. The number of documents in the `FileSearchStore` that are being processed."""1742117422  failed_documents_count: Optional[int]17423  """Output only. The number of documents in the `FileSearchStore` that have failed processing."""1742417425  size_bytes: Optional[int]17426  """Output only. The size of raw bytes ingested into the `FileSearchStore`. This is the total size of all the documents in the `FileSearchStore`."""1742717428  embedding_model: Optional[str]17429  """The embedding model used by the FileSearchStore."""174301743117432FileSearchStoreOrDict = Union[FileSearchStore, FileSearchStoreDict]174331743417435class GetFileSearchStoreConfig(_common.BaseModel):17436  """Optional parameters for getting a FileSearchStore."""1743717438  http_options: Optional[HttpOptions] = Field(17439      default=None, description="""Used to override HTTP request options."""17440  )174411744217443class GetFileSearchStoreConfigDict(TypedDict, total=False):17444  """Optional parameters for getting a FileSearchStore."""1744517446  http_options: Optional[HttpOptionsDict]17447  """Used to override HTTP request options."""174481744917450GetFileSearchStoreConfigOrDict = Union[17451    GetFileSearchStoreConfig, GetFileSearchStoreConfigDict17452]174531745417455class _GetFileSearchStoreParameters(_common.BaseModel):17456  """Config for file_search_stores.get parameters."""1745717458  name: Optional[str] = Field(17459      default=None,17460      description="""The resource name of the FileSearchStore. Example: `fileSearchStores/my-file-search-store-123`""",17461  )17462  config: Optional[GetFileSearchStoreConfig] = Field(17463      default=None, description="""Optional parameters for the request."""17464  )174651746617467class _GetFileSearchStoreParametersDict(TypedDict, total=False):17468  """Config for file_search_stores.get parameters."""1746917470  name: Optional[str]17471  """The resource name of the FileSearchStore. Example: `fileSearchStores/my-file-search-store-123`"""1747217473  config: Optional[GetFileSearchStoreConfigDict]17474  """Optional parameters for the request."""174751747617477_GetFileSearchStoreParametersOrDict = Union[17478    _GetFileSearchStoreParameters, _GetFileSearchStoreParametersDict17479]174801748117482class DeleteFileSearchStoreConfig(_common.BaseModel):17483  """Optional parameters for deleting a FileSearchStore."""1748417485  http_options: Optional[HttpOptions] = Field(17486      default=None, description="""Used to override HTTP request options."""17487  )17488  force: Optional[bool] = Field(17489      default=None,17490      description="""If set to true, any Documents and objects related to this FileSearchStore will also be deleted.17491      If false (the default), a FAILED_PRECONDITION error will be returned if17492      the FileSearchStore contains any Documents.17493      """,17494  )174951749617497class DeleteFileSearchStoreConfigDict(TypedDict, total=False):17498  """Optional parameters for deleting a FileSearchStore."""1749917500  http_options: Optional[HttpOptionsDict]17501  """Used to override HTTP request options."""1750217503  force: Optional[bool]17504  """If set to true, any Documents and objects related to this FileSearchStore will also be deleted.17505      If false (the default), a FAILED_PRECONDITION error will be returned if17506      the FileSearchStore contains any Documents.17507      """175081750917510DeleteFileSearchStoreConfigOrDict = Union[17511    DeleteFileSearchStoreConfig, DeleteFileSearchStoreConfigDict17512]175131751417515class _DeleteFileSearchStoreParameters(_common.BaseModel):17516  """Config for file_search_stores.delete parameters."""1751717518  name: Optional[str] = Field(17519      default=None,17520      description="""The resource name of the FileSearchStore. Example: `fileSearchStores/my-file-search-store-123`""",17521  )17522  config: Optional[DeleteFileSearchStoreConfig] = Field(17523      default=None, description="""Optional parameters for the request."""17524  )175251752617527class _DeleteFileSearchStoreParametersDict(TypedDict, total=False):17528  """Config for file_search_stores.delete parameters."""1752917530  name: Optional[str]17531  """The resource name of the FileSearchStore. Example: `fileSearchStores/my-file-search-store-123`"""1753217533  config: Optional[DeleteFileSearchStoreConfigDict]17534  """Optional parameters for the request."""175351753617537_DeleteFileSearchStoreParametersOrDict = Union[17538    _DeleteFileSearchStoreParameters, _DeleteFileSearchStoreParametersDict17539]175401754117542class ListFileSearchStoresConfig(_common.BaseModel):17543  """Optional parameters for listing FileSearchStore."""1754417545  http_options: Optional[HttpOptions] = Field(17546      default=None, description="""Used to override HTTP request options."""17547  )17548  page_size: Optional[int] = Field(default=None, description="""""")17549  page_token: Optional[str] = Field(default=None, description="""""")175501755117552class ListFileSearchStoresConfigDict(TypedDict, total=False):17553  """Optional parameters for listing FileSearchStore."""1755417555  http_options: Optional[HttpOptionsDict]17556  """Used to override HTTP request options."""1755717558  page_size: Optional[int]17559  """"""1756017561  page_token: Optional[str]17562  """"""175631756417565ListFileSearchStoresConfigOrDict = Union[17566    ListFileSearchStoresConfig, ListFileSearchStoresConfigDict17567]175681756917570class _ListFileSearchStoresParameters(_common.BaseModel):17571  """Config for file_search_stores.list parameters."""1757217573  config: Optional[ListFileSearchStoresConfig] = Field(17574      default=None, description="""Optional parameters for the list request."""17575  )175761757717578class _ListFileSearchStoresParametersDict(TypedDict, total=False):17579  """Config for file_search_stores.list parameters."""1758017581  config: Optional[ListFileSearchStoresConfigDict]17582  """Optional parameters for the list request."""175831758417585_ListFileSearchStoresParametersOrDict = Union[17586    _ListFileSearchStoresParameters, _ListFileSearchStoresParametersDict17587]175881758917590class ListFileSearchStoresResponse(_common.BaseModel):17591  """Config for file_search_stores.list return value."""1759217593  sdk_http_response: Optional[HttpResponse] = Field(17594      default=None, description="""Used to retain the full HTTP response."""17595  )17596  next_page_token: Optional[str] = Field(17597      default=None,17598      description="""A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages.""",17599  )17600  file_search_stores: Optional[list[FileSearchStore]] = Field(17601      default=None, description="""The returned file search stores."""17602  )176031760417605class ListFileSearchStoresResponseDict(TypedDict, total=False):17606  """Config for file_search_stores.list return value."""1760717608  sdk_http_response: Optional[HttpResponseDict]17609  """Used to retain the full HTTP response."""1761017611  next_page_token: Optional[str]17612  """A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages."""1761317614  file_search_stores: Optional[list[FileSearchStoreDict]]17615  """The returned file search stores."""176161761717618ListFileSearchStoresResponseOrDict = Union[17619    ListFileSearchStoresResponse, ListFileSearchStoresResponseDict17620]176211762217623class WhiteSpaceConfig(_common.BaseModel):17624  """Configuration for a white space chunking algorithm."""1762517626  max_tokens_per_chunk: Optional[int] = Field(17627      default=None, description="""Maximum number of tokens per chunk."""17628  )17629  max_overlap_tokens: Optional[int] = Field(17630      default=None,17631      description="""Maximum number of overlapping tokens between two adjacent chunks.""",17632  )176331763417635class WhiteSpaceConfigDict(TypedDict, total=False):17636  """Configuration for a white space chunking algorithm."""1763717638  max_tokens_per_chunk: Optional[int]17639  """Maximum number of tokens per chunk."""1764017641  max_overlap_tokens: Optional[int]17642  """Maximum number of overlapping tokens between two adjacent chunks."""176431764417645WhiteSpaceConfigOrDict = Union[WhiteSpaceConfig, WhiteSpaceConfigDict]176461764717648class ChunkingConfig(_common.BaseModel):17649  """Config for telling the service how to chunk the file."""1765017651  white_space_config: Optional[WhiteSpaceConfig] = Field(17652      default=None, description="""White space chunking configuration."""17653  )176541765517656class ChunkingConfigDict(TypedDict, total=False):17657  """Config for telling the service how to chunk the file."""1765817659  white_space_config: Optional[WhiteSpaceConfigDict]17660  """White space chunking configuration."""176611766217663ChunkingConfigOrDict = Union[ChunkingConfig, ChunkingConfigDict]176641766517666class UploadToFileSearchStoreConfig(_common.BaseModel):17667  """Optional parameters for uploading a file to a FileSearchStore."""1766817669  http_options: Optional[HttpOptions] = Field(17670      default=None, description="""Used to override HTTP request options."""17671  )17672  should_return_http_response: Optional[bool] = Field(17673      default=None,17674      description=""" If true, the raw HTTP response will be returned in the 'sdk_http_response' field.""",17675  )17676  mime_type: Optional[str] = Field(17677      default=None,17678      description="""MIME type of the file to be uploaded. If not provided, it will be inferred from the file extension.""",17679  )17680  display_name: Optional[str] = Field(17681      default=None, description="""Display name of the created document."""17682  )17683  custom_metadata: Optional[list[CustomMetadata]] = Field(17684      default=None,17685      description="""User provided custom metadata stored as key-value pairs used for querying.""",17686  )17687  chunking_config: Optional[ChunkingConfig] = Field(17688      default=None,17689      description="""Config for telling the service how to chunk the file.""",17690  )176911769217693class UploadToFileSearchStoreConfigDict(TypedDict, total=False):17694  """Optional parameters for uploading a file to a FileSearchStore."""1769517696  http_options: Optional[HttpOptionsDict]17697  """Used to override HTTP request options."""1769817699  should_return_http_response: Optional[bool]17700  """ If true, the raw HTTP response will be returned in the 'sdk_http_response' field."""1770117702  mime_type: Optional[str]17703  """MIME type of the file to be uploaded. If not provided, it will be inferred from the file extension."""1770417705  display_name: Optional[str]17706  """Display name of the created document."""1770717708  custom_metadata: Optional[list[CustomMetadataDict]]17709  """User provided custom metadata stored as key-value pairs used for querying."""1771017711  chunking_config: Optional[ChunkingConfigDict]17712  """Config for telling the service how to chunk the file."""177131771417715UploadToFileSearchStoreConfigOrDict = Union[17716    UploadToFileSearchStoreConfig, UploadToFileSearchStoreConfigDict17717]177181771917720class _UploadToFileSearchStoreParameters(_common.BaseModel):17721  """Generates the parameters for the private _upload_to_file_search_store method."""1772217723  file_search_store_name: Optional[str] = Field(17724      default=None,17725      description="""The resource name of the FileSearchStore. Example: `fileSearchStores/my-file-search-store-123`""",17726  )17727  config: Optional[UploadToFileSearchStoreConfig] = Field(17728      default=None,17729      description="""Used to override the default configuration.""",17730  )177311773217733class _UploadToFileSearchStoreParametersDict(TypedDict, total=False):17734  """Generates the parameters for the private _upload_to_file_search_store method."""1773517736  file_search_store_name: Optional[str]17737  """The resource name of the FileSearchStore. Example: `fileSearchStores/my-file-search-store-123`"""1773817739  config: Optional[UploadToFileSearchStoreConfigDict]17740  """Used to override the default configuration."""177411774217743_UploadToFileSearchStoreParametersOrDict = Union[17744    _UploadToFileSearchStoreParameters, _UploadToFileSearchStoreParametersDict17745]177461774717748class UploadToFileSearchStoreResumableResponse(_common.BaseModel):17749  """Response for the resumable upload method."""1775017751  sdk_http_response: Optional[HttpResponse] = Field(17752      default=None, description="""Used to retain the full HTTP response."""17753  )177541775517756class UploadToFileSearchStoreResumableResponseDict(TypedDict, total=False):17757  """Response for the resumable upload method."""1775817759  sdk_http_response: Optional[HttpResponseDict]17760  """Used to retain the full HTTP response."""177611776217763UploadToFileSearchStoreResumableResponseOrDict = Union[17764    UploadToFileSearchStoreResumableResponse,17765    UploadToFileSearchStoreResumableResponseDict,17766]177671776817769class ImportFileConfig(_common.BaseModel):17770  """Optional parameters for importing a file."""1777117772  http_options: Optional[HttpOptions] = Field(17773      default=None, description="""Used to override HTTP request options."""17774  )17775  custom_metadata: Optional[list[CustomMetadata]] = Field(17776      default=None,17777      description="""User provided custom metadata stored as key-value pairs used for querying.""",17778  )17779  chunking_config: Optional[ChunkingConfig] = Field(17780      default=None,17781      description="""Config for telling the service how to chunk the file.""",17782  )177831778417785class ImportFileConfigDict(TypedDict, total=False):17786  """Optional parameters for importing a file."""1778717788  http_options: Optional[HttpOptionsDict]17789  """Used to override HTTP request options."""1779017791  custom_metadata: Optional[list[CustomMetadataDict]]17792  """User provided custom metadata stored as key-value pairs used for querying."""1779317794  chunking_config: Optional[ChunkingConfigDict]17795  """Config for telling the service how to chunk the file."""177961779717798ImportFileConfigOrDict = Union[ImportFileConfig, ImportFileConfigDict]177991780017801class _ImportFileParameters(_common.BaseModel):17802  """Config for file_search_stores.import_file parameters."""1780317804  file_search_store_name: Optional[str] = Field(17805      default=None,17806      description="""The resource name of the FileSearchStore. Example: `fileSearchStores/my-file-search-store-123`""",17807  )17808  file_name: Optional[str] = Field(17809      default=None,17810      description="""The name of the File API File to import. Example: `files/abc-123`""",17811  )17812  config: Optional[ImportFileConfig] = Field(17813      default=None, description="""Optional parameters for the request."""17814  )178151781617817class _ImportFileParametersDict(TypedDict, total=False):17818  """Config for file_search_stores.import_file parameters."""1781917820  file_search_store_name: Optional[str]17821  """The resource name of the FileSearchStore. Example: `fileSearchStores/my-file-search-store-123`"""1782217823  file_name: Optional[str]17824  """The name of the File API File to import. Example: `files/abc-123`"""1782517826  config: Optional[ImportFileConfigDict]17827  """Optional parameters for the request."""178281782917830_ImportFileParametersOrDict = Union[17831    _ImportFileParameters, _ImportFileParametersDict17832]178331783417835class ImportFileResponse(_common.BaseModel):17836  """Response for ImportFile to import a File API file with a file search store."""1783717838  sdk_http_response: Optional[HttpResponse] = Field(17839      default=None, description="""Used to retain the full HTTP response."""17840  )17841  parent: Optional[str] = Field(17842      default=None,17843      description="""The name of the FileSearchStore containing Documents.""",17844  )17845  document_name: Optional[str] = Field(17846      default=None, description="""The identifier for the Document imported."""17847  )178481784917850class ImportFileResponseDict(TypedDict, total=False):17851  """Response for ImportFile to import a File API file with a file search store."""1785217853  sdk_http_response: Optional[HttpResponseDict]17854  """Used to retain the full HTTP response."""1785517856  parent: Optional[str]17857  """The name of the FileSearchStore containing Documents."""1785817859  document_name: Optional[str]17860  """The identifier for the Document imported."""178611786217863ImportFileResponseOrDict = Union[ImportFileResponse, ImportFileResponseDict]178641786517866class ImportFileOperation(_common.BaseModel, Operation):17867  """Long-running operation for importing a file to a FileSearchStore."""1786817869  response: Optional[ImportFileResponse] = Field(17870      default=None,17871      description="""The result of the ImportFile operation, available when the operation is done.""",17872  )1787317874  @classmethod17875  def from_api_response(17876      cls, api_response: Any, is_vertex_ai: bool = False17877  ) -> Self:17878    """Instantiates a ImportFileOperation from an API response."""1787917880    response_dict = _ImportFileOperation_from_mldev(api_response)17881    return cls._from_response(response=response_dict, kwargs={})178821788317884class ListFilesConfig(_common.BaseModel):17885  """Used to override the default configuration."""1788617887  http_options: Optional[HttpOptions] = Field(17888      default=None, description="""Used to override HTTP request options."""17889  )17890  page_size: Optional[int] = Field(default=None, description="""""")17891  page_token: Optional[str] = Field(default=None, description="""""")178921789317894class ListFilesConfigDict(TypedDict, total=False):17895  """Used to override the default configuration."""1789617897  http_options: Optional[HttpOptionsDict]17898  """Used to override HTTP request options."""1789917900  page_size: Optional[int]17901  """"""1790217903  page_token: Optional[str]17904  """"""179051790617907ListFilesConfigOrDict = Union[ListFilesConfig, ListFilesConfigDict]179081790917910class _ListFilesParameters(_common.BaseModel):17911  """Generates the parameters for the list method."""1791217913  config: Optional[ListFilesConfig] = Field(17914      default=None,17915      description="""Used to override the default configuration.""",17916  )179171791817919class _ListFilesParametersDict(TypedDict, total=False):17920  """Generates the parameters for the list method."""1792117922  config: Optional[ListFilesConfigDict]17923  """Used to override the default configuration."""179241792517926_ListFilesParametersOrDict = Union[17927    _ListFilesParameters, _ListFilesParametersDict17928]179291793017931class ListFilesResponse(_common.BaseModel):17932  """Response for the list files method."""1793317934  sdk_http_response: Optional[HttpResponse] = Field(17935      default=None, description="""Used to retain the full HTTP response."""17936  )17937  next_page_token: Optional[str] = Field(17938      default=None,17939      description="""A token that can be sent as a `page_token` into a subsequent `ListFiles` call.""",17940  )17941  files: Optional[list[File]] = Field(17942      default=None, description="""The list of `File`s."""17943  )179441794517946class ListFilesResponseDict(TypedDict, total=False):17947  """Response for the list files method."""1794817949  sdk_http_response: Optional[HttpResponseDict]17950  """Used to retain the full HTTP response."""1795117952  next_page_token: Optional[str]17953  """A token that can be sent as a `page_token` into a subsequent `ListFiles` call."""1795417955  files: Optional[list[FileDict]]17956  """The list of `File`s."""179571795817959ListFilesResponseOrDict = Union[ListFilesResponse, ListFilesResponseDict]179601796117962class CreateFileConfig(_common.BaseModel):17963  """Used to override the default configuration."""1796417965  http_options: Optional[HttpOptions] = Field(17966      default=None, description="""Used to override HTTP request options."""17967  )17968  should_return_http_response: Optional[bool] = Field(17969      default=None,17970      description=""" If true, the raw HTTP response will be returned in the 'sdk_http_response' field.""",17971  )179721797317974class CreateFileConfigDict(TypedDict, total=False):17975  """Used to override the default configuration."""1797617977  http_options: Optional[HttpOptionsDict]17978  """Used to override HTTP request options."""1797917980  should_return_http_response: Optional[bool]17981  """ If true, the raw HTTP response will be returned in the 'sdk_http_response' field."""179821798317984CreateFileConfigOrDict = Union[CreateFileConfig, CreateFileConfigDict]179851798617987class _CreateFileParameters(_common.BaseModel):17988  """Generates the parameters for the private _create method."""1798917990  file: Optional[File] = Field(17991      default=None,17992      description="""The file to be uploaded.17993            mime_type: (Required) The MIME type of the file. Must be provided.17994            name: (Optional) The name of the file in the destination (e.g.17995            'files/sample-image').17996            display_name: (Optional) The display name of the file.17997      """,17998  )17999  config: Optional[CreateFileConfig] = Field(18000      default=None,18001      description="""Used to override the default configuration.""",18002  )180031800418005class _CreateFileParametersDict(TypedDict, total=False):18006  """Generates the parameters for the private _create method."""1800718008  file: Optional[FileDict]18009  """The file to be uploaded.18010            mime_type: (Required) The MIME type of the file. Must be provided.18011            name: (Optional) The name of the file in the destination (e.g.18012            'files/sample-image').18013            display_name: (Optional) The display name of the file.18014      """1801518016  config: Optional[CreateFileConfigDict]18017  """Used to override the default configuration."""180181801918020_CreateFileParametersOrDict = Union[18021    _CreateFileParameters, _CreateFileParametersDict18022]180231802418025class CreateFileResponse(_common.BaseModel):18026  """Response for the create file method."""1802718028  sdk_http_response: Optional[HttpResponse] = Field(18029      default=None, description="""Used to retain the full HTTP response."""18030  )180311803218033class CreateFileResponseDict(TypedDict, total=False):18034  """Response for the create file method."""1803518036  sdk_http_response: Optional[HttpResponseDict]18037  """Used to retain the full HTTP response."""180381803918040CreateFileResponseOrDict = Union[CreateFileResponse, CreateFileResponseDict]180411804218043class GetFileConfig(_common.BaseModel):18044  """Used to override the default configuration."""1804518046  http_options: Optional[HttpOptions] = Field(18047      default=None, description="""Used to override HTTP request options."""18048  )180491805018051class GetFileConfigDict(TypedDict, total=False):18052  """Used to override the default configuration."""1805318054  http_options: Optional[HttpOptionsDict]18055  """Used to override HTTP request options."""180561805718058GetFileConfigOrDict = Union[GetFileConfig, GetFileConfigDict]180591806018061class _GetFileParameters(_common.BaseModel):18062  """Generates the parameters for the get method."""1806318064  name: Optional[str] = Field(18065      default=None,18066      description="""The name identifier for the file to retrieve.""",18067  )18068  config: Optional[GetFileConfig] = Field(18069      default=None,18070      description="""Used to override the default configuration.""",18071  )180721807318074class _GetFileParametersDict(TypedDict, total=False):18075  """Generates the parameters for the get method."""1807618077  name: Optional[str]18078  """The name identifier for the file to retrieve."""1807918080  config: Optional[GetFileConfigDict]18081  """Used to override the default configuration."""180821808318084_GetFileParametersOrDict = Union[_GetFileParameters, _GetFileParametersDict]180851808618087class DeleteFileConfig(_common.BaseModel):18088  """Used to override the default configuration."""1808918090  http_options: Optional[HttpOptions] = Field(18091      default=None, description="""Used to override HTTP request options."""18092  )180931809418095class DeleteFileConfigDict(TypedDict, total=False):18096  """Used to override the default configuration."""1809718098  http_options: Optional[HttpOptionsDict]18099  """Used to override HTTP request options."""181001810118102DeleteFileConfigOrDict = Union[DeleteFileConfig, DeleteFileConfigDict]181031810418105class _DeleteFileParameters(_common.BaseModel):18106  """Generates the parameters for the get method."""1810718108  name: Optional[str] = Field(18109      default=None,18110      description="""The name identifier for the file to be deleted.""",18111  )18112  config: Optional[DeleteFileConfig] = Field(18113      default=None,18114      description="""Used to override the default configuration.""",18115  )181161811718118class _DeleteFileParametersDict(TypedDict, total=False):18119  """Generates the parameters for the get method."""1812018121  name: Optional[str]18122  """The name identifier for the file to be deleted."""1812318124  config: Optional[DeleteFileConfigDict]18125  """Used to override the default configuration."""181261812718128_DeleteFileParametersOrDict = Union[18129    _DeleteFileParameters, _DeleteFileParametersDict18130]181311813218133class DeleteFileResponse(_common.BaseModel):18134  """Response for the delete file method."""1813518136  sdk_http_response: Optional[HttpResponse] = Field(18137      default=None, description="""Used to retain the full HTTP response."""18138  )181391814018141class DeleteFileResponseDict(TypedDict, total=False):18142  """Response for the delete file method."""1814318144  sdk_http_response: Optional[HttpResponseDict]18145  """Used to retain the full HTTP response."""181461814718148DeleteFileResponseOrDict = Union[DeleteFileResponse, DeleteFileResponseDict]181491815018151class RegisterFilesConfig(_common.BaseModel):18152  """Used to override the default configuration."""1815318154  http_options: Optional[HttpOptions] = Field(18155      default=None, description="""Used to override HTTP request options."""18156  )18157  should_return_http_response: Optional[bool] = Field(18158      default=None,18159      description=""" If true, the raw HTTP response will be returned in the 'sdk_http_response' field.""",18160  )181611816218163class RegisterFilesConfigDict(TypedDict, total=False):18164  """Used to override the default configuration."""1816518166  http_options: Optional[HttpOptionsDict]18167  """Used to override HTTP request options."""1816818169  should_return_http_response: Optional[bool]18170  """ If true, the raw HTTP response will be returned in the 'sdk_http_response' field."""181711817218173RegisterFilesConfigOrDict = Union[RegisterFilesConfig, RegisterFilesConfigDict]181741817518176class _InternalRegisterFilesParameters(_common.BaseModel):18177  """Parameters for the private _Register method."""1817818179  uris: Optional[list[str]] = Field(18180      default=None,18181      description="""The Google Cloud Storage URIs to register. Example: `gs://bucket/object`.""",18182  )18183  config: Optional[RegisterFilesConfig] = Field(18184      default=None,18185      description="""Used to override the default configuration.""",18186  )181871818818189class _InternalRegisterFilesParametersDict(TypedDict, total=False):18190  """Parameters for the private _Register method."""1819118192  uris: Optional[list[str]]18193  """The Google Cloud Storage URIs to register. Example: `gs://bucket/object`."""1819418195  config: Optional[RegisterFilesConfigDict]18196  """Used to override the default configuration."""181971819818199_InternalRegisterFilesParametersOrDict = Union[18200    _InternalRegisterFilesParameters, _InternalRegisterFilesParametersDict18201]182021820318204class RegisterFilesResponse(_common.BaseModel):18205  """Response for the _register file method."""1820618207  sdk_http_response: Optional[HttpResponse] = Field(18208      default=None, description="""Used to retain the full HTTP response."""18209  )18210  files: Optional[list[File]] = Field(18211      default=None, description="""The registered files."""18212  )182131821418215class RegisterFilesResponseDict(TypedDict, total=False):18216  """Response for the _register file method."""1821718218  sdk_http_response: Optional[HttpResponseDict]18219  """Used to retain the full HTTP response."""1822018221  files: Optional[list[FileDict]]18222  """The registered files."""182231822418225RegisterFilesResponseOrDict = Union[18226    RegisterFilesResponse, RegisterFilesResponseDict18227]182281822918230class InlinedRequest(_common.BaseModel):18231  """Config for inlined request."""1823218233  model: Optional[str] = Field(18234      default=None,18235      description="""ID of the model to use. For a list of models, see `Google models18236      <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",18237  )18238  contents: Optional[ContentListUnion] = Field(18239      default=None,18240      description="""Content of the request.18241      """,18242  )18243  metadata: Optional[dict[str, str]] = Field(18244      default=None,18245      description="""The metadata to be associated with the request.""",18246  )18247  config: Optional[GenerateContentConfig] = Field(18248      default=None,18249      description="""Configuration that contains optional model parameters.18250      """,18251  )182521825318254class InlinedRequestDict(TypedDict, total=False):18255  """Config for inlined request."""1825618257  model: Optional[str]18258  """ID of the model to use. For a list of models, see `Google models18259      <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""1826018261  contents: Optional[ContentListUnionDict]18262  """Content of the request.18263      """1826418265  metadata: Optional[dict[str, str]]18266  """The metadata to be associated with the request."""1826718268  config: Optional[GenerateContentConfigDict]18269  """Configuration that contains optional model parameters.18270      """182711827218273InlinedRequestOrDict = Union[InlinedRequest, InlinedRequestDict]182741827518276class BatchJobSource(_common.BaseModel):18277  """Config for `src` parameter."""1827818279  format: Optional[str] = Field(18280      default=None,18281      description="""Storage format of the input files. Must be one of:18282      'jsonl', 'bigquery', 'vertex-dataset'.18283      """,18284  )18285  gcs_uri: Optional[list[str]] = Field(18286      default=None,18287      description="""The Google Cloud Storage URIs to input files.18288      """,18289  )18290  bigquery_uri: Optional[str] = Field(18291      default=None,18292      description="""The BigQuery URI to input table.18293      """,18294  )18295  file_name: Optional[str] = Field(18296      default=None,18297      description="""The Gemini Developer API's file resource name of the input data18298      (e.g. "files/12345").18299      """,18300  )18301  inlined_requests: Optional[list[InlinedRequest]] = Field(18302      default=None,18303      description="""The Gemini Developer API's inlined input data to run batch job.18304      """,18305  )18306  vertex_dataset_name: Optional[str] = Field(18307      default=None,18308      description="""This field is experimental and may change in future versions. The Vertex AI dataset resource name to use as input. Must be of type multimodal.18309      """,18310  )183111831218313class BatchJobSourceDict(TypedDict, total=False):18314  """Config for `src` parameter."""1831518316  format: Optional[str]18317  """Storage format of the input files. Must be one of:18318      'jsonl', 'bigquery', 'vertex-dataset'.18319      """1832018321  gcs_uri: Optional[list[str]]18322  """The Google Cloud Storage URIs to input files.18323      """1832418325  bigquery_uri: Optional[str]18326  """The BigQuery URI to input table.18327      """1832818329  file_name: Optional[str]18330  """The Gemini Developer API's file resource name of the input data18331      (e.g. "files/12345").18332      """1833318334  inlined_requests: Optional[list[InlinedRequestDict]]18335  """The Gemini Developer API's inlined input data to run batch job.18336      """1833718338  vertex_dataset_name: Optional[str]18339  """This field is experimental and may change in future versions. The Vertex AI dataset resource name to use as input. Must be of type multimodal.18340      """183411834218343BatchJobSourceOrDict = Union[BatchJobSource, BatchJobSourceDict]183441834518346class VertexMultimodalDatasetDestination(_common.BaseModel):18347  """This class is experimental and may change in future versions.1834818349  The specification for an output Vertex AI multimodal dataset.18350  """1835118352  bigquery_destination: Optional[str] = Field(18353      default=None,18354      description="""The BigQuery destination for the multimodal dataset.""",18355  )18356  display_name: Optional[str] = Field(18357      default=None,18358      description="""The display name of the multimodal dataset.""",18359  )183601836118362class VertexMultimodalDatasetDestinationDict(TypedDict, total=False):18363  """This class is experimental and may change in future versions.1836418365  The specification for an output Vertex AI multimodal dataset.18366  """1836718368  bigquery_destination: Optional[str]18369  """The BigQuery destination for the multimodal dataset."""1837018371  display_name: Optional[str]18372  """The display name of the multimodal dataset."""183731837418375VertexMultimodalDatasetDestinationOrDict = Union[18376    VertexMultimodalDatasetDestination, VertexMultimodalDatasetDestinationDict18377]183781837918380class JobError(_common.BaseModel):18381  """Job error."""1838218383  details: Optional[list[str]] = Field(18384      default=None,18385      description="""A list of messages that carry the error details. There is a common set of message types for APIs to use.""",18386  )18387  code: Optional[int] = Field(default=None, description="""The status code.""")18388  message: Optional[str] = Field(18389      default=None,18390      description="""A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the `details` field.""",18391  )183921839318394class JobErrorDict(TypedDict, total=False):18395  """Job error."""1839618397  details: Optional[list[str]]18398  """A list of messages that carry the error details. There is a common set of message types for APIs to use."""1839918400  code: Optional[int]18401  """The status code."""1840218403  message: Optional[str]18404  """A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the `details` field."""184051840618407JobErrorOrDict = Union[JobError, JobErrorDict]184081840918410class InlinedResponse(_common.BaseModel):18411  """Config for `inlined_responses` parameter."""1841218413  response: Optional[GenerateContentResponse] = Field(18414      default=None,18415      description="""The response to the request.18416      """,18417  )18418  metadata: Optional[dict[str, str]] = Field(18419      default=None,18420      description="""The metadata to be associated with the request.""",18421  )18422  error: Optional[JobError] = Field(18423      default=None,18424      description="""The error encountered while processing the request.18425      """,18426  )184271842818429class InlinedResponseDict(TypedDict, total=False):18430  """Config for `inlined_responses` parameter."""1843118432  response: Optional[GenerateContentResponseDict]18433  """The response to the request.18434      """1843518436  metadata: Optional[dict[str, str]]18437  """The metadata to be associated with the request."""1843818439  error: Optional[JobErrorDict]18440  """The error encountered while processing the request.18441      """184421844318444InlinedResponseOrDict = Union[InlinedResponse, InlinedResponseDict]184451844618447class SingleEmbedContentResponse(_common.BaseModel):18448  """Config for `response` parameter."""1844918450  embedding: Optional[ContentEmbedding] = Field(18451      default=None,18452      description="""The response to the request.18453      """,18454  )18455  token_count: Optional[int] = Field(18456      default=None,18457      description="""The error encountered while processing the request.18458      """,18459  )184601846118462class SingleEmbedContentResponseDict(TypedDict, total=False):18463  """Config for `response` parameter."""1846418465  embedding: Optional[ContentEmbeddingDict]18466  """The response to the request.18467      """1846818469  token_count: Optional[int]18470  """The error encountered while processing the request.18471      """184721847318474SingleEmbedContentResponseOrDict = Union[18475    SingleEmbedContentResponse, SingleEmbedContentResponseDict18476]184771847818479class InlinedEmbedContentResponse(_common.BaseModel):18480  """Config for `inlined_embedding_responses` parameter."""1848118482  response: Optional[SingleEmbedContentResponse] = Field(18483      default=None, description="""Output only. The response to the request."""18484  )18485  error: Optional[JobError] = Field(18486      default=None,18487      description="""Output only. The error encountered while processing the request.""",18488  )18489  metadata: Optional[dict[str, Any]] = Field(18490      default=None,18491      description="""Output only. The metadata associated with the request.""",18492  )184931849418495class InlinedEmbedContentResponseDict(TypedDict, total=False):18496  """Config for `inlined_embedding_responses` parameter."""1849718498  response: Optional[SingleEmbedContentResponseDict]18499  """Output only. The response to the request."""1850018501  error: Optional[JobErrorDict]18502  """Output only. The error encountered while processing the request."""1850318504  metadata: Optional[dict[str, Any]]18505  """Output only. The metadata associated with the request."""185061850718508InlinedEmbedContentResponseOrDict = Union[18509    InlinedEmbedContentResponse, InlinedEmbedContentResponseDict18510]185111851218513class BatchJobDestination(_common.BaseModel):18514  """Config for `dest` parameter."""1851518516  format: Optional[str] = Field(18517      default=None,18518      description="""Storage format of the output files. Must be one of:18519      'jsonl', 'bigquery', 'vertex-dataset'.18520      """,18521  )18522  gcs_uri: Optional[str] = Field(18523      default=None,18524      description="""The Google Cloud Storage URI to the output file.18525      """,18526  )18527  bigquery_uri: Optional[str] = Field(18528      default=None,18529      description="""The BigQuery URI to the output table.18530      """,18531  )18532  file_name: Optional[str] = Field(18533      default=None,18534      description="""The Gemini Developer API's file resource name of the output data18535      (e.g. "files/12345"). The file will be a JSONL file with a single response18536      per line. The responses will be GenerateContentResponse messages formatted18537      as JSON. The responses will be written in the same order as the input18538      requests.18539      """,18540  )18541  inlined_responses: Optional[list[InlinedResponse]] = Field(18542      default=None,18543      description="""The responses to the requests in the batch. Returned when the batch was18544      built using inlined requests. The responses will be in the same order as18545      the input requests.18546      """,18547  )18548  inlined_embed_content_responses: Optional[18549      list[InlinedEmbedContentResponse]18550  ] = Field(18551      default=None,18552      description="""The responses to the requests in the batch. Returned when the batch was18553      built using inlined requests. The responses will be in the same order as18554      the input requests.18555      """,18556  )18557  vertex_dataset: Optional[VertexMultimodalDatasetDestination] = Field(18558      default=None,18559      description="""This field is experimental and may change in future versions. The Vertex AI dataset destination.18560      """,18561  )185621856318564class BatchJobDestinationDict(TypedDict, total=False):18565  """Config for `dest` parameter."""1856618567  format: Optional[str]18568  """Storage format of the output files. Must be one of:18569      'jsonl', 'bigquery', 'vertex-dataset'.18570      """1857118572  gcs_uri: Optional[str]18573  """The Google Cloud Storage URI to the output file.18574      """1857518576  bigquery_uri: Optional[str]18577  """The BigQuery URI to the output table.18578      """1857918580  file_name: Optional[str]18581  """The Gemini Developer API's file resource name of the output data18582      (e.g. "files/12345"). The file will be a JSONL file with a single response18583      per line. The responses will be GenerateContentResponse messages formatted18584      as JSON. The responses will be written in the same order as the input18585      requests.18586      """1858718588  inlined_responses: Optional[list[InlinedResponseDict]]18589  """The responses to the requests in the batch. Returned when the batch was18590      built using inlined requests. The responses will be in the same order as18591      the input requests.18592      """1859318594  inlined_embed_content_responses: Optional[18595      list[InlinedEmbedContentResponseDict]18596  ]18597  """The responses to the requests in the batch. Returned when the batch was18598      built using inlined requests. The responses will be in the same order as18599      the input requests.18600      """1860118602  vertex_dataset: Optional[VertexMultimodalDatasetDestinationDict]18603  """This field is experimental and may change in future versions. The Vertex AI dataset destination.18604      """186051860618607BatchJobDestinationOrDict = Union[BatchJobDestination, BatchJobDestinationDict]186081860918610BatchJobDestinationUnion = Union[BatchJobDestination, str]186111861218613BatchJobDestinationUnionDict = Union[18614    BatchJobDestinationUnion, BatchJobDestinationDict18615]186161861718618class CreateBatchJobConfig(_common.BaseModel):18619  """Config for optional parameters."""1862018621  http_options: Optional[HttpOptions] = Field(18622      default=None, description="""Used to override HTTP request options."""18623  )18624  display_name: Optional[str] = Field(18625      default=None,18626      description="""The user-defined name of this BatchJob.18627      """,18628  )18629  dest: Optional[BatchJobDestinationUnion] = Field(18630      default=None,18631      description="""GCS or BigQuery URI prefix for the output predictions. Example:18632      "gs://path/to/output/data" or "bq://projectId.bqDatasetId.bqTableId".18633      """,18634  )18635  webhook_config: Optional[WebhookConfig] = Field(18636      default=None,18637      description="""Webhook configuration for receiving notifications when the batch18638      operation completes.18639      """,18640  )186411864218643class CreateBatchJobConfigDict(TypedDict, total=False):18644  """Config for optional parameters."""1864518646  http_options: Optional[HttpOptionsDict]18647  """Used to override HTTP request options."""1864818649  display_name: Optional[str]18650  """The user-defined name of this BatchJob.18651      """1865218653  dest: Optional[BatchJobDestinationUnionDict]18654  """GCS or BigQuery URI prefix for the output predictions. Example:18655      "gs://path/to/output/data" or "bq://projectId.bqDatasetId.bqTableId".18656      """1865718658  webhook_config: Optional[WebhookConfigDict]18659  """Webhook configuration for receiving notifications when the batch18660      operation completes.18661      """186621866318664CreateBatchJobConfigOrDict = Union[18665    CreateBatchJobConfig, CreateBatchJobConfigDict18666]186671866818669BatchJobSourceUnion = Union[BatchJobSource, list[InlinedRequest], str]186701867118672BatchJobSourceUnionDict = Union[18673    BatchJobSourceUnion, BatchJobSourceDict, list[InlinedRequestDict]18674]186751867618677class _CreateBatchJobParameters(_common.BaseModel):18678  """Config for batches.create parameters."""1867918680  model: Optional[str] = Field(18681      default=None,18682      description="""The name of the model to produces the predictions via the BatchJob.18683      """,18684  )18685  src: Optional[BatchJobSourceUnion] = Field(18686      default=None,18687      description="""GCS URI(-s) or BigQuery URI to your input data to run batch job.18688      Example: "gs://path/to/input/data" or "bq://projectId.bqDatasetId.bqTableId".18689      """,18690  )18691  config: Optional[CreateBatchJobConfig] = Field(18692      default=None,18693      description="""Optional parameters for creating a BatchJob.18694      """,18695  )186961869718698class _CreateBatchJobParametersDict(TypedDict, total=False):18699  """Config for batches.create parameters."""1870018701  model: Optional[str]18702  """The name of the model to produces the predictions via the BatchJob.18703      """1870418705  src: Optional[BatchJobSourceUnionDict]18706  """GCS URI(-s) or BigQuery URI to your input data to run batch job.18707      Example: "gs://path/to/input/data" or "bq://projectId.bqDatasetId.bqTableId".18708      """1870918710  config: Optional[CreateBatchJobConfigDict]18711  """Optional parameters for creating a BatchJob.18712      """187131871418715_CreateBatchJobParametersOrDict = Union[18716    _CreateBatchJobParameters, _CreateBatchJobParametersDict18717]187181871918720class BatchJobOutputInfo(_common.BaseModel):18721  """Represents the `output_info` field in batch jobs."""1872218723  vertex_multimodal_dataset_name: Optional[str] = Field(18724      default=None,18725      description="""This field is experimental and may change in future versions. The Vertex AI dataset name containing the output data.""",18726  )18727  gcs_output_directory: Optional[str] = Field(18728      default=None,18729      description="""The full path of the Cloud Storage directory created, into which the prediction output is written.""",18730  )18731  bigquery_output_table: Optional[str] = Field(18732      default=None,18733      description="""The name of the BigQuery table created, in `predictions_TIMESTAMP` format, into which the prediction output is written.""",18734  )187351873618737class BatchJobOutputInfoDict(TypedDict, total=False):18738  """Represents the `output_info` field in batch jobs."""1873918740  vertex_multimodal_dataset_name: Optional[str]18741  """This field is experimental and may change in future versions. The Vertex AI dataset name containing the output data."""1874218743  gcs_output_directory: Optional[str]18744  """The full path of the Cloud Storage directory created, into which the prediction output is written."""1874518746  bigquery_output_table: Optional[str]18747  """The name of the BigQuery table created, in `predictions_TIMESTAMP` format, into which the prediction output is written."""187481874918750BatchJobOutputInfoOrDict = Union[BatchJobOutputInfo, BatchJobOutputInfoDict]187511875218753class CompletionStats(_common.BaseModel):18754  """Success and error statistics of processing multiple entities (for example, DataItems or structured data rows) in batch.1875518756  This data type is not supported in Gemini API.18757  """1875818759  failed_count: Optional[int] = Field(18760      default=None,18761      description="""Output only. The number of entities for which any error was encountered.""",18762  )18763  incomplete_count: Optional[int] = Field(18764      default=None,18765      description="""Output only. In cases when enough errors are encountered a job, pipeline, or operation may be failed as a whole. Below is the number of entities for which the processing had not been finished (either in successful or failed state). Set to -1 if the number is unknown (for example, the operation failed before the total entity number could be collected).""",18766  )18767  successful_count: Optional[int] = Field(18768      default=None,18769      description="""Output only. The number of entities that had been processed successfully.""",18770  )18771  successful_forecast_point_count: Optional[int] = Field(18772      default=None,18773      description="""Output only. The number of the successful forecast points that are generated by the forecasting model. This is ONLY used by the forecasting batch prediction.""",18774  )187751877618777class CompletionStatsDict(TypedDict, total=False):18778  """Success and error statistics of processing multiple entities (for example, DataItems or structured data rows) in batch.1877918780  This data type is not supported in Gemini API.18781  """1878218783  failed_count: Optional[int]18784  """Output only. The number of entities for which any error was encountered."""1878518786  incomplete_count: Optional[int]18787  """Output only. In cases when enough errors are encountered a job, pipeline, or operation may be failed as a whole. Below is the number of entities for which the processing had not been finished (either in successful or failed state). Set to -1 if the number is unknown (for example, the operation failed before the total entity number could be collected)."""1878818789  successful_count: Optional[int]18790  """Output only. The number of entities that had been processed successfully."""1879118792  successful_forecast_point_count: Optional[int]18793  """Output only. The number of the successful forecast points that are generated by the forecasting model. This is ONLY used by the forecasting batch prediction."""187941879518796CompletionStatsOrDict = Union[CompletionStats, CompletionStatsDict]187971879818799class BatchJob(_common.BaseModel):18800  """Config for batches.create return value."""1880118802  name: Optional[str] = Field(18803      default=None,18804      description="""The resource name of the BatchJob. Output only.".18805      """,18806  )18807  display_name: Optional[str] = Field(18808      default=None,18809      description="""The display name of the BatchJob.18810      """,18811  )18812  state: Optional[JobState] = Field(18813      default=None,18814      description="""The state of the BatchJob.18815      """,18816  )18817  error: Optional[JobError] = Field(18818      default=None,18819      description="""Output only. Only populated when the job's state is JOB_STATE_FAILED or JOB_STATE_CANCELLED.""",18820  )18821  create_time: Optional[datetime.datetime] = Field(18822      default=None,18823      description="""The time when the BatchJob was created.18824      """,18825  )18826  start_time: Optional[datetime.datetime] = Field(18827      default=None,18828      description="""Output only. Time when the Job for the first time entered the `JOB_STATE_RUNNING` state.""",18829  )18830  end_time: Optional[datetime.datetime] = Field(18831      default=None,18832      description="""The time when the BatchJob was completed. This field is for Gemini Enterprise Agent Platform only.18833      """,18834  )18835  update_time: Optional[datetime.datetime] = Field(18836      default=None,18837      description="""The time when the BatchJob was last updated.18838      """,18839  )18840  model: Optional[str] = Field(18841      default=None,18842      description="""The name of the model that produces the predictions via the BatchJob.18843      """,18844  )18845  src: Optional[BatchJobSource] = Field(18846      default=None,18847      description="""Configuration for the input data. This field is for Gemini Enterprise Agent Platform only.18848      """,18849  )18850  dest: Optional[BatchJobDestination] = Field(18851      default=None,18852      description="""Configuration for the output data.18853      """,18854  )18855  completion_stats: Optional[CompletionStats] = Field(18856      default=None,18857      description="""Statistics on completed and failed prediction instances. This field is for Gemini Enterprise Agent Platform only.18858      """,18859  )18860  output_info: Optional[BatchJobOutputInfo] = Field(18861      default=None,18862      description="""Information further describing the output of this job. Output only.18863      """,18864  )1886518866  @property18867  def done(self) -> bool:18868    """Returns True if the batch job has ended."""18869    if self.state is None:18870      return False18871    return self.state.name in JOB_STATES_ENDED188721887318874class GenerationConfigThinkingConfig(ThinkingConfig):18875  """Config for thinking feature.1887618877  This class will be deprecated. Please use `ThinkingConfig` instead.18878  """188791888018881class GenerationConfigThinkingConfigDict(ThinkingConfigDict):18882  """Config for thinking feature.1888318884  This class will be deprecated. Please use `ThinkingConfig` instead.18885  """188861888718888GenerationConfigThinkingConfigOrDict = Union[18889    GenerationConfigThinkingConfig, GenerationConfigThinkingConfigDict18890]188911889218893class BatchJobDict(TypedDict, total=False):18894  """Config for batches.create return value."""1889518896  name: Optional[str]18897  """The resource name of the BatchJob. Output only.".18898      """1889918900  display_name: Optional[str]18901  """The display name of the BatchJob.18902      """1890318904  state: Optional[JobState]18905  """The state of the BatchJob.18906      """1890718908  error: Optional[JobErrorDict]18909  """Output only. Only populated when the job's state is JOB_STATE_FAILED or JOB_STATE_CANCELLED."""1891018911  create_time: Optional[datetime.datetime]18912  """The time when the BatchJob was created.18913      """1891418915  start_time: Optional[datetime.datetime]18916  """Output only. Time when the Job for the first time entered the `JOB_STATE_RUNNING` state."""1891718918  end_time: Optional[datetime.datetime]18919  """The time when the BatchJob was completed. This field is for Gemini Enterprise Agent Platform only.18920      """1892118922  update_time: Optional[datetime.datetime]18923  """The time when the BatchJob was last updated.18924      """1892518926  model: Optional[str]18927  """The name of the model that produces the predictions via the BatchJob.18928      """1892918930  src: Optional[BatchJobSourceDict]18931  """Configuration for the input data. This field is for Gemini Enterprise Agent Platform only.18932      """1893318934  dest: Optional[BatchJobDestinationDict]18935  """Configuration for the output data.18936      """1893718938  completion_stats: Optional[CompletionStatsDict]18939  """Statistics on completed and failed prediction instances. This field is for Gemini Enterprise Agent Platform only.18940      """1894118942  output_info: Optional[BatchJobOutputInfoDict]18943  """Information further describing the output of this job. Output only.18944      """189451894618947BatchJobOrDict = Union[BatchJob, BatchJobDict]189481894918950class EmbedContentBatch(_common.BaseModel):18951  """Parameters for the embed_content method."""1895218953  contents: Optional[ContentListUnion] = Field(18954      default=None,18955      description="""The content to embed. Only the `parts.text` fields will be counted.18956      """,18957  )18958  config: Optional[EmbedContentConfig] = Field(18959      default=None,18960      description="""Configuration that contains optional parameters.18961      """,18962  )189631896418965class EmbedContentBatchDict(TypedDict, total=False):18966  """Parameters for the embed_content method."""1896718968  contents: Optional[ContentListUnionDict]18969  """The content to embed. Only the `parts.text` fields will be counted.18970      """1897118972  config: Optional[EmbedContentConfigDict]18973  """Configuration that contains optional parameters.18974      """189751897618977EmbedContentBatchOrDict = Union[EmbedContentBatch, EmbedContentBatchDict]189781897918980class EmbeddingsBatchJobSource(_common.BaseModel):1898118982  file_name: Optional[str] = Field(18983      default=None,18984      description="""The Gemini Developer API's file resource name of the input data18985      (e.g. "files/12345").18986      """,18987  )18988  inlined_requests: Optional[EmbedContentBatch] = Field(18989      default=None,18990      description="""The Gemini Developer API's inlined input data to run batch job.18991      """,18992  )189931899418995class EmbeddingsBatchJobSourceDict(TypedDict, total=False):1899618997  file_name: Optional[str]18998  """The Gemini Developer API's file resource name of the input data18999      (e.g. "files/12345").19000      """1900119002  inlined_requests: Optional[EmbedContentBatchDict]19003  """The Gemini Developer API's inlined input data to run batch job.19004      """190051900619007EmbeddingsBatchJobSourceOrDict = Union[19008    EmbeddingsBatchJobSource, EmbeddingsBatchJobSourceDict19009]190101901119012class CreateEmbeddingsBatchJobConfig(_common.BaseModel):19013  """Config for optional parameters."""1901419015  http_options: Optional[HttpOptions] = Field(19016      default=None, description="""Used to override HTTP request options."""19017  )19018  display_name: Optional[str] = Field(19019      default=None,19020      description="""The user-defined name of this BatchJob.19021      """,19022  )190231902419025class CreateEmbeddingsBatchJobConfigDict(TypedDict, total=False):19026  """Config for optional parameters."""1902719028  http_options: Optional[HttpOptionsDict]19029  """Used to override HTTP request options."""1903019031  display_name: Optional[str]19032  """The user-defined name of this BatchJob.19033      """190341903519036CreateEmbeddingsBatchJobConfigOrDict = Union[19037    CreateEmbeddingsBatchJobConfig, CreateEmbeddingsBatchJobConfigDict19038]190391904019041class _CreateEmbeddingsBatchJobParameters(_common.BaseModel):19042  """Config for batches.create parameters."""1904319044  model: Optional[str] = Field(19045      default=None,19046      description="""The name of the model to produces the predictions via the BatchJob.19047      """,19048  )19049  src: Optional[EmbeddingsBatchJobSource] = Field(19050      default=None,19051      description="""input data to run batch job".19052      """,19053  )19054  config: Optional[CreateEmbeddingsBatchJobConfig] = Field(19055      default=None,19056      description="""Optional parameters for creating a BatchJob.19057      """,19058  )190591906019061class _CreateEmbeddingsBatchJobParametersDict(TypedDict, total=False):19062  """Config for batches.create parameters."""1906319064  model: Optional[str]19065  """The name of the model to produces the predictions via the BatchJob.19066      """1906719068  src: Optional[EmbeddingsBatchJobSourceDict]19069  """input data to run batch job".19070      """1907119072  config: Optional[CreateEmbeddingsBatchJobConfigDict]19073  """Optional parameters for creating a BatchJob.19074      """190751907619077_CreateEmbeddingsBatchJobParametersOrDict = Union[19078    _CreateEmbeddingsBatchJobParameters, _CreateEmbeddingsBatchJobParametersDict19079]190801908119082class GetBatchJobConfig(_common.BaseModel):19083  """Optional parameters."""1908419085  http_options: Optional[HttpOptions] = Field(19086      default=None, description="""Used to override HTTP request options."""19087  )190881908919090class GetBatchJobConfigDict(TypedDict, total=False):19091  """Optional parameters."""1909219093  http_options: Optional[HttpOptionsDict]19094  """Used to override HTTP request options."""190951909619097GetBatchJobConfigOrDict = Union[GetBatchJobConfig, GetBatchJobConfigDict]190981909919100class _GetBatchJobParameters(_common.BaseModel):19101  """Config for batches.get parameters."""1910219103  name: Optional[str] = Field(19104      default=None,19105      description="""A fully-qualified BatchJob resource name or ID.19106    Example: "projects/.../locations/.../batchPredictionJobs/456"19107    or "456" when project and location are initialized in the client.19108    """,19109  )19110  config: Optional[GetBatchJobConfig] = Field(19111      default=None, description="""Optional parameters for the request."""19112  )191131911419115class _GetBatchJobParametersDict(TypedDict, total=False):19116  """Config for batches.get parameters."""1911719118  name: Optional[str]19119  """A fully-qualified BatchJob resource name or ID.19120    Example: "projects/.../locations/.../batchPredictionJobs/456"19121    or "456" when project and location are initialized in the client.19122    """1912319124  config: Optional[GetBatchJobConfigDict]19125  """Optional parameters for the request."""191261912719128_GetBatchJobParametersOrDict = Union[19129    _GetBatchJobParameters, _GetBatchJobParametersDict19130]191311913219133class CancelBatchJobConfig(_common.BaseModel):19134  """Optional parameters."""1913519136  http_options: Optional[HttpOptions] = Field(19137      default=None, description="""Used to override HTTP request options."""19138  )191391914019141class CancelBatchJobConfigDict(TypedDict, total=False):19142  """Optional parameters."""1914319144  http_options: Optional[HttpOptionsDict]19145  """Used to override HTTP request options."""191461914719148CancelBatchJobConfigOrDict = Union[19149    CancelBatchJobConfig, CancelBatchJobConfigDict19150]191511915219153class _CancelBatchJobParameters(_common.BaseModel):19154  """Config for batches.cancel parameters."""1915519156  name: Optional[str] = Field(19157      default=None,19158      description="""A fully-qualified BatchJob resource name or ID.19159    Example: "projects/.../locations/.../batchPredictionJobs/456"19160    or "456" when project and location are initialized in the client.19161    """,19162  )19163  config: Optional[CancelBatchJobConfig] = Field(19164      default=None, description="""Optional parameters for the request."""19165  )191661916719168class _CancelBatchJobParametersDict(TypedDict, total=False):19169  """Config for batches.cancel parameters."""1917019171  name: Optional[str]19172  """A fully-qualified BatchJob resource name or ID.19173    Example: "projects/.../locations/.../batchPredictionJobs/456"19174    or "456" when project and location are initialized in the client.19175    """1917619177  config: Optional[CancelBatchJobConfigDict]19178  """Optional parameters for the request."""191791918019181_CancelBatchJobParametersOrDict = Union[19182    _CancelBatchJobParameters, _CancelBatchJobParametersDict19183]191841918519186class ListBatchJobsConfig(_common.BaseModel):19187  """Config for optional parameters."""1918819189  http_options: Optional[HttpOptions] = Field(19190      default=None, description="""Used to override HTTP request options."""19191  )19192  page_size: Optional[int] = Field(default=None, description="""""")19193  page_token: Optional[str] = Field(default=None, description="""""")19194  filter: Optional[str] = Field(default=None, description="""""")191951919619197class ListBatchJobsConfigDict(TypedDict, total=False):19198  """Config for optional parameters."""1919919200  http_options: Optional[HttpOptionsDict]19201  """Used to override HTTP request options."""1920219203  page_size: Optional[int]19204  """"""1920519206  page_token: Optional[str]19207  """"""1920819209  filter: Optional[str]19210  """"""192111921219213ListBatchJobsConfigOrDict = Union[ListBatchJobsConfig, ListBatchJobsConfigDict]192141921519216class _ListBatchJobsParameters(_common.BaseModel):19217  """Config for batches.list parameters."""1921819219  config: Optional[ListBatchJobsConfig] = Field(19220      default=None, description=""""""19221  )192221922319224class _ListBatchJobsParametersDict(TypedDict, total=False):19225  """Config for batches.list parameters."""1922619227  config: Optional[ListBatchJobsConfigDict]19228  """"""192291923019231_ListBatchJobsParametersOrDict = Union[19232    _ListBatchJobsParameters, _ListBatchJobsParametersDict19233]192341923519236class ListBatchJobsResponse(_common.BaseModel):19237  """Config for batches.list return value."""1923819239  sdk_http_response: Optional[HttpResponse] = Field(19240      default=None, description="""Used to retain the full HTTP response."""19241  )19242  next_page_token: Optional[str] = Field(default=None, description="""""")19243  batch_jobs: Optional[list[BatchJob]] = Field(default=None, description="""""")192441924519246class ListBatchJobsResponseDict(TypedDict, total=False):19247  """Config for batches.list return value."""1924819249  sdk_http_response: Optional[HttpResponseDict]19250  """Used to retain the full HTTP response."""1925119252  next_page_token: Optional[str]19253  """"""1925419255  batch_jobs: Optional[list[BatchJobDict]]19256  """"""192571925819259ListBatchJobsResponseOrDict = Union[19260    ListBatchJobsResponse, ListBatchJobsResponseDict19261]192621926319264class DeleteBatchJobConfig(_common.BaseModel):19265  """Optional parameters for models.get method."""1926619267  http_options: Optional[HttpOptions] = Field(19268      default=None, description="""Used to override HTTP request options."""19269  )192701927119272class DeleteBatchJobConfigDict(TypedDict, total=False):19273  """Optional parameters for models.get method."""1927419275  http_options: Optional[HttpOptionsDict]19276  """Used to override HTTP request options."""192771927819279DeleteBatchJobConfigOrDict = Union[19280    DeleteBatchJobConfig, DeleteBatchJobConfigDict19281]192821928319284class _DeleteBatchJobParameters(_common.BaseModel):19285  """Config for batches.delete parameters."""1928619287  name: Optional[str] = Field(19288      default=None,19289      description="""A fully-qualified BatchJob resource name or ID.19290    Example: "projects/.../locations/.../batchPredictionJobs/456"19291    or "456" when project and location are initialized in the client.19292    """,19293  )19294  config: Optional[DeleteBatchJobConfig] = Field(19295      default=None, description="""Optional parameters for the request."""19296  )192971929819299class _DeleteBatchJobParametersDict(TypedDict, total=False):19300  """Config for batches.delete parameters."""1930119302  name: Optional[str]19303  """A fully-qualified BatchJob resource name or ID.19304    Example: "projects/.../locations/.../batchPredictionJobs/456"19305    or "456" when project and location are initialized in the client.19306    """1930719308  config: Optional[DeleteBatchJobConfigDict]19309  """Optional parameters for the request."""193101931119312_DeleteBatchJobParametersOrDict = Union[19313    _DeleteBatchJobParameters, _DeleteBatchJobParametersDict19314]193151931619317class DeleteResourceJob(_common.BaseModel):19318  """The return value of delete operation."""1931919320  sdk_http_response: Optional[HttpResponse] = Field(19321      default=None, description="""Used to retain the full HTTP response."""19322  )19323  name: Optional[str] = Field(default=None, description="""""")19324  done: Optional[bool] = Field(default=None, description="""""")19325  error: Optional[JobError] = Field(default=None, description="""""")193261932719328class DeleteResourceJobDict(TypedDict, total=False):19329  """The return value of delete operation."""1933019331  sdk_http_response: Optional[HttpResponseDict]19332  """Used to retain the full HTTP response."""1933319334  name: Optional[str]19335  """"""1933619337  done: Optional[bool]19338  """"""1933919340  error: Optional[JobErrorDict]19341  """"""193421934319344DeleteResourceJobOrDict = Union[DeleteResourceJob, DeleteResourceJobDict]193451934619347class GetOperationConfig(_common.BaseModel):1934819349  http_options: Optional[HttpOptions] = Field(19350      default=None, description="""Used to override HTTP request options."""19351  )193521935319354class GetOperationConfigDict(TypedDict, total=False):1935519356  http_options: Optional[HttpOptionsDict]19357  """Used to override HTTP request options."""193581935919360GetOperationConfigOrDict = Union[GetOperationConfig, GetOperationConfigDict]193611936219363class _GetOperationParameters(_common.BaseModel):19364  """Parameters for the GET method."""1936519366  operation_name: Optional[str] = Field(19367      default=None,19368      description="""The server-assigned name for the operation.""",19369  )19370  config: Optional[GetOperationConfig] = Field(19371      default=None,19372      description="""Used to override the default configuration.""",19373  )193741937519376class _GetOperationParametersDict(TypedDict, total=False):19377  """Parameters for the GET method."""1937819379  operation_name: Optional[str]19380  """The server-assigned name for the operation."""1938119382  config: Optional[GetOperationConfigDict]19383  """Used to override the default configuration."""193841938519386_GetOperationParametersOrDict = Union[19387    _GetOperationParameters, _GetOperationParametersDict19388]193891939019391class FetchPredictOperationConfig(_common.BaseModel):1939219393  http_options: Optional[HttpOptions] = Field(19394      default=None, description="""Used to override HTTP request options."""19395  )193961939719398class FetchPredictOperationConfigDict(TypedDict, total=False):1939919400  http_options: Optional[HttpOptionsDict]19401  """Used to override HTTP request options."""194021940319404FetchPredictOperationConfigOrDict = Union[19405    FetchPredictOperationConfig, FetchPredictOperationConfigDict19406]194071940819409class _FetchPredictOperationParameters(_common.BaseModel):19410  """Parameters for the fetchPredictOperation method."""1941119412  operation_name: Optional[str] = Field(19413      default=None,19414      description="""The server-assigned name for the operation.""",19415  )19416  resource_name: Optional[str] = Field(default=None, description="""""")19417  config: Optional[FetchPredictOperationConfig] = Field(19418      default=None,19419      description="""Used to override the default configuration.""",19420  )194211942219423class _FetchPredictOperationParametersDict(TypedDict, total=False):19424  """Parameters for the fetchPredictOperation method."""1942519426  operation_name: Optional[str]19427  """The server-assigned name for the operation."""1942819429  resource_name: Optional[str]19430  """"""1943119432  config: Optional[FetchPredictOperationConfigDict]19433  """Used to override the default configuration."""194341943519436_FetchPredictOperationParametersOrDict = Union[19437    _FetchPredictOperationParameters, _FetchPredictOperationParametersDict19438]194391944019441class _GetProjectOperationParameters(_common.BaseModel):19442  """Parameters for the getProjectOperation method."""1944319444  operation_id: Optional[str] = Field(19445      default=None,19446      description="""The ID of the project-level Gemini Enterprise Agent Platform operation to get. For example if the operation resource name is19447      projects/123/locations/us-central1/operations/456, the operation_id is19448      456.""",19449  )19450  config: Optional[GetOperationConfig] = Field(19451      default=None,19452      description="""Used to override the default configuration.""",19453  )194541945519456class _GetProjectOperationParametersDict(TypedDict, total=False):19457  """Parameters for the getProjectOperation method."""1945819459  operation_id: Optional[str]19460  """The ID of the project-level Gemini Enterprise Agent Platform operation to get. For example if the operation resource name is19461      projects/123/locations/us-central1/operations/456, the operation_id is19462      456."""1946319464  config: Optional[GetOperationConfigDict]19465  """Used to override the default configuration."""194661946719468_GetProjectOperationParametersOrDict = Union[19469    _GetProjectOperationParameters, _GetProjectOperationParametersDict19470]194711947219473class ProjectOperation(_common.BaseModel):19474  """A project-level operation in Gemini Enterprise Agent Platform."""1947519476  name: Optional[str] = Field(19477      default=None,19478      description="""The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.""",19479  )19480  metadata: Optional[dict[str, Any]] = Field(19481      default=None,19482      description="""Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata.  Any method that returns a long-running operation should document the metadata type, if any.""",19483  )19484  done: Optional[bool] = Field(19485      default=None,19486      description="""If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.""",19487  )19488  error: Optional[dict[str, Any]] = Field(19489      default=None,19490      description="""The error result of the operation in case of failure or cancellation.""",19491  )194921949319494class ProjectOperationDict(TypedDict, total=False):19495  """A project-level operation in Gemini Enterprise Agent Platform."""1949619497  name: Optional[str]19498  """The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`."""1949919500  metadata: Optional[dict[str, Any]]19501  """Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata.  Any method that returns a long-running operation should document the metadata type, if any."""1950219503  done: Optional[bool]19504  """If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available."""1950519506  error: Optional[dict[str, Any]]19507  """The error result of the operation in case of failure or cancellation."""195081950919510ProjectOperationOrDict = Union[ProjectOperation, ProjectOperationDict]195111951219513class TestTableItem(_common.BaseModel):1951419515  name: Optional[str] = Field(19516      default=None,19517      description="""The name of the test. This is used to derive the replay id.""",19518  )19519  parameters: Optional[dict[str, Any]] = Field(19520      default=None,19521      description="""The parameters to the test. Use pydantic models.""",19522  )19523  exception_if_mldev: Optional[str] = Field(19524      default=None,19525      description="""Expects an exception for MLDev matching the string.""",19526  )19527  exception_if_vertex: Optional[str] = Field(19528      default=None,19529      description="""Expects an exception for Vertex matching the string.""",19530  )19531  override_replay_id: Optional[str] = Field(19532      default=None,19533      description="""Use if you don't want to use the default replay id which is derived from the test name.""",19534  )19535  has_union: Optional[bool] = Field(19536      default=None,19537      description="""True if the parameters contain an unsupported union type. This test  will be skipped for languages that do not support the union type.""",19538  )19539  skip_in_api_mode: Optional[str] = Field(19540      default=None,19541      description="""When set to a reason string, this test will be skipped in the API mode. Use this flag for tests that can not be reproduced with the real API. E.g. a test that deletes a resource.""",19542  )19543  ignore_keys: Optional[list[str]] = Field(19544      default=None,19545      description="""Keys to ignore when comparing the request and response. This is useful for tests that are not deterministic.""",19546  )195471954819549class TestTableItemDict(TypedDict, total=False):1955019551  name: Optional[str]19552  """The name of the test. This is used to derive the replay id."""1955319554  parameters: Optional[dict[str, Any]]19555  """The parameters to the test. Use pydantic models."""1955619557  exception_if_mldev: Optional[str]19558  """Expects an exception for MLDev matching the string."""1955919560  exception_if_vertex: Optional[str]19561  """Expects an exception for Vertex matching the string."""1956219563  override_replay_id: Optional[str]19564  """Use if you don't want to use the default replay id which is derived from the test name."""1956519566  has_union: Optional[bool]19567  """True if the parameters contain an unsupported union type. This test  will be skipped for languages that do not support the union type."""1956819569  skip_in_api_mode: Optional[str]19570  """When set to a reason string, this test will be skipped in the API mode. Use this flag for tests that can not be reproduced with the real API. E.g. a test that deletes a resource."""1957119572  ignore_keys: Optional[list[str]]19573  """Keys to ignore when comparing the request and response. This is useful for tests that are not deterministic."""195741957519576TestTableItemOrDict = Union[TestTableItem, TestTableItemDict]195771957819579class TestTableFile(_common.BaseModel):1958019581  comment: Optional[str] = Field(default=None, description="""""")19582  test_method: Optional[str] = Field(default=None, description="""""")19583  parameter_names: Optional[list[str]] = Field(default=None, description="""""")19584  test_table: Optional[list[TestTableItem]] = Field(19585      default=None, description=""""""19586  )195871958819589class TestTableFileDict(TypedDict, total=False):1959019591  comment: Optional[str]19592  """"""1959319594  test_method: Optional[str]19595  """"""1959619597  parameter_names: Optional[list[str]]19598  """"""1959919600  test_table: Optional[list[TestTableItemDict]]19601  """"""196021960319604TestTableFileOrDict = Union[TestTableFile, TestTableFileDict]196051960619607class ReplayRequest(_common.BaseModel):19608  """Represents a single request in a replay."""1960919610  method: Optional[str] = Field(default=None, description="""""")19611  url: Optional[str] = Field(default=None, description="""""")19612  headers: Optional[dict[str, str]] = Field(default=None, description="""""")19613  body_segments: Optional[list[dict[str, Any]]] = Field(19614      default=None, description=""""""19615  )196161961719618class ReplayRequestDict(TypedDict, total=False):19619  """Represents a single request in a replay."""1962019621  method: Optional[str]19622  """"""1962319624  url: Optional[str]19625  """"""1962619627  headers: Optional[dict[str, str]]19628  """"""1962919630  body_segments: Optional[list[dict[str, Any]]]19631  """"""196321963319634ReplayRequestOrDict = Union[ReplayRequest, ReplayRequestDict]196351963619637class ReplayResponse(_common.BaseModel):19638  """Represents a single response in a replay."""1963919640  status_code: Optional[int] = Field(default=None, description="""""")19641  headers: Optional[dict[str, str]] = Field(default=None, description="""""")19642  body_segments: Optional[list[dict[str, Any]]] = Field(19643      default=None, description=""""""19644  )19645  sdk_response_segments: Optional[list[dict[str, Any]]] = Field(19646      default=None, description=""""""19647  )196481964919650class ReplayResponseDict(TypedDict, total=False):19651  """Represents a single response in a replay."""1965219653  status_code: Optional[int]19654  """"""1965519656  headers: Optional[dict[str, str]]19657  """"""1965819659  body_segments: Optional[list[dict[str, Any]]]19660  """"""1966119662  sdk_response_segments: Optional[list[dict[str, Any]]]19663  """"""196641966519666ReplayResponseOrDict = Union[ReplayResponse, ReplayResponseDict]196671966819669class ReplayInteraction(_common.BaseModel):19670  """Represents a single interaction, request and response in a replay."""1967119672  request: Optional[ReplayRequest] = Field(default=None, description="""""")19673  response: Optional[ReplayResponse] = Field(default=None, description="""""")196741967519676class ReplayInteractionDict(TypedDict, total=False):19677  """Represents a single interaction, request and response in a replay."""1967819679  request: Optional[ReplayRequestDict]19680  """"""1968119682  response: Optional[ReplayResponseDict]19683  """"""196841968519686ReplayInteractionOrDict = Union[ReplayInteraction, ReplayInteractionDict]196871968819689class ReplayFile(_common.BaseModel):19690  """Represents a recorded session."""1969119692  replay_id: Optional[str] = Field(default=None, description="""""")19693  interactions: Optional[list[ReplayInteraction]] = Field(19694      default=None, description=""""""19695  )196961969719698class ReplayFileDict(TypedDict, total=False):19699  """Represents a recorded session."""1970019701  replay_id: Optional[str]19702  """"""1970319704  interactions: Optional[list[ReplayInteractionDict]]19705  """"""197061970719708ReplayFileOrDict = Union[ReplayFile, ReplayFileDict]197091971019711class UploadFileConfig(_common.BaseModel):19712  """Used to override the default configuration."""1971319714  http_options: Optional[HttpOptions] = Field(19715      default=None, description="""Used to override HTTP request options."""19716  )19717  name: Optional[str] = Field(19718      default=None,19719      description="""The name of the file in the destination (e.g., 'files/sample-image'. If not provided one will be generated.""",19720  )19721  mime_type: Optional[str] = Field(19722      default=None,19723      description="""mime_type: The MIME type of the file. If not provided, it will be inferred from the file extension.""",19724  )19725  display_name: Optional[str] = Field(19726      default=None, description="""Optional display name of the file."""19727  )197281972919730class UploadFileConfigDict(TypedDict, total=False):19731  """Used to override the default configuration."""1973219733  http_options: Optional[HttpOptionsDict]19734  """Used to override HTTP request options."""1973519736  name: Optional[str]19737  """The name of the file in the destination (e.g., 'files/sample-image'. If not provided one will be generated."""1973819739  mime_type: Optional[str]19740  """mime_type: The MIME type of the file. If not provided, it will be inferred from the file extension."""1974119742  display_name: Optional[str]19743  """Optional display name of the file."""197441974519746UploadFileConfigOrDict = Union[UploadFileConfig, UploadFileConfigDict]197471974819749class DownloadFileConfig(_common.BaseModel):19750  """Used to override the default configuration."""1975119752  http_options: Optional[HttpOptions] = Field(19753      default=None, description="""Used to override HTTP request options."""19754  )197551975619757class DownloadFileConfigDict(TypedDict, total=False):19758  """Used to override the default configuration."""1975919760  http_options: Optional[HttpOptionsDict]19761  """Used to override HTTP request options."""197621976319764DownloadFileConfigOrDict = Union[DownloadFileConfig, DownloadFileConfigDict]197651976619767class UpscaleImageConfig(_common.BaseModel):19768  """Configuration for upscaling an image.1976919770  For more information on this configuration, refer to19771  the `Imagen API reference documentation19772  <https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api>`_.19773  """1977419775  http_options: Optional[HttpOptions] = Field(19776      default=None, description="""Used to override HTTP request options."""19777  )19778  output_gcs_uri: Optional[str] = Field(19779      default=None,19780      description="""Cloud Storage URI used to store the generated images.""",19781  )19782  safety_filter_level: Optional[SafetyFilterLevel] = Field(19783      default=None, description="""Filter level for safety filtering."""19784  )19785  person_generation: Optional[PersonGeneration] = Field(19786      default=None, description="""Allows generation of people by the model."""19787  )19788  include_rai_reason: Optional[bool] = Field(19789      default=None,19790      description="""Whether to include a reason for filtered-out images in the19791      response.""",19792  )19793  output_mime_type: Optional[str] = Field(19794      default=None,19795      description="""The image format that the output should be saved as.""",19796  )19797  output_compression_quality: Optional[int] = Field(19798      default=None,19799      description="""The level of compression. Only applicable if the19800      ``output_mime_type`` is ``image/jpeg``.""",19801  )19802  enhance_input_image: Optional[bool] = Field(19803      default=None,19804      description="""Whether to add an image enhancing step before upscaling.19805      It is expected to suppress the noise and JPEG compression artifacts19806      from the input image.""",19807  )19808  image_preservation_factor: Optional[float] = Field(19809      default=None,19810      description="""With a higher image preservation factor, the original image19811      pixels are more respected. With a lower image preservation factor, the19812      output image will have be more different from the input image, but19813      with finer details and less noise.""",19814  )19815  labels: Optional[dict[str, str]] = Field(19816      default=None,19817      description="""User specified labels to track billing usage.""",19818  )198191982019821class UpscaleImageConfigDict(TypedDict, total=False):19822  """Configuration for upscaling an image.1982319824  For more information on this configuration, refer to19825  the `Imagen API reference documentation19826  <https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api>`_.19827  """1982819829  http_options: Optional[HttpOptionsDict]19830  """Used to override HTTP request options."""1983119832  output_gcs_uri: Optional[str]19833  """Cloud Storage URI used to store the generated images."""1983419835  safety_filter_level: Optional[SafetyFilterLevel]19836  """Filter level for safety filtering."""1983719838  person_generation: Optional[PersonGeneration]19839  """Allows generation of people by the model."""1984019841  include_rai_reason: Optional[bool]19842  """Whether to include a reason for filtered-out images in the19843      response."""1984419845  output_mime_type: Optional[str]19846  """The image format that the output should be saved as."""1984719848  output_compression_quality: Optional[int]19849  """The level of compression. Only applicable if the19850      ``output_mime_type`` is ``image/jpeg``."""1985119852  enhance_input_image: Optional[bool]19853  """Whether to add an image enhancing step before upscaling.19854      It is expected to suppress the noise and JPEG compression artifacts19855      from the input image."""1985619857  image_preservation_factor: Optional[float]19858  """With a higher image preservation factor, the original image19859      pixels are more respected. With a lower image preservation factor, the19860      output image will have be more different from the input image, but19861      with finer details and less noise."""1986219863  labels: Optional[dict[str, str]]19864  """User specified labels to track billing usage."""198651986619867UpscaleImageConfigOrDict = Union[UpscaleImageConfig, UpscaleImageConfigDict]198681986919870class UpscaleImageParameters(_common.BaseModel):19871  """User-facing config UpscaleImageParameters."""1987219873  model: Optional[str] = Field(19874      default=None, description="""The model to use."""19875  )19876  image: Optional[Image] = Field(19877      default=None, description="""The input image to upscale."""19878  )19879  upscale_factor: Optional[str] = Field(19880      default=None,19881      description="""The factor to upscale the image (x2 or x4).""",19882  )19883  config: Optional[UpscaleImageConfig] = Field(19884      default=None, description="""Configuration for upscaling."""19885  )198861988719888class UpscaleImageParametersDict(TypedDict, total=False):19889  """User-facing config UpscaleImageParameters."""1989019891  model: Optional[str]19892  """The model to use."""1989319894  image: Optional[ImageDict]19895  """The input image to upscale."""1989619897  upscale_factor: Optional[str]19898  """The factor to upscale the image (x2 or x4)."""1989919900  config: Optional[UpscaleImageConfigDict]19901  """Configuration for upscaling."""199021990319904UpscaleImageParametersOrDict = Union[19905    UpscaleImageParameters, UpscaleImageParametersDict19906]199071990819909class RawReferenceImage(_common.BaseModel):19910  """A raw reference image.1991119912  A raw reference image represents the base image to edit, provided by the user.19913  It can optionally be provided in addition to a mask reference image or19914  a style reference image.19915  """1991619917  reference_image: Optional[Image] = Field(19918      default=None,19919      description="""The reference image for the editing operation.""",19920  )19921  reference_id: Optional[int] = Field(19922      default=None, description="""The id of the reference image."""19923  )19924  reference_type: Optional[str] = Field(19925      default=None,19926      description="""The type of the reference image. Only set by the SDK.""",19927  )1992819929  @pydantic.model_validator(mode='before')19930  @classmethod19931  def _validate_mask_image_config(self, values: Any) -> Any:19932    if 'reference_type' in values:19933      raise ValueError('Cannot set internal reference_type field directly.')19934    values['reference_type'] = 'REFERENCE_TYPE_RAW'19935    return values199361993719938class RawReferenceImageDict(TypedDict, total=False):19939  """A raw reference image.1994019941  A raw reference image represents the base image to edit, provided by the user.19942  It can optionally be provided in addition to a mask reference image or19943  a style reference image.19944  """1994519946  reference_image: Optional[ImageDict]19947  """The reference image for the editing operation."""1994819949  reference_id: Optional[int]19950  """The id of the reference image."""1995119952  reference_type: Optional[str]19953  """The type of the reference image. Only set by the SDK."""199541995519956RawReferenceImageOrDict = Union[RawReferenceImage, RawReferenceImageDict]199571995819959class MaskReferenceImage(_common.BaseModel):19960  """A mask reference image.1996119962  This encapsulates either a mask image provided by the user and configs for19963  the user provided mask, or only config parameters for the model to generate19964  a mask.1996519966  A mask image is an image whose non-zero values indicate where to edit the base19967  image. If the user provides a mask image, the mask must be in the same19968  dimensions as the raw image.19969  """1997019971  reference_image: Optional[Image] = Field(19972      default=None,19973      description="""The reference image for the editing operation.""",19974  )19975  reference_id: Optional[int] = Field(19976      default=None, description="""The id of the reference image."""19977  )19978  reference_type: Optional[str] = Field(19979      default=None,19980      description="""The type of the reference image. Only set by the SDK.""",19981  )19982  config: Optional[MaskReferenceConfig] = Field(19983      default=None,19984      description="""Configuration for the mask reference image.""",19985  )19986  """Re-map config to mask_reference_config to send to API."""19987  mask_image_config: Optional['MaskReferenceConfig'] = Field(19988      default=None, description=""""""19989  )1999019991  @pydantic.model_validator(mode='before')19992  @classmethod19993  def _validate_mask_image_config(self, values: Any) -> Any:19994    config = values.get('config', None)19995    values['mask_image_config'] = config19996    if 'reference_type' in values:19997      raise ValueError('Cannot set internal reference_type field directly.')19998    values['reference_type'] = 'REFERENCE_TYPE_MASK'19999    return values200002000120002class MaskReferenceImageDict(TypedDict, total=False):20003  """A mask reference image.2000420005  This encapsulates either a mask image provided by the user and configs for20006  the user provided mask, or only config parameters for the model to generate20007  a mask.2000820009  A mask image is an image whose non-zero values indicate where to edit the base20010  image. If the user provides a mask image, the mask must be in the same20011  dimensions as the raw image.20012  """2001320014  reference_image: Optional[ImageDict]20015  """The reference image for the editing operation."""2001620017  reference_id: Optional[int]20018  """The id of the reference image."""2001920020  reference_type: Optional[str]20021  """The type of the reference image. Only set by the SDK."""2002220023  config: Optional[MaskReferenceConfigDict]20024  """Configuration for the mask reference image."""200252002620027MaskReferenceImageOrDict = Union[MaskReferenceImage, MaskReferenceImageDict]200282002920030class ControlReferenceImage(_common.BaseModel):20031  """A control reference image.2003220033  The image of the control reference image is either a control image provided20034  by the user, or a regular image which the backend will use to generate a20035  control image of. In the case of the latter, the20036  enable_control_image_computation field in the config should be set to True.2003720038  A control image is an image that represents a sketch image of areas for the20039  model to fill in based on the prompt.20040  """2004120042  reference_image: Optional[Image] = Field(20043      default=None,20044      description="""The reference image for the editing operation.""",20045  )20046  reference_id: Optional[int] = Field(20047      default=None, description="""The id of the reference image."""20048  )20049  reference_type: Optional[str] = Field(20050      default=None,20051      description="""The type of the reference image. Only set by the SDK.""",20052  )20053  config: Optional[ControlReferenceConfig] = Field(20054      default=None,20055      description="""Configuration for the control reference image.""",20056  )20057  """Re-map config to control_reference_config to send to API."""20058  control_image_config: Optional['ControlReferenceConfig'] = Field(20059      default=None, description=""""""20060  )2006120062  @pydantic.model_validator(mode='before')20063  @classmethod20064  def _validate_mask_image_config(self, values: Any) -> Any:20065    config = values.get('config', None)20066    values['control_image_config'] = config20067    if 'reference_type' in values:20068      raise ValueError('Cannot set internal reference_type field directly.')20069    values['reference_type'] = 'REFERENCE_TYPE_CONTROL'20070    return values200712007220073class ControlReferenceImageDict(TypedDict, total=False):20074  """A control reference image.2007520076  The image of the control reference image is either a control image provided20077  by the user, or a regular image which the backend will use to generate a20078  control image of. In the case of the latter, the20079  enable_control_image_computation field in the config should be set to True.2008020081  A control image is an image that represents a sketch image of areas for the20082  model to fill in based on the prompt.20083  """2008420085  reference_image: Optional[ImageDict]20086  """The reference image for the editing operation."""2008720088  reference_id: Optional[int]20089  """The id of the reference image."""2009020091  reference_type: Optional[str]20092  """The type of the reference image. Only set by the SDK."""2009320094  config: Optional[ControlReferenceConfigDict]20095  """Configuration for the control reference image."""200962009720098ControlReferenceImageOrDict = Union[20099    ControlReferenceImage, ControlReferenceImageDict20100]201012010220103class StyleReferenceImage(_common.BaseModel):20104  """A style reference image.2010520106  This encapsulates a style reference image provided by the user, and20107  additionally optional config parameters for the style reference image.2010820109  A raw reference image can also be provided as a destination for the style to20110  be applied to.20111  """2011220113  reference_image: Optional[Image] = Field(20114      default=None,20115      description="""The reference image for the editing operation.""",20116  )20117  reference_id: Optional[int] = Field(20118      default=None, description="""The id of the reference image."""20119  )20120  reference_type: Optional[str] = Field(20121      default=None,20122      description="""The type of the reference image. Only set by the SDK.""",20123  )20124  config: Optional[StyleReferenceConfig] = Field(20125      default=None,20126      description="""Configuration for the style reference image.""",20127  )20128  """Re-map config to style_reference_config to send to API."""20129  style_image_config: Optional['StyleReferenceConfig'] = Field(20130      default=None, description=""""""20131  )2013220133  @pydantic.model_validator(mode='before')20134  @classmethod20135  def _validate_mask_image_config(self, values: Any) -> Any:20136    config = values.get('config', None)20137    values['style_image_config'] = config20138    if 'reference_type' in values:20139      raise ValueError('Cannot set internal reference_type field directly.')20140    values['reference_type'] = 'REFERENCE_TYPE_STYLE'20141    return values201422014320144class StyleReferenceImageDict(TypedDict, total=False):20145  """A style reference image.2014620147  This encapsulates a style reference image provided by the user, and20148  additionally optional config parameters for the style reference image.2014920150  A raw reference image can also be provided as a destination for the style to20151  be applied to.20152  """2015320154  reference_image: Optional[ImageDict]20155  """The reference image for the editing operation."""2015620157  reference_id: Optional[int]20158  """The id of the reference image."""2015920160  reference_type: Optional[str]20161  """The type of the reference image. Only set by the SDK."""2016220163  config: Optional[StyleReferenceConfigDict]20164  """Configuration for the style reference image."""201652016620167StyleReferenceImageOrDict = Union[StyleReferenceImage, StyleReferenceImageDict]201682016920170class SubjectReferenceImage(_common.BaseModel):20171  """A subject reference image.2017220173  This encapsulates a subject reference image provided by the user, and20174  additionally optional config parameters for the subject reference image.2017520176  A raw reference image can also be provided as a destination for the subject to20177  be applied to.20178  """2017920180  reference_image: Optional[Image] = Field(20181      default=None,20182      description="""The reference image for the editing operation.""",20183  )20184  reference_id: Optional[int] = Field(20185      default=None, description="""The id of the reference image."""20186  )20187  reference_type: Optional[str] = Field(20188      default=None,20189      description="""The type of the reference image. Only set by the SDK.""",20190  )20191  config: Optional[SubjectReferenceConfig] = Field(20192      default=None,20193      description="""Configuration for the subject reference image.""",20194  )20195  """Re-map config to subject_reference_config to send to API."""20196  subject_image_config: Optional['SubjectReferenceConfig'] = Field(20197      default=None, description=""""""20198  )2019920200  @pydantic.model_validator(mode='before')20201  @classmethod20202  def _validate_mask_image_config(self, values: Any) -> Any:20203    config = values.get('config', None)20204    values['subject_image_config'] = config20205    if 'reference_type' in values:20206      raise ValueError('Cannot set internal reference_type field directly.')20207    values['reference_type'] = 'REFERENCE_TYPE_SUBJECT'20208    return values202092021020211class SubjectReferenceImageDict(TypedDict, total=False):20212  """A subject reference image.2021320214  This encapsulates a subject reference image provided by the user, and20215  additionally optional config parameters for the subject reference image.2021620217  A raw reference image can also be provided as a destination for the subject to20218  be applied to.20219  """2022020221  reference_image: Optional[ImageDict]20222  """The reference image for the editing operation."""2022320224  reference_id: Optional[int]20225  """The id of the reference image."""2022620227  reference_type: Optional[str]20228  """The type of the reference image. Only set by the SDK."""2022920230  config: Optional[SubjectReferenceConfigDict]20231  """Configuration for the subject reference image."""202322023320234SubjectReferenceImageOrDict = Union[20235    SubjectReferenceImage, SubjectReferenceImageDict20236]202372023820239class ContentReferenceImage(_common.BaseModel):20240  """A content reference image.2024120242  A content reference image represents a subject to reference (ex. person,20243  product, animal) provided by the user. It can optionally be provided in20244  addition to a style reference image (ex. background, style reference).20245  """2024620247  reference_image: Optional[Image] = Field(20248      default=None,20249      description="""The reference image for the editing operation.""",20250  )20251  reference_id: Optional[int] = Field(20252      default=None, description="""The id of the reference image."""20253  )20254  reference_type: Optional[str] = Field(20255      default=None,20256      description="""The type of the reference image. Only set by the SDK.""",20257  )2025820259  @pydantic.model_validator(mode='before')20260  @classmethod20261  def _validate_mask_image_config(self, values: Any) -> Any:20262    if 'reference_type' in values:20263      raise ValueError('Cannot set internal reference_type field directly.')20264    values['reference_type'] = 'REFERENCE_TYPE_CONTENT'20265    return values202662026720268class ContentReferenceImageDict(TypedDict, total=False):20269  """A content reference image.2027020271  A content reference image represents a subject to reference (ex. person,20272  product, animal) provided by the user. It can optionally be provided in20273  addition to a style reference image (ex. background, style reference).20274  """2027520276  reference_image: Optional[ImageDict]20277  """The reference image for the editing operation."""2027820279  reference_id: Optional[int]20280  """The id of the reference image."""2028120282  reference_type: Optional[str]20283  """The type of the reference image. Only set by the SDK."""202842028520286ContentReferenceImageOrDict = Union[20287    ContentReferenceImage, ContentReferenceImageDict20288]202892029020291class LiveServerSetupComplete(_common.BaseModel):20292  """Sent in response to a `LiveGenerateContentSetup` message from the client."""2029320294  session_id: Optional[str] = Field(20295      default=None, description="""The session id of the live session."""20296  )20297  voice_consent_signature: Optional[VoiceConsentSignature] = Field(20298      default=None,20299      description="""Signature of the verified consent audio. This is populated when the20300      request has a ReplicatedVoiceConfig with consent_audio set, if the consent20301      verification was successful. This may be used in a subsequent request20302      instead of the consent_audio to verify the same consent.""",20303  )203042030520306class LiveServerSetupCompleteDict(TypedDict, total=False):20307  """Sent in response to a `LiveGenerateContentSetup` message from the client."""2030820309  session_id: Optional[str]20310  """The session id of the live session."""2031120312  voice_consent_signature: Optional[VoiceConsentSignatureDict]20313  """Signature of the verified consent audio. This is populated when the20314      request has a ReplicatedVoiceConfig with consent_audio set, if the consent20315      verification was successful. This may be used in a subsequent request20316      instead of the consent_audio to verify the same consent."""203172031820319LiveServerSetupCompleteOrDict = Union[20320    LiveServerSetupComplete, LiveServerSetupCompleteDict20321]203222032320324class LiveServerContent(_common.BaseModel):20325  """Incremental server update generated by the model in response to client messages.2032620327  Content is generated as quickly as possible, and not in real time. Clients20328  may choose to buffer and play it out in real time.20329  """2033020331  model_turn: Optional[Content] = Field(20332      default=None,20333      description="""The content that the model has generated as part of the current conversation with the user.""",20334  )20335  turn_complete: Optional[bool] = Field(20336      default=None,20337      description="""If true, indicates that the model is done generating. Generation will only start in response to additional client messages. Can be set alongside `content`, indicating that the `content` is the last in the turn.""",20338  )20339  interrupted: Optional[bool] = Field(20340      default=None,20341      description="""If true, indicates that a client message has interrupted current model generation. If the client is playing out the content in realtime, this is a good signal to stop and empty the current queue.""",20342  )20343  grounding_metadata: Optional[GroundingMetadata] = Field(20344      default=None,20345      description="""Metadata returned to client when grounding is enabled.""",20346  )20347  generation_complete: Optional[bool] = Field(20348      default=None,20349      description="""If true, indicates that the model is done generating. When model is20350      interrupted while generating there will be no generation_complete message20351      in interrupted turn, it will go through interrupted > turn_complete.20352      When model assumes realtime playback there will be delay between20353      generation_complete and turn_complete that is caused by model20354      waiting for playback to finish. If true, indicates that the model20355      has finished generating all content. This is a signal to the client20356      that it can stop sending messages.""",20357  )20358  input_transcription: Optional[Transcription] = Field(20359      default=None,20360      description="""Input transcription. The transcription is independent to the model20361      turn which means it doesn’t imply any ordering between transcription and20362      model turn.""",20363  )20364  output_transcription: Optional[Transcription] = Field(20365      default=None,20366      description="""Output transcription. The transcription is independent to the model20367      turn which means it doesn’t imply any ordering between transcription and20368      model turn.20369      """,20370  )20371  url_context_metadata: Optional[UrlContextMetadata] = Field(20372      default=None,20373      description="""Metadata related to url context retrieval tool.""",20374  )20375  turn_complete_reason: Optional[TurnCompleteReason] = Field(20376      default=None, description="""Reason for the turn is complete."""20377  )20378  waiting_for_input: Optional[bool] = Field(20379      default=None,20380      description="""If true, indicates that the model is not generating content because20381      it is waiting for more input from the user, e.g. because it expects the20382      user to continue talking.""",20383  )20384  interim_input_transcription: Optional[Transcription] = Field(20385      default=None,20386      description="""Low latency transcription updated while the user is speaking.""",20387  )20388  interaction_status: Optional[InteractionStatus] = Field(20389      default=None,20390      description="""The current activity status of the live session. Always sent alongside `turn_complete`.""",20391  )203922039320394class LiveServerContentDict(TypedDict, total=False):20395  """Incremental server update generated by the model in response to client messages.2039620397  Content is generated as quickly as possible, and not in real time. Clients20398  may choose to buffer and play it out in real time.20399  """2040020401  model_turn: Optional[ContentDict]20402  """The content that the model has generated as part of the current conversation with the user."""2040320404  turn_complete: Optional[bool]20405  """If true, indicates that the model is done generating. Generation will only start in response to additional client messages. Can be set alongside `content`, indicating that the `content` is the last in the turn."""2040620407  interrupted: Optional[bool]20408  """If true, indicates that a client message has interrupted current model generation. If the client is playing out the content in realtime, this is a good signal to stop and empty the current queue."""2040920410  grounding_metadata: Optional[GroundingMetadataDict]20411  """Metadata returned to client when grounding is enabled."""2041220413  generation_complete: Optional[bool]20414  """If true, indicates that the model is done generating. When model is20415      interrupted while generating there will be no generation_complete message20416      in interrupted turn, it will go through interrupted > turn_complete.20417      When model assumes realtime playback there will be delay between20418      generation_complete and turn_complete that is caused by model20419      waiting for playback to finish. If true, indicates that the model20420      has finished generating all content. This is a signal to the client20421      that it can stop sending messages."""2042220423  input_transcription: Optional[TranscriptionDict]20424  """Input transcription. The transcription is independent to the model20425      turn which means it doesn’t imply any ordering between transcription and20426      model turn."""2042720428  output_transcription: Optional[TranscriptionDict]20429  """Output transcription. The transcription is independent to the model20430      turn which means it doesn’t imply any ordering between transcription and20431      model turn.20432      """2043320434  url_context_metadata: Optional[UrlContextMetadataDict]20435  """Metadata related to url context retrieval tool."""2043620437  turn_complete_reason: Optional[TurnCompleteReason]20438  """Reason for the turn is complete."""2043920440  waiting_for_input: Optional[bool]20441  """If true, indicates that the model is not generating content because20442      it is waiting for more input from the user, e.g. because it expects the20443      user to continue talking."""2044420445  interim_input_transcription: Optional[TranscriptionDict]20446  """Low latency transcription updated while the user is speaking."""2044720448  interaction_status: Optional[InteractionStatus]20449  """The current activity status of the live session. Always sent alongside `turn_complete`."""204502045120452LiveServerContentOrDict = Union[LiveServerContent, LiveServerContentDict]204532045420455class LiveServerToolCall(_common.BaseModel):20456  """Request for the client to execute the `function_calls` and return the responses with the matching `id`s."""2045720458  function_calls: Optional[list[FunctionCall]] = Field(20459      default=None, description="""The function call to be executed."""20460  )204612046220463class LiveServerToolCallDict(TypedDict, total=False):20464  """Request for the client to execute the `function_calls` and return the responses with the matching `id`s."""2046520466  function_calls: Optional[list[FunctionCallDict]]20467  """The function call to be executed."""204682046920470LiveServerToolCallOrDict = Union[LiveServerToolCall, LiveServerToolCallDict]204712047220473class LiveServerToolCallCancellation(_common.BaseModel):20474  """Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should have been not executed and should be cancelled.2047520476  If there were side-effects to those tool calls, clients may attempt to undo20477  the tool calls. This message occurs only in cases where the clients interrupt20478  server turns.20479  """2048020481  ids: Optional[list[str]] = Field(20482      default=None, description="""The ids of the tool calls to be cancelled."""20483  )204842048520486class LiveServerToolCallCancellationDict(TypedDict, total=False):20487  """Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should have been not executed and should be cancelled.2048820489  If there were side-effects to those tool calls, clients may attempt to undo20490  the tool calls. This message occurs only in cases where the clients interrupt20491  server turns.20492  """2049320494  ids: Optional[list[str]]20495  """The ids of the tool calls to be cancelled."""204962049720498LiveServerToolCallCancellationOrDict = Union[20499    LiveServerToolCallCancellation, LiveServerToolCallCancellationDict20500]205012050220503class UsageMetadata(_common.BaseModel):20504  """Usage metadata about response(s)."""2050520506  prompt_token_count: Optional[int] = Field(20507      default=None,20508      description="""The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When `cached_content` is set, this also includes the number of tokens in the cached content.""",20509  )20510  cached_content_token_count: Optional[int] = Field(20511      default=None,20512      description="""Output only. The number of tokens in the cached content that was used for this request.""",20513  )20514  response_token_count: Optional[int] = Field(20515      default=None,20516      description="""Total number of tokens across all the generated response candidates.""",20517  )20518  tool_use_prompt_token_count: Optional[int] = Field(20519      default=None,20520      description="""Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable.""",20521  )20522  thoughts_token_count: Optional[int] = Field(20523      default=None,20524      description="""Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable.""",20525  )20526  total_token_count: Optional[int] = Field(20527      default=None,20528      description="""The total number of tokens for the entire request. This is the sum of `prompt_token_count`, `candidates_token_count`, `tool_use_prompt_token_count`, and `thoughts_token_count`.""",20529  )20530  prompt_tokens_details: Optional[list[ModalityTokenCount]] = Field(20531      default=None,20532      description="""Output only. A detailed breakdown of the token count for each modality in the prompt.""",20533  )20534  cache_tokens_details: Optional[list[ModalityTokenCount]] = Field(20535      default=None,20536      description="""Output only. A detailed breakdown of the token count for each modality in the cached content.""",20537  )20538  response_tokens_details: Optional[list[ModalityTokenCount]] = Field(20539      default=None,20540      description="""List of modalities that were returned in the response.""",20541  )20542  tool_use_prompt_tokens_details: Optional[list[ModalityTokenCount]] = Field(20543      default=None,20544      description="""Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input.""",20545  )20546  traffic_type: Optional[TrafficType] = Field(20547      default=None,20548      description="""Output only. The traffic type for this request. This field is not supported in Gemini API.""",20549  )20550  service_tier: Optional[ServiceTier] = Field(20551      default=None,20552      description="""Output only. Service tier of the request. This field is not supported in Vertex AI.""",20553  )205542055520556class UsageMetadataDict(TypedDict, total=False):20557  """Usage metadata about response(s)."""2055820559  prompt_token_count: Optional[int]20560  """The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When `cached_content` is set, this also includes the number of tokens in the cached content."""2056120562  cached_content_token_count: Optional[int]20563  """Output only. The number of tokens in the cached content that was used for this request."""2056420565  response_token_count: Optional[int]20566  """Total number of tokens across all the generated response candidates."""2056720568  tool_use_prompt_token_count: Optional[int]20569  """Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable."""2057020571  thoughts_token_count: Optional[int]20572  """Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable."""2057320574  total_token_count: Optional[int]20575  """The total number of tokens for the entire request. This is the sum of `prompt_token_count`, `candidates_token_count`, `tool_use_prompt_token_count`, and `thoughts_token_count`."""2057620577  prompt_tokens_details: Optional[list[ModalityTokenCountDict]]20578  """Output only. A detailed breakdown of the token count for each modality in the prompt."""2057920580  cache_tokens_details: Optional[list[ModalityTokenCountDict]]20581  """Output only. A detailed breakdown of the token count for each modality in the cached content."""2058220583  response_tokens_details: Optional[list[ModalityTokenCountDict]]20584  """List of modalities that were returned in the response."""2058520586  tool_use_prompt_tokens_details: Optional[list[ModalityTokenCountDict]]20587  """Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input."""2058820589  traffic_type: Optional[TrafficType]20590  """Output only. The traffic type for this request. This field is not supported in Gemini API."""2059120592  service_tier: Optional[ServiceTier]20593  """Output only. Service tier of the request. This field is not supported in Vertex AI."""205942059520596UsageMetadataOrDict = Union[UsageMetadata, UsageMetadataDict]205972059820599class LiveServerGoAway(_common.BaseModel):20600  """Server will not be able to service client soon."""2060120602  time_left: Optional[str] = Field(20603      default=None,20604      description="""The remaining time before the connection will be terminated as ABORTED. The minimal time returned here is specified differently together with the rate limits for a given model.""",20605  )206062060720608class LiveServerGoAwayDict(TypedDict, total=False):20609  """Server will not be able to service client soon."""2061020611  time_left: Optional[str]20612  """The remaining time before the connection will be terminated as ABORTED. The minimal time returned here is specified differently together with the rate limits for a given model."""206132061420615LiveServerGoAwayOrDict = Union[LiveServerGoAway, LiveServerGoAwayDict]206162061720618class LiveServerSessionResumptionUpdate(_common.BaseModel):20619  """Update of the session resumption state.2062020621  Only sent if `session_resumption` was set in the connection config.20622  """2062320624  new_handle: Optional[str] = Field(20625      default=None,20626      description="""New handle that represents state that can be resumed. Empty if `resumable`=false.""",20627  )20628  resumable: Optional[bool] = Field(20629      default=None,20630      description="""True if session can be resumed at this point. It might be not possible to resume session at some points. In that case we send update empty new_handle and resumable=false. Example of such case could be model executing function calls or just generating. Resuming session (using previous session token) in such state will result in some data loss.""",20631  )20632  last_consumed_client_message_index: Optional[int] = Field(20633      default=None,20634      description="""Index of last message sent by client that is included in state represented by this SessionResumptionToken. Only sent when `SessionResumptionConfig.transparent` is set.2063520636Presence of this index allows users to transparently reconnect and avoid issue of losing some part of realtime audio input/video. If client wishes to temporarily disconnect (for example as result of receiving GoAway) they can do it without losing state by buffering messages sent since last `SessionResumptionTokenUpdate`. This field will enable them to limit buffering (avoid keeping all requests in RAM).2063720638Note: This should not be used for when resuming a session at some time later -- in those cases partial audio and video frames are likely not needed.""",20639  )206402064120642class LiveServerSessionResumptionUpdateDict(TypedDict, total=False):20643  """Update of the session resumption state.2064420645  Only sent if `session_resumption` was set in the connection config.20646  """2064720648  new_handle: Optional[str]20649  """New handle that represents state that can be resumed. Empty if `resumable`=false."""2065020651  resumable: Optional[bool]20652  """True if session can be resumed at this point. It might be not possible to resume session at some points. In that case we send update empty new_handle and resumable=false. Example of such case could be model executing function calls or just generating. Resuming session (using previous session token) in such state will result in some data loss."""2065320654  last_consumed_client_message_index: Optional[int]20655  """Index of last message sent by client that is included in state represented by this SessionResumptionToken. Only sent when `SessionResumptionConfig.transparent` is set.2065620657Presence of this index allows users to transparently reconnect and avoid issue of losing some part of realtime audio input/video. If client wishes to temporarily disconnect (for example as result of receiving GoAway) they can do it without losing state by buffering messages sent since last `SessionResumptionTokenUpdate`. This field will enable them to limit buffering (avoid keeping all requests in RAM).2065820659Note: This should not be used for when resuming a session at some time later -- in those cases partial audio and video frames are likely not needed."""206602066120662LiveServerSessionResumptionUpdateOrDict = Union[20663    LiveServerSessionResumptionUpdate, LiveServerSessionResumptionUpdateDict20664]206652066620667class VoiceActivityDetectionSignal(_common.BaseModel):2066820669  vad_signal_type: Optional[VadSignalType] = Field(20670      default=None, description="""The type of the VAD signal."""20671  )206722067320674class VoiceActivityDetectionSignalDict(TypedDict, total=False):2067520676  vad_signal_type: Optional[VadSignalType]20677  """The type of the VAD signal."""206782067920680VoiceActivityDetectionSignalOrDict = Union[20681    VoiceActivityDetectionSignal, VoiceActivityDetectionSignalDict20682]206832068420685class VoiceActivity(_common.BaseModel):20686  """Voice activity signal."""2068720688  voice_activity_type: Optional[VoiceActivityType] = Field(20689      default=None, description="""The type of the voice activity signal."""20690  )20691  audio_offset: Optional[str] = Field(20692      default=None,20693      description="""The time voice activity detected in audio time, relative to the start of the audio stream.""",20694  )206952069620697class VoiceActivityDict(TypedDict, total=False):20698  """Voice activity signal."""2069920700  voice_activity_type: Optional[VoiceActivityType]20701  """The type of the voice activity signal."""2070220703  audio_offset: Optional[str]20704  """The time voice activity detected in audio time, relative to the start of the audio stream."""207052070620707VoiceActivityOrDict = Union[VoiceActivity, VoiceActivityDict]207082070920710class LiveServerMessage(_common.BaseModel):20711  """Response message for API call."""2071220713  setup_complete: Optional[LiveServerSetupComplete] = Field(20714      default=None,20715      description="""Sent in response to a `LiveClientSetup` message from the client.""",20716  )20717  server_content: Optional[LiveServerContent] = Field(20718      default=None,20719      description="""Content generated by the model in response to client messages.""",20720  )20721  tool_call: Optional[LiveServerToolCall] = Field(20722      default=None,20723      description="""Request for the client to execute the `function_calls` and return the responses with the matching `id`s.""",20724  )20725  tool_call_cancellation: Optional[LiveServerToolCallCancellation] = Field(20726      default=None,20727      description="""Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should have been not executed and should be cancelled.""",20728  )20729  usage_metadata: Optional[UsageMetadata] = Field(20730      default=None, description="""Usage metadata about model response(s)."""20731  )20732  go_away: Optional[LiveServerGoAway] = Field(20733      default=None, description="""Server will disconnect soon."""20734  )20735  session_resumption_update: Optional[LiveServerSessionResumptionUpdate] = (20736      Field(20737          default=None,20738          description="""Update of the session resumption state.""",20739      )20740  )20741  voice_activity_detection_signal: Optional[VoiceActivityDetectionSignal] = (20742      Field(20743          default=None,20744          description="""Voice activity detection signal. Allowlisted only.""",20745      )20746  )20747  voice_activity: Optional[VoiceActivity] = Field(20748      default=None, description="""Voice activity signal."""20749  )2075020751  @property20752  def text(self) -> Optional[str]:20753    """Returns the concatenation of all text parts in the response.2075420755    If there are non-text parts in the response, only the concatenated text20756    result from text parts will be returned.20757    """20758    if (20759        not self.server_content20760        or not self.server_content20761        or not self.server_content.model_turn20762        or not self.server_content.model_turn.parts20763    ):20764      return None20765    text = ''20766    non_text_parts = []20767    for part in self.server_content.model_turn.parts:20768      for field_name, field_value in part.model_dump(20769          exclude={'text', 'thought'}20770      ).items():20771        if field_value is not None:20772          non_text_parts.append(field_name)20773      if isinstance(part.text, str):20774        if isinstance(part.thought, bool) and part.thought:20775          continue20776        text += part.text20777    global _live_server_text_warning_logged20778    if non_text_parts and not _live_server_text_warning_logged:20779      logger.warning(20780          'Warning: there are non-text parts in the response:'20781          f' {non_text_parts}, returning concatenated text result from text'20782          ' parts, check out the non text parts for full response from model.'20783      )20784      _live_server_text_warning_logged = True20785    return text if text else None2078620787  @property20788  def data(self) -> Optional[bytes]:20789    """Returns the concatenation of all inline data parts in the response.2079020791    If there are non-data parts in the response, only the concatenated data20792    result from the data parts will be returned.20793    """20794    if (20795        not self.server_content20796        or not self.server_content20797        or not self.server_content.model_turn20798        or not self.server_content.model_turn.parts20799    ):20800      return None20801    concatenated_data = b''20802    non_data_parts = []20803    for part in self.server_content.model_turn.parts:20804      for field_name, field_value in part.model_dump(20805          exclude={'inline_data'}20806      ).items():20807        if field_value is not None:20808          non_data_parts.append(field_name)20809      if part.inline_data and isinstance(part.inline_data.data, bytes):20810        concatenated_data += part.inline_data.data20811    global _live_server_data_warning_logged20812    if non_data_parts and not _live_server_data_warning_logged:20813      logger.warning(20814          'Warning: there are non-data parts in the response:'20815          f' {non_data_parts}, returning concatenated data result from data'20816          ' parts, check out the non data parts for full response from model.'20817      )20818      _live_server_data_warning_logged = True20819    return concatenated_data if len(concatenated_data) > 0 else None208202082120822class LiveServerMessageDict(TypedDict, total=False):20823  """Response message for API call."""2082420825  setup_complete: Optional[LiveServerSetupCompleteDict]20826  """Sent in response to a `LiveClientSetup` message from the client."""2082720828  server_content: Optional[LiveServerContentDict]20829  """Content generated by the model in response to client messages."""2083020831  tool_call: Optional[LiveServerToolCallDict]20832  """Request for the client to execute the `function_calls` and return the responses with the matching `id`s."""2083320834  tool_call_cancellation: Optional[LiveServerToolCallCancellationDict]20835  """Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should have been not executed and should be cancelled."""2083620837  usage_metadata: Optional[UsageMetadataDict]20838  """Usage metadata about model response(s)."""2083920840  go_away: Optional[LiveServerGoAwayDict]20841  """Server will disconnect soon."""2084220843  session_resumption_update: Optional[LiveServerSessionResumptionUpdateDict]20844  """Update of the session resumption state."""2084520846  voice_activity_detection_signal: Optional[VoiceActivityDetectionSignalDict]20847  """Voice activity detection signal. Allowlisted only."""2084820849  voice_activity: Optional[VoiceActivityDict]20850  """Voice activity signal."""208512085220853LiveServerMessageOrDict = Union[LiveServerMessage, LiveServerMessageDict]208542085520856class SessionResumptionConfig(_common.BaseModel):20857  """Configuration of session resumption mechanism.2085820859  Included in `LiveConnectConfig.session_resumption`. If included server20860  will send `LiveServerSessionResumptionUpdate` messages.20861  """2086220863  handle: Optional[str] = Field(20864      default=None,20865      description="""Session resumption handle of previous session (session to restore).2086620867If not present new session will be started.""",20868  )20869  transparent: Optional[bool] = Field(20870      default=None,20871      description="""If set the server will send `last_consumed_client_message_index` in the `session_resumption_update` messages to allow for transparent reconnections.""",20872  )208732087420875class SessionResumptionConfigDict(TypedDict, total=False):20876  """Configuration of session resumption mechanism.2087720878  Included in `LiveConnectConfig.session_resumption`. If included server20879  will send `LiveServerSessionResumptionUpdate` messages.20880  """2088120882  handle: Optional[str]20883  """Session resumption handle of previous session (session to restore).2088420885If not present new session will be started."""2088620887  transparent: Optional[bool]20888  """If set the server will send `last_consumed_client_message_index` in the `session_resumption_update` messages to allow for transparent reconnections."""208892089020891SessionResumptionConfigOrDict = Union[20892    SessionResumptionConfig, SessionResumptionConfigDict20893]208942089520896class SlidingWindow(_common.BaseModel):20897  """Context window will be truncated by keeping only suffix of it.2089820899  Context window will always be cut at start of USER role turn. System20900  instructions and `BidiGenerateContentSetup.prefix_turns` will not be20901  subject to the sliding window mechanism, they will always stay at the20902  beginning of context window.20903  """2090420905  target_tokens: Optional[int] = Field(20906      default=None,20907      description="""Session reduction target -- how many tokens we should keep. Window shortening operation has some latency costs, so we should avoid running it on every turn. Should be < trigger_tokens. If not set, trigger_tokens/2 is assumed.""",20908  )209092091020911class SlidingWindowDict(TypedDict, total=False):20912  """Context window will be truncated by keeping only suffix of it.2091320914  Context window will always be cut at start of USER role turn. System20915  instructions and `BidiGenerateContentSetup.prefix_turns` will not be20916  subject to the sliding window mechanism, they will always stay at the20917  beginning of context window.20918  """2091920920  target_tokens: Optional[int]20921  """Session reduction target -- how many tokens we should keep. Window shortening operation has some latency costs, so we should avoid running it on every turn. Should be < trigger_tokens. If not set, trigger_tokens/2 is assumed."""209222092320924SlidingWindowOrDict = Union[SlidingWindow, SlidingWindowDict]209252092620927class ContextWindowCompressionConfig(_common.BaseModel):20928  """Enables context window compression -- mechanism managing model context window so it does not exceed given length."""2092920930  trigger_tokens: Optional[int] = Field(20931      default=None,20932      description="""Number of tokens (before running turn) that triggers context window compression mechanism.""",20933  )20934  sliding_window: Optional[SlidingWindow] = Field(20935      default=None, description="""Sliding window compression mechanism."""20936  )209372093820939class ContextWindowCompressionConfigDict(TypedDict, total=False):20940  """Enables context window compression -- mechanism managing model context window so it does not exceed given length."""2094120942  trigger_tokens: Optional[int]20943  """Number of tokens (before running turn) that triggers context window compression mechanism."""2094420945  sliding_window: Optional[SlidingWindowDict]20946  """Sliding window compression mechanism."""209472094820949ContextWindowCompressionConfigOrDict = Union[20950    ContextWindowCompressionConfig, ContextWindowCompressionConfigDict20951]209522095320954class ProactivityConfig(_common.BaseModel):20955  """Config for proactivity features."""2095620957  proactive_audio: Optional[bool] = Field(20958      default=None,20959      description="""If enabled, the model can reject responding to the last prompt. For20960        example, this allows the model to ignore out of context speech or to stay20961        silent if the user did not make a request, yet.""",20962  )209632096420965class ProactivityConfigDict(TypedDict, total=False):20966  """Config for proactivity features."""2096720968  proactive_audio: Optional[bool]20969  """If enabled, the model can reject responding to the last prompt. For20970        example, this allows the model to ignore out of context speech or to stay20971        silent if the user did not make a request, yet."""209722097320974ProactivityConfigOrDict = Union[ProactivityConfig, ProactivityConfigDict]209752097620977class HistoryConfig(_common.BaseModel):20978  """Configuration for history exchange between client and server."""2097920980  initial_history_in_client_content: Optional[bool] = Field(20981      default=None,20982      description="""If true, after sending `setup_complete`, the server will wait20983      and at first process `client_content` messages until `turn_complete` is20984      `true`. This initial history will not trigger a model call and20985      may end with model content. After `turn_complete` is `true`, the client20986      can start the realtime conversation via `realtime_input`.""",20987  )209882098920990class HistoryConfigDict(TypedDict, total=False):20991  """Configuration for history exchange between client and server."""2099220993  initial_history_in_client_content: Optional[bool]20994  """If true, after sending `setup_complete`, the server will wait20995      and at first process `client_content` messages until `turn_complete` is20996      `true`. This initial history will not trigger a model call and20997      may end with model content. After `turn_complete` is `true`, the client20998      can start the realtime conversation via `realtime_input`."""209992100021001HistoryConfigOrDict = Union[HistoryConfig, HistoryConfigDict]210022100321004class CustomizedAvatar(_common.BaseModel):21005  """Configures the customized avatar to be used in the session."""2100621007  image_mime_type: Optional[str] = Field(21008      default=None,21009      description="""The mime type of the reference image, e.g., "image/jpeg".""",21010  )21011  image_data: Optional[bytes] = Field(21012      default=None,21013      description="""The data of the reference image. The dimensions of the reference21014      image should be 9:16 (portrait) with a minimum resolution of 704x1280.""",21015  )210162101721018class CustomizedAvatarDict(TypedDict, total=False):21019  """Configures the customized avatar to be used in the session."""2102021021  image_mime_type: Optional[str]21022  """The mime type of the reference image, e.g., "image/jpeg"."""2102321024  image_data: Optional[bytes]21025  """The data of the reference image. The dimensions of the reference21026      image should be 9:16 (portrait) with a minimum resolution of 704x1280."""210272102821029CustomizedAvatarOrDict = Union[CustomizedAvatar, CustomizedAvatarDict]210302103121032class AvatarConfig(_common.BaseModel):21033  """Configures the avatar to be used in the session."""2103421035  avatar_name: Optional[str] = Field(21036      default=None, description="""Pre-built avatar id."""21037  )21038  customized_avatar: Optional[CustomizedAvatar] = Field(21039      default=None,21040      description="""Customized avatar appearance with a reference image.""",21041  )21042  audio_bitrate_bps: Optional[int] = Field(21043      default=None, description="""The bitrate of compressed audio."""21044  )21045  video_bitrate_bps: Optional[int] = Field(21046      default=None, description="""The bitrate of compressed video output."""21047  )210482104921050class AvatarConfigDict(TypedDict, total=False):21051  """Configures the avatar to be used in the session."""2105221053  avatar_name: Optional[str]21054  """Pre-built avatar id."""2105521056  customized_avatar: Optional[CustomizedAvatarDict]21057  """Customized avatar appearance with a reference image."""2105821059  audio_bitrate_bps: Optional[int]21060  """The bitrate of compressed audio."""2106121062  video_bitrate_bps: Optional[int]21063  """The bitrate of compressed video output."""210642106521066AvatarConfigOrDict = Union[AvatarConfig, AvatarConfigDict]210672106821069class LiveClientSetup(_common.BaseModel):21070  """Message contains configuration that will apply for the duration of the streaming session."""2107121072  model: Optional[str] = Field(21073      default=None,21074      description="""21075      The fully qualified name of the publisher model or tuned model endpoint to21076      use.21077      """,21078  )21079  generation_config: Optional[GenerationConfig] = Field(21080      default=None,21081      description="""The generation configuration for the session.21082      Note: only a subset of fields are supported.21083      """,21084  )21085  system_instruction: Optional[ContentUnion] = Field(21086      default=None,21087      description="""The user provided system instructions for the model.21088      Note: only text should be used in parts and content in each part will be21089      in a separate paragraph.""",21090  )21091  tools: Optional[ToolListUnion] = Field(21092      default=None,21093      description=""" A list of `Tools` the model may use to generate the next response.2109421095      A `Tool` is a piece of code that enables the system to interact with21096      external systems to perform an action, or set of actions, outside of21097      knowledge and scope of the model.""",21098  )21099  session_resumption: Optional[SessionResumptionConfig] = Field(21100      default=None,21101      description="""Configures session resumption mechanism.2110221103          If included server will send SessionResumptionUpdate messages.""",21104  )21105  context_window_compression: Optional[ContextWindowCompressionConfig] = Field(21106      default=None,21107      description="""Configures context window compression mechanism.2110821109      If included, server will compress context window to fit into given length.""",21110  )21111  input_audio_transcription: Optional[AudioTranscriptionConfig] = Field(21112      default=None,21113      description="""The transcription of the input aligns with the input audio language.21114      """,21115  )21116  output_audio_transcription: Optional[AudioTranscriptionConfig] = Field(21117      default=None,21118      description="""The transcription of the output aligns with the language code21119      specified for the output audio.21120      """,21121  )21122  proactivity: Optional[ProactivityConfig] = Field(21123      default=None,21124      description="""Configures the proactivity of the model. This allows the model to respond proactively to21125    the input and to ignore irrelevant input.""",21126  )21127  explicit_vad_signal: Optional[bool] = Field(21128      default=None,21129      description="""Configures the explicit VAD signal. If enabled, the client will send21130      vad_signal to indicate the start and end of speech. This allows the server21131      to process the audio more efficiently.""",21132  )21133  history_config: Optional[HistoryConfig] = Field(21134      default=None,21135      description="""Configures the exchange of history between the client and the server.""",21136  )21137  avatar_config: Optional[AvatarConfig] = Field(21138      default=None, description="""Configures the avatar model behavior."""21139  )21140  safety_settings: Optional[list[SafetySetting]] = Field(21141      default=None,21142      description="""Safety settings in the request to block unsafe content in the21143      response.21144      """,21145  )211462114721148class LiveClientSetupDict(TypedDict, total=False):21149  """Message contains configuration that will apply for the duration of the streaming session."""2115021151  model: Optional[str]21152  """21153      The fully qualified name of the publisher model or tuned model endpoint to21154      use.21155      """2115621157  generation_config: Optional[GenerationConfigDict]21158  """The generation configuration for the session.21159      Note: only a subset of fields are supported.21160      """2116121162  system_instruction: Optional[ContentUnionDict]21163  """The user provided system instructions for the model.21164      Note: only text should be used in parts and content in each part will be21165      in a separate paragraph."""2116621167  tools: Optional[ToolListUnionDict]21168  """ A list of `Tools` the model may use to generate the next response.2116921170      A `Tool` is a piece of code that enables the system to interact with21171      external systems to perform an action, or set of actions, outside of21172      knowledge and scope of the model."""2117321174  session_resumption: Optional[SessionResumptionConfigDict]21175  """Configures session resumption mechanism.2117621177          If included server will send SessionResumptionUpdate messages."""2117821179  context_window_compression: Optional[ContextWindowCompressionConfigDict]21180  """Configures context window compression mechanism.2118121182      If included, server will compress context window to fit into given length."""2118321184  input_audio_transcription: Optional[AudioTranscriptionConfigDict]21185  """The transcription of the input aligns with the input audio language.21186      """2118721188  output_audio_transcription: Optional[AudioTranscriptionConfigDict]21189  """The transcription of the output aligns with the language code21190      specified for the output audio.21191      """2119221193  proactivity: Optional[ProactivityConfigDict]21194  """Configures the proactivity of the model. This allows the model to respond proactively to21195    the input and to ignore irrelevant input."""2119621197  explicit_vad_signal: Optional[bool]21198  """Configures the explicit VAD signal. If enabled, the client will send21199      vad_signal to indicate the start and end of speech. This allows the server21200      to process the audio more efficiently."""2120121202  history_config: Optional[HistoryConfigDict]21203  """Configures the exchange of history between the client and the server."""2120421205  avatar_config: Optional[AvatarConfigDict]21206  """Configures the avatar model behavior."""2120721208  safety_settings: Optional[list[SafetySettingDict]]21209  """Safety settings in the request to block unsafe content in the21210      response.21211      """212122121321214LiveClientSetupOrDict = Union[LiveClientSetup, LiveClientSetupDict]212152121621217class LiveClientContent(_common.BaseModel):21218  """Incremental update of the current conversation delivered from the client.2121921220  All the content here will unconditionally be appended to the conversation21221  history and used as part of the prompt to the model to generate content.2122221223  A message here will interrupt any current model generation.21224  """2122521226  turns: Optional[list[Content]] = Field(21227      default=None,21228      description="""The content appended to the current conversation with the model.2122921230      For single-turn queries, this is a single instance. For multi-turn21231      queries, this is a repeated field that contains conversation history and21232      latest request.21233      """,21234  )21235  turn_complete: Optional[bool] = Field(21236      default=None,21237      description="""If true, indicates that the server content generation should start with21238  the currently accumulated prompt. Otherwise, the server will await21239  additional messages before starting generation.""",21240  )212412124221243class LiveClientContentDict(TypedDict, total=False):21244  """Incremental update of the current conversation delivered from the client.2124521246  All the content here will unconditionally be appended to the conversation21247  history and used as part of the prompt to the model to generate content.2124821249  A message here will interrupt any current model generation.21250  """2125121252  turns: Optional[list[ContentDict]]21253  """The content appended to the current conversation with the model.2125421255      For single-turn queries, this is a single instance. For multi-turn21256      queries, this is a repeated field that contains conversation history and21257      latest request.21258      """2125921260  turn_complete: Optional[bool]21261  """If true, indicates that the server content generation should start with21262  the currently accumulated prompt. Otherwise, the server will await21263  additional messages before starting generation."""212642126521266LiveClientContentOrDict = Union[LiveClientContent, LiveClientContentDict]212672126821269class ActivityStart(_common.BaseModel):21270  """Marks the start of user activity.2127121272  This can only be sent if automatic (i.e. server-side) activity detection is21273  disabled.21274  """2127521276  pass212772127821279class ActivityStartDict(TypedDict, total=False):21280  """Marks the start of user activity.2128121282  This can only be sent if automatic (i.e. server-side) activity detection is21283  disabled.21284  """2128521286  pass212872128821289ActivityStartOrDict = Union[ActivityStart, ActivityStartDict]212902129121292class ActivityEnd(_common.BaseModel):21293  """Marks the end of user activity.2129421295  This can only be sent if automatic (i.e. server-side) activity detection is21296  disabled.21297  """2129821299  pass213002130121302class ActivityEndDict(TypedDict, total=False):21303  """Marks the end of user activity.2130421305  This can only be sent if automatic (i.e. server-side) activity detection is21306  disabled.21307  """2130821309  pass213102131121312ActivityEndOrDict = Union[ActivityEnd, ActivityEndDict]213132131421315class LiveClientRealtimeInput(_common.BaseModel):21316  """User input that is sent in real time.2131721318  This is different from `LiveClientContent` in a few ways:2131921320    - Can be sent continuously without interruption to model generation.21321    - If there is a need to mix data interleaved across the21322      `LiveClientContent` and the `LiveClientRealtimeInput`, server attempts to21323      optimize for best response, but there are no guarantees.21324    - End of turn is not explicitly specified, but is rather derived from user21325      activity (for example, end of speech).21326    - Even before the end of turn, the data is processed incrementally21327      to optimize for a fast start of the response from the model.21328    - Is always assumed to be the user's input (cannot be used to populate21329      conversation history).21330  """2133121332  media_chunks: Optional[list[Blob]] = Field(21333      default=None, description="""Inlined bytes data for media input."""21334  )21335  audio: Optional[Blob] = Field(21336      default=None, description="""The realtime audio input stream."""21337  )21338  audio_stream_end: Optional[bool] = Field(21339      default=None,21340      description="""21341Indicates that the audio stream has ended, e.g. because the microphone was21342turned off.2134321344This should only be sent when automatic activity detection is enabled21345(which is the default).2134621347The client can reopen the stream by sending an audio message.21348""",21349  )21350  video: Optional[Blob] = Field(21351      default=None, description="""The realtime video input stream."""21352  )21353  text: Optional[str] = Field(21354      default=None, description="""The realtime text input stream."""21355  )21356  activity_start: Optional[ActivityStart] = Field(21357      default=None, description="""Marks the start of user activity."""21358  )21359  activity_end: Optional[ActivityEnd] = Field(21360      default=None, description="""Marks the end of user activity."""21361  )213622136321364class LiveClientRealtimeInputDict(TypedDict, total=False):21365  """User input that is sent in real time.2136621367  This is different from `LiveClientContent` in a few ways:2136821369    - Can be sent continuously without interruption to model generation.21370    - If there is a need to mix data interleaved across the21371      `LiveClientContent` and the `LiveClientRealtimeInput`, server attempts to21372      optimize for best response, but there are no guarantees.21373    - End of turn is not explicitly specified, but is rather derived from user21374      activity (for example, end of speech).21375    - Even before the end of turn, the data is processed incrementally21376      to optimize for a fast start of the response from the model.21377    - Is always assumed to be the user's input (cannot be used to populate21378      conversation history).21379  """2138021381  media_chunks: Optional[list[BlobDict]]21382  """Inlined bytes data for media input."""2138321384  audio: Optional[BlobDict]21385  """The realtime audio input stream."""2138621387  audio_stream_end: Optional[bool]21388  """21389Indicates that the audio stream has ended, e.g. because the microphone was21390turned off.2139121392This should only be sent when automatic activity detection is enabled21393(which is the default).2139421395The client can reopen the stream by sending an audio message.21396"""2139721398  video: Optional[BlobDict]21399  """The realtime video input stream."""2140021401  text: Optional[str]21402  """The realtime text input stream."""2140321404  activity_start: Optional[ActivityStartDict]21405  """Marks the start of user activity."""2140621407  activity_end: Optional[ActivityEndDict]21408  """Marks the end of user activity."""214092141021411LiveClientRealtimeInputOrDict = Union[21412    LiveClientRealtimeInput, LiveClientRealtimeInputDict21413]214142141521416class LiveClientToolResponse(_common.BaseModel):21417  """Client generated response to a `ToolCall` received from the server.2141821419  Individual `FunctionResponse` objects are matched to the respective21420  `FunctionCall` objects by the `id` field.2142121422  Note that in the unary and server-streaming GenerateContent APIs function21423  calling happens by exchanging the `Content` parts, while in the bidi21424  GenerateContent APIs function calling happens over this dedicated set of21425  messages.21426  """2142721428  function_responses: Optional[list[FunctionResponse]] = Field(21429      default=None, description="""The response to the function calls."""21430  )214312143221433class LiveClientToolResponseDict(TypedDict, total=False):21434  """Client generated response to a `ToolCall` received from the server.2143521436  Individual `FunctionResponse` objects are matched to the respective21437  `FunctionCall` objects by the `id` field.2143821439  Note that in the unary and server-streaming GenerateContent APIs function21440  calling happens by exchanging the `Content` parts, while in the bidi21441  GenerateContent APIs function calling happens over this dedicated set of21442  messages.21443  """2144421445  function_responses: Optional[list[FunctionResponseDict]]21446  """The response to the function calls."""214472144821449LiveClientToolResponseOrDict = Union[21450    LiveClientToolResponse, LiveClientToolResponseDict21451]214522145321454class LiveClientMessage(_common.BaseModel):21455  """Messages sent by the client in the API call."""2145621457  setup: Optional[LiveClientSetup] = Field(21458      default=None,21459      description="""Message to be sent by the system when connecting to the API. SDK users should not send this message.""",21460  )21461  client_content: Optional[LiveClientContent] = Field(21462      default=None,21463      description="""Incremental update of the current conversation delivered from the client.""",21464  )21465  realtime_input: Optional[LiveClientRealtimeInput] = Field(21466      default=None, description="""User input that is sent in real time."""21467  )21468  tool_response: Optional[LiveClientToolResponse] = Field(21469      default=None,21470      description="""Response to a `ToolCallMessage` received from the server.""",21471  )214722147321474class LiveClientMessageDict(TypedDict, total=False):21475  """Messages sent by the client in the API call."""2147621477  setup: Optional[LiveClientSetupDict]21478  """Message to be sent by the system when connecting to the API. SDK users should not send this message."""2147921480  client_content: Optional[LiveClientContentDict]21481  """Incremental update of the current conversation delivered from the client."""2148221483  realtime_input: Optional[LiveClientRealtimeInputDict]21484  """User input that is sent in real time."""2148521486  tool_response: Optional[LiveClientToolResponseDict]21487  """Response to a `ToolCallMessage` received from the server."""214882148921490LiveClientMessageOrDict = Union[LiveClientMessage, LiveClientMessageDict]214912149221493class AutomaticActivityDetection(_common.BaseModel):21494  """Configures automatic detection of activity."""2149521496  disabled: Optional[bool] = Field(21497      default=None,21498      description="""If enabled, detected voice and text input count as activity. If disabled, the client must send activity signals.""",21499  )21500  start_of_speech_sensitivity: Optional[StartSensitivity] = Field(21501      default=None,21502      description="""Determines how likely speech is to be detected.""",21503  )21504  end_of_speech_sensitivity: Optional[EndSensitivity] = Field(21505      default=None,21506      description="""Determines how likely detected speech is ended.""",21507  )21508  prefix_padding_ms: Optional[int] = Field(21509      default=None,21510      description="""The required duration of detected speech before start-of-speech is committed. The lower this value the more sensitive the start-of-speech detection is and the shorter speech can be recognized. However, this also increases the probability of false positives.""",21511  )21512  silence_duration_ms: Optional[int] = Field(21513      default=None,21514      description="""The required duration of detected non-speech (e.g. silence) before end-of-speech is committed. The larger this value, the longer speech gaps can be without interrupting the user's activity but this will increase the model's latency.""",21515  )215162151721518class AutomaticActivityDetectionDict(TypedDict, total=False):21519  """Configures automatic detection of activity."""2152021521  disabled: Optional[bool]21522  """If enabled, detected voice and text input count as activity. If disabled, the client must send activity signals."""2152321524  start_of_speech_sensitivity: Optional[StartSensitivity]21525  """Determines how likely speech is to be detected."""2152621527  end_of_speech_sensitivity: Optional[EndSensitivity]21528  """Determines how likely detected speech is ended."""2152921530  prefix_padding_ms: Optional[int]21531  """The required duration of detected speech before start-of-speech is committed. The lower this value the more sensitive the start-of-speech detection is and the shorter speech can be recognized. However, this also increases the probability of false positives."""2153221533  silence_duration_ms: Optional[int]21534  """The required duration of detected non-speech (e.g. silence) before end-of-speech is committed. The larger this value, the longer speech gaps can be without interrupting the user's activity but this will increase the model's latency."""215352153621537AutomaticActivityDetectionOrDict = Union[21538    AutomaticActivityDetection, AutomaticActivityDetectionDict21539]215402154121542class RealtimeInputConfig(_common.BaseModel):21543  """Marks the end of user activity.2154421545  This can only be sent if automatic (i.e. server-side) activity detection is21546  disabled.21547  """2154821549  automatic_activity_detection: Optional[AutomaticActivityDetection] = Field(21550      default=None,21551      description="""If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals.""",21552  )21553  activity_handling: Optional[ActivityHandling] = Field(21554      default=None, description="""Defines what effect activity has."""21555  )21556  turn_coverage: Optional[TurnCoverage] = Field(21557      default=None,21558      description="""Defines which input is included in the user's turn.""",21559  )215602156121562class RealtimeInputConfigDict(TypedDict, total=False):21563  """Marks the end of user activity.2156421565  This can only be sent if automatic (i.e. server-side) activity detection is21566  disabled.21567  """2156821569  automatic_activity_detection: Optional[AutomaticActivityDetectionDict]21570  """If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals."""2157121572  activity_handling: Optional[ActivityHandling]21573  """Defines what effect activity has."""2157421575  turn_coverage: Optional[TurnCoverage]21576  """Defines which input is included in the user's turn."""215772157821579RealtimeInputConfigOrDict = Union[RealtimeInputConfig, RealtimeInputConfigDict]215802158121582class LiveConnectConfig(_common.BaseModel):21583  """Session config for the API connection."""2158421585  http_options: Optional[HttpOptions] = Field(21586      default=None, description="""Used to override HTTP request options."""21587  )21588  generation_config: Optional[GenerationConfig] = Field(21589      default=None,21590      description="""The generation configuration for the session.""",21591  )21592  response_modalities: Optional[list[Modality]] = Field(21593      default=None,21594      description="""The requested modalities of the response. Represents the set of21595      modalities that the model can return. Defaults to AUDIO if not specified.21596      """,21597  )21598  temperature: Optional[float] = Field(21599      default=None,21600      description="""Value that controls the degree of randomness in token selection.21601      Lower temperatures are good for prompts that require a less open-ended or21602      creative response, while higher temperatures can lead to more diverse or21603      creative results.21604      """,21605  )21606  top_p: Optional[float] = Field(21607      default=None,21608      description="""Tokens are selected from the most to least probable until the sum21609      of their probabilities equals this value. Use a lower value for less21610      random responses and a higher value for more random responses.21611      """,21612  )21613  top_k: Optional[float] = Field(21614      default=None,21615      description="""For each token selection step, the ``top_k`` tokens with the21616      highest probabilities are sampled. Then tokens are further filtered based21617      on ``top_p`` with the final token selected using temperature sampling. Use21618      a lower number for less random responses and a higher number for more21619      random responses.21620      """,21621  )21622  max_output_tokens: Optional[int] = Field(21623      default=None,21624      description="""Maximum number of tokens that can be generated in the response.21625      """,21626  )21627  media_resolution: Optional[MediaResolution] = Field(21628      default=None,21629      description="""If specified, the media resolution specified will be used.21630      """,21631  )21632  seed: Optional[int] = Field(21633      default=None,21634      description="""When ``seed`` is fixed to a specific number, the model makes a best21635      effort to provide the same response for repeated requests. By default, a21636      random number is used.21637      """,21638  )21639  speech_config: Optional[SpeechConfig] = Field(21640      default=None,21641      description="""The speech generation configuration.21642      """,21643  )21644  thinking_config: Optional[ThinkingConfig] = Field(21645      default=None,21646      description="""Config for thinking features.21647      An error will be returned if this field is set for models that don't21648      support thinking.21649      """,21650  )21651  enable_affective_dialog: Optional[bool] = Field(21652      default=None,21653      description="""If enabled, the model will detect emotions and adapt its responses accordingly.""",21654  )21655  system_instruction: Optional[ContentUnion] = Field(21656      default=None,21657      description="""The user provided system instructions for the model.21658      Note: only text should be used in parts and content in each part will be21659      in a separate paragraph.""",21660  )21661  tools: Optional[ToolListUnion] = Field(21662      default=None,21663      description="""A list of `Tools` the model may use to generate the next response.2166421665      A `Tool` is a piece of code that enables the system to interact with21666      external systems to perform an action, or set of actions, outside of21667      knowledge and scope of the model.""",21668  )21669  session_resumption: Optional[SessionResumptionConfig] = Field(21670      default=None,21671      description="""Configures session resumption mechanism.2167221673If included the server will send SessionResumptionUpdate messages.""",21674  )21675  input_audio_transcription: Optional[AudioTranscriptionConfig] = Field(21676      default=None,21677      description="""The transcription of the input aligns with the input audio language.21678      """,21679  )21680  output_audio_transcription: Optional[AudioTranscriptionConfig] = Field(21681      default=None,21682      description="""The transcription of the output aligns with the language code21683      specified for the output audio.21684      """,21685  )21686  realtime_input_config: Optional[RealtimeInputConfig] = Field(21687      default=None,21688      description="""Configures the realtime input behavior in BidiGenerateContent.""",21689  )21690  context_window_compression: Optional[ContextWindowCompressionConfig] = Field(21691      default=None,21692      description="""Configures context window compression mechanism.2169321694      If included, server will compress context window to fit into given length.""",21695  )21696  proactivity: Optional[ProactivityConfig] = Field(21697      default=None,21698      description="""Configures the proactivity of the model. This allows the model to respond proactively to21699    the input and to ignore irrelevant input.""",21700  )21701  explicit_vad_signal: Optional[bool] = Field(21702      default=None,21703      description="""Configures the explicit VAD signal. If enabled, the client will send21704      vad_signal to indicate the start and end of speech. This allows the server21705      to process the audio more efficiently.""",21706  )21707  history_config: Optional[HistoryConfig] = Field(21708      default=None,21709      description="""Configures the exchange of history between the client and the server.""",21710  )21711  avatar_config: Optional[AvatarConfig] = Field(21712      default=None, description="""Configures the avatar model behavior."""21713  )21714  safety_settings: Optional[list[SafetySetting]] = Field(21715      default=None,21716      description="""Safety settings in the request to block unsafe content in the21717      response.21718      """,21719  )21720  translation_config: Optional[TranslationConfig] = Field(21721      default=None, description="""Config for translation."""21722  )217232172421725class LiveConnectConfigDict(TypedDict, total=False):21726  """Session config for the API connection."""2172721728  http_options: Optional[HttpOptionsDict]21729  """Used to override HTTP request options."""2173021731  generation_config: Optional[GenerationConfigDict]21732  """The generation configuration for the session."""2173321734  response_modalities: Optional[list[Modality]]21735  """The requested modalities of the response. Represents the set of21736      modalities that the model can return. Defaults to AUDIO if not specified.21737      """2173821739  temperature: Optional[float]21740  """Value that controls the degree of randomness in token selection.21741      Lower temperatures are good for prompts that require a less open-ended or21742      creative response, while higher temperatures can lead to more diverse or21743      creative results.21744      """2174521746  top_p: Optional[float]21747  """Tokens are selected from the most to least probable until the sum21748      of their probabilities equals this value. Use a lower value for less21749      random responses and a higher value for more random responses.21750      """2175121752  top_k: Optional[float]21753  """For each token selection step, the ``top_k`` tokens with the21754      highest probabilities are sampled. Then tokens are further filtered based21755      on ``top_p`` with the final token selected using temperature sampling. Use21756      a lower number for less random responses and a higher number for more21757      random responses.21758      """2175921760  max_output_tokens: Optional[int]21761  """Maximum number of tokens that can be generated in the response.21762      """2176321764  media_resolution: Optional[MediaResolution]21765  """If specified, the media resolution specified will be used.21766      """2176721768  seed: Optional[int]21769  """When ``seed`` is fixed to a specific number, the model makes a best21770      effort to provide the same response for repeated requests. By default, a21771      random number is used.21772      """2177321774  speech_config: Optional[SpeechConfigDict]21775  """The speech generation configuration.21776      """2177721778  thinking_config: Optional[ThinkingConfigDict]21779  """Config for thinking features.21780      An error will be returned if this field is set for models that don't21781      support thinking.21782      """2178321784  enable_affective_dialog: Optional[bool]21785  """If enabled, the model will detect emotions and adapt its responses accordingly."""2178621787  system_instruction: Optional[ContentUnionDict]21788  """The user provided system instructions for the model.21789      Note: only text should be used in parts and content in each part will be21790      in a separate paragraph."""2179121792  tools: Optional[ToolListUnionDict]21793  """A list of `Tools` the model may use to generate the next response.2179421795      A `Tool` is a piece of code that enables the system to interact with21796      external systems to perform an action, or set of actions, outside of21797      knowledge and scope of the model."""2179821799  session_resumption: Optional[SessionResumptionConfigDict]21800  """Configures session resumption mechanism.2180121802If included the server will send SessionResumptionUpdate messages."""2180321804  input_audio_transcription: Optional[AudioTranscriptionConfigDict]21805  """The transcription of the input aligns with the input audio language.21806      """2180721808  output_audio_transcription: Optional[AudioTranscriptionConfigDict]21809  """The transcription of the output aligns with the language code21810      specified for the output audio.21811      """2181221813  realtime_input_config: Optional[RealtimeInputConfigDict]21814  """Configures the realtime input behavior in BidiGenerateContent."""2181521816  context_window_compression: Optional[ContextWindowCompressionConfigDict]21817  """Configures context window compression mechanism.2181821819      If included, server will compress context window to fit into given length."""2182021821  proactivity: Optional[ProactivityConfigDict]21822  """Configures the proactivity of the model. This allows the model to respond proactively to21823    the input and to ignore irrelevant input."""2182421825  explicit_vad_signal: Optional[bool]21826  """Configures the explicit VAD signal. If enabled, the client will send21827      vad_signal to indicate the start and end of speech. This allows the server21828      to process the audio more efficiently."""2182921830  history_config: Optional[HistoryConfigDict]21831  """Configures the exchange of history between the client and the server."""2183221833  avatar_config: Optional[AvatarConfigDict]21834  """Configures the avatar model behavior."""2183521836  safety_settings: Optional[list[SafetySettingDict]]21837  """Safety settings in the request to block unsafe content in the21838      response.21839      """2184021841  translation_config: Optional[TranslationConfigDict]21842  """Config for translation."""218432184421845LiveConnectConfigOrDict = Union[LiveConnectConfig, LiveConnectConfigDict]218462184721848class LiveConnectParameters(_common.BaseModel):21849  """Parameters for connecting to the live API."""2185021851  model: Optional[str] = Field(21852      default=None,21853      description="""ID of the model to use. For a list of models, see `Google models21854    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",21855  )21856  config: Optional[LiveConnectConfig] = Field(21857      default=None,21858      description="""Optional configuration parameters for the request.21859      """,21860  )218612186221863class LiveConnectParametersDict(TypedDict, total=False):21864  """Parameters for connecting to the live API."""2186521866  model: Optional[str]21867  """ID of the model to use. For a list of models, see `Google models21868    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""2186921870  config: Optional[LiveConnectConfigDict]21871  """Optional configuration parameters for the request.21872      """218732187421875LiveConnectParametersOrDict = Union[21876    LiveConnectParameters, LiveConnectParametersDict21877]218782187921880if _is_pillow_image_imported:21881  BlobImageUnion = Union[PIL_Image, Blob]21882else:21883  BlobImageUnion = Blob  # type: ignore[misc]218842188521886if _is_pillow_image_imported:21887  BlobImageUnionDict = Union[PIL_Image, Blob, BlobDict]21888else:21889  BlobImageUnionDict = Union[Blob, BlobDict]  # type: ignore[misc]218902189121892class LiveSendRealtimeInputParameters(_common.BaseModel):21893  """Parameters for sending realtime input to the live API."""2189421895  media: Optional[BlobImageUnion] = Field(21896      default=None, description="""Realtime input to send to the session."""21897  )21898  audio: Optional[Blob] = Field(21899      default=None, description="""The realtime audio input stream."""21900  )21901  audio_stream_end: Optional[bool] = Field(21902      default=None,21903      description="""21904Indicates that the audio stream has ended, e.g. because the microphone was21905turned off.2190621907This should only be sent when automatic activity detection is enabled21908(which is the default).2190921910The client can reopen the stream by sending an audio message.21911""",21912  )21913  video: Optional[BlobImageUnion] = Field(21914      default=None, description="""The realtime video input stream."""21915  )21916  text: Optional[str] = Field(21917      default=None, description="""The realtime text input stream."""21918  )21919  activity_start: Optional[ActivityStart] = Field(21920      default=None, description="""Marks the start of user activity."""21921  )21922  activity_end: Optional[ActivityEnd] = Field(21923      default=None, description="""Marks the end of user activity."""21924  )219252192621927class LiveSendRealtimeInputParametersDict(TypedDict, total=False):21928  """Parameters for sending realtime input to the live API."""2192921930  media: Optional[BlobImageUnionDict]21931  """Realtime input to send to the session."""2193221933  audio: Optional[BlobDict]21934  """The realtime audio input stream."""2193521936  audio_stream_end: Optional[bool]21937  """21938Indicates that the audio stream has ended, e.g. because the microphone was21939turned off.2194021941This should only be sent when automatic activity detection is enabled21942(which is the default).2194321944The client can reopen the stream by sending an audio message.21945"""2194621947  video: Optional[BlobImageUnionDict]21948  """The realtime video input stream."""2194921950  text: Optional[str]21951  """The realtime text input stream."""2195221953  activity_start: Optional[ActivityStartDict]21954  """Marks the start of user activity."""2195521956  activity_end: Optional[ActivityEndDict]21957  """Marks the end of user activity."""219582195921960LiveSendRealtimeInputParametersOrDict = Union[21961    LiveSendRealtimeInputParameters, LiveSendRealtimeInputParametersDict21962]219632196421965class LiveMusicClientSetup(_common.BaseModel):21966  """Message to be sent by the system when connecting to the API."""2196721968  model: Optional[str] = Field(21969      default=None,21970      description="""The model's resource name. Format: `models/{model}`.""",21971  )219722197321974class LiveMusicClientSetupDict(TypedDict, total=False):21975  """Message to be sent by the system when connecting to the API."""2197621977  model: Optional[str]21978  """The model's resource name. Format: `models/{model}`."""219792198021981LiveMusicClientSetupOrDict = Union[21982    LiveMusicClientSetup, LiveMusicClientSetupDict21983]219842198521986class WeightedPrompt(_common.BaseModel):21987  """Maps a prompt to a relative weight to steer music generation."""2198821989  text: Optional[str] = Field(default=None, description="""Text prompt.""")21990  weight: Optional[float] = Field(21991      default=None,21992      description="""Weight of the prompt. The weight is used to control the relative21993      importance of the prompt. Higher weights are more important than lower21994      weights.2199521996      Weight must not be 0. Weights of all weighted_prompts in this21997      LiveMusicClientContent message will be normalized.""",21998  )219992200022001class WeightedPromptDict(TypedDict, total=False):22002  """Maps a prompt to a relative weight to steer music generation."""2200322004  text: Optional[str]22005  """Text prompt."""2200622007  weight: Optional[float]22008  """Weight of the prompt. The weight is used to control the relative22009      importance of the prompt. Higher weights are more important than lower22010      weights.2201122012      Weight must not be 0. Weights of all weighted_prompts in this22013      LiveMusicClientContent message will be normalized."""220142201522016WeightedPromptOrDict = Union[WeightedPrompt, WeightedPromptDict]220172201822019class LiveMusicClientContent(_common.BaseModel):22020  """User input to start or steer the music."""2202122022  weighted_prompts: Optional[list[WeightedPrompt]] = Field(22023      default=None, description="""Weighted prompts as the model input."""22024  )220252202622027class LiveMusicClientContentDict(TypedDict, total=False):22028  """User input to start or steer the music."""2202922030  weighted_prompts: Optional[list[WeightedPromptDict]]22031  """Weighted prompts as the model input."""220322203322034LiveMusicClientContentOrDict = Union[22035    LiveMusicClientContent, LiveMusicClientContentDict22036]220372203822039class LiveMusicGenerationConfig(_common.BaseModel):22040  """Configuration for music generation."""2204122042  temperature: Optional[float] = Field(22043      default=None,22044      description="""Controls the variance in audio generation. Higher values produce22045      higher variance. Range is [0.0, 3.0].""",22046  )22047  top_k: Optional[int] = Field(22048      default=None,22049      description="""Controls how the model selects tokens for output. Samples the topK22050      tokens with the highest probabilities. Range is [1, 1000].""",22051  )22052  seed: Optional[int] = Field(22053      default=None,22054      description="""Seeds audio generation. If not set, the request uses a randomly22055      generated seed.""",22056  )22057  guidance: Optional[float] = Field(22058      default=None,22059      description="""Controls how closely the model follows prompts.22060      Higher guidance follows more closely, but will make transitions more22061      abrupt. Range is [0.0, 6.0].""",22062  )22063  bpm: Optional[int] = Field(22064      default=None, description="""Beats per minute. Range is [60, 200]."""22065  )22066  density: Optional[float] = Field(22067      default=None, description="""Density of sounds. Range is [0.0, 1.0]."""22068  )22069  brightness: Optional[float] = Field(22070      default=None,22071      description="""Brightness of the music. Range is [0.0, 1.0].""",22072  )22073  scale: Optional[Scale] = Field(22074      default=None, description="""Scale of the generated music."""22075  )22076  mute_bass: Optional[bool] = Field(22077      default=None,22078      description="""Whether the audio output should contain bass.""",22079  )22080  mute_drums: Optional[bool] = Field(22081      default=None,22082      description="""Whether the audio output should contain drums.""",22083  )22084  only_bass_and_drums: Optional[bool] = Field(22085      default=None,22086      description="""Whether the audio output should contain only bass and drums.""",22087  )22088  music_generation_mode: Optional[MusicGenerationMode] = Field(22089      default=None,22090      description="""The mode of music generation. Default mode is QUALITY.""",22091  )220922209322094class LiveMusicGenerationConfigDict(TypedDict, total=False):22095  """Configuration for music generation."""2209622097  temperature: Optional[float]22098  """Controls the variance in audio generation. Higher values produce22099      higher variance. Range is [0.0, 3.0]."""2210022101  top_k: Optional[int]22102  """Controls how the model selects tokens for output. Samples the topK22103      tokens with the highest probabilities. Range is [1, 1000]."""2210422105  seed: Optional[int]22106  """Seeds audio generation. If not set, the request uses a randomly22107      generated seed."""2210822109  guidance: Optional[float]22110  """Controls how closely the model follows prompts.22111      Higher guidance follows more closely, but will make transitions more22112      abrupt. Range is [0.0, 6.0]."""2211322114  bpm: Optional[int]22115  """Beats per minute. Range is [60, 200]."""2211622117  density: Optional[float]22118  """Density of sounds. Range is [0.0, 1.0]."""2211922120  brightness: Optional[float]22121  """Brightness of the music. Range is [0.0, 1.0]."""2212222123  scale: Optional[Scale]22124  """Scale of the generated music."""2212522126  mute_bass: Optional[bool]22127  """Whether the audio output should contain bass."""2212822129  mute_drums: Optional[bool]22130  """Whether the audio output should contain drums."""2213122132  only_bass_and_drums: Optional[bool]22133  """Whether the audio output should contain only bass and drums."""2213422135  music_generation_mode: Optional[MusicGenerationMode]22136  """The mode of music generation. Default mode is QUALITY."""221372213822139LiveMusicGenerationConfigOrDict = Union[22140    LiveMusicGenerationConfig, LiveMusicGenerationConfigDict22141]221422214322144class LiveMusicClientMessage(_common.BaseModel):22145  """Messages sent by the client in the LiveMusicClientMessage call."""2214622147  setup: Optional[LiveMusicClientSetup] = Field(22148      default=None,22149      description="""Message to be sent in the first (and only in the first) `LiveMusicClientMessage`.22150      Clients should wait for a `LiveMusicSetupComplete` message before22151      sending any additional messages.""",22152  )22153  client_content: Optional[LiveMusicClientContent] = Field(22154      default=None, description="""User input to influence music generation."""22155  )22156  music_generation_config: Optional[LiveMusicGenerationConfig] = Field(22157      default=None, description="""Configuration for music generation."""22158  )22159  playback_control: Optional[LiveMusicPlaybackControl] = Field(22160      default=None,22161      description="""Playback control signal for the music generation.""",22162  )221632216422165class LiveMusicClientMessageDict(TypedDict, total=False):22166  """Messages sent by the client in the LiveMusicClientMessage call."""2216722168  setup: Optional[LiveMusicClientSetupDict]22169  """Message to be sent in the first (and only in the first) `LiveMusicClientMessage`.22170      Clients should wait for a `LiveMusicSetupComplete` message before22171      sending any additional messages."""2217222173  client_content: Optional[LiveMusicClientContentDict]22174  """User input to influence music generation."""2217522176  music_generation_config: Optional[LiveMusicGenerationConfigDict]22177  """Configuration for music generation."""2217822179  playback_control: Optional[LiveMusicPlaybackControl]22180  """Playback control signal for the music generation."""221812218222183LiveMusicClientMessageOrDict = Union[22184    LiveMusicClientMessage, LiveMusicClientMessageDict22185]221862218722188class LiveMusicServerSetupComplete(_common.BaseModel):22189  """Sent in response to a `LiveMusicClientSetup` message from the client."""2219022191  pass221922219322194class LiveMusicServerSetupCompleteDict(TypedDict, total=False):22195  """Sent in response to a `LiveMusicClientSetup` message from the client."""2219622197  pass221982219922200LiveMusicServerSetupCompleteOrDict = Union[22201    LiveMusicServerSetupComplete, LiveMusicServerSetupCompleteDict22202]222032220422205class LiveMusicSourceMetadata(_common.BaseModel):22206  """Prompts and config used for generating this audio chunk."""2220722208  client_content: Optional[LiveMusicClientContent] = Field(22209      default=None,22210      description="""Weighted prompts for generating this audio chunk.""",22211  )22212  music_generation_config: Optional[LiveMusicGenerationConfig] = Field(22213      default=None,22214      description="""Music generation config for generating this audio chunk.""",22215  )222162221722218class LiveMusicSourceMetadataDict(TypedDict, total=False):22219  """Prompts and config used for generating this audio chunk."""2222022221  client_content: Optional[LiveMusicClientContentDict]22222  """Weighted prompts for generating this audio chunk."""2222322224  music_generation_config: Optional[LiveMusicGenerationConfigDict]22225  """Music generation config for generating this audio chunk."""222262222722228LiveMusicSourceMetadataOrDict = Union[22229    LiveMusicSourceMetadata, LiveMusicSourceMetadataDict22230]222312223222233class AudioChunk(_common.BaseModel):22234  """Representation of an audio chunk."""2223522236  data: Optional[bytes] = Field(22237      default=None, description="""Raw bytes of audio data."""22238  )22239  mime_type: Optional[str] = Field(22240      default=None, description="""MIME type of the audio chunk."""22241  )22242  source_metadata: Optional[LiveMusicSourceMetadata] = Field(22243      default=None,22244      description="""Prompts and config used for generating this audio chunk.""",22245  )222462224722248class AudioChunkDict(TypedDict, total=False):22249  """Representation of an audio chunk."""2225022251  data: Optional[bytes]22252  """Raw bytes of audio data."""2225322254  mime_type: Optional[str]22255  """MIME type of the audio chunk."""2225622257  source_metadata: Optional[LiveMusicSourceMetadataDict]22258  """Prompts and config used for generating this audio chunk."""222592226022261AudioChunkOrDict = Union[AudioChunk, AudioChunkDict]222622226322264class LiveMusicServerContent(_common.BaseModel):22265  """Server update generated by the model in response to client messages.2226622267  Content is generated as quickly as possible, and not in real time.22268  Clients may choose to buffer and play it out in real time.22269  """2227022271  audio_chunks: Optional[list[AudioChunk]] = Field(22272      default=None,22273      description="""The audio chunks that the model has generated.""",22274  )222752227622277class LiveMusicServerContentDict(TypedDict, total=False):22278  """Server update generated by the model in response to client messages.2227922280  Content is generated as quickly as possible, and not in real time.22281  Clients may choose to buffer and play it out in real time.22282  """2228322284  audio_chunks: Optional[list[AudioChunkDict]]22285  """The audio chunks that the model has generated."""222862228722288LiveMusicServerContentOrDict = Union[22289    LiveMusicServerContent, LiveMusicServerContentDict22290]222912229222293class LiveMusicFilteredPrompt(_common.BaseModel):22294  """A prompt that was filtered with the reason."""2229522296  text: Optional[str] = Field(22297      default=None, description="""The text prompt that was filtered."""22298  )22299  filtered_reason: Optional[str] = Field(22300      default=None, description="""The reason the prompt was filtered."""22301  )223022230322304class LiveMusicFilteredPromptDict(TypedDict, total=False):22305  """A prompt that was filtered with the reason."""2230622307  text: Optional[str]22308  """The text prompt that was filtered."""2230922310  filtered_reason: Optional[str]22311  """The reason the prompt was filtered."""223122231322314LiveMusicFilteredPromptOrDict = Union[22315    LiveMusicFilteredPrompt, LiveMusicFilteredPromptDict22316]223172231822319class LiveMusicServerMessage(_common.BaseModel):22320  """Response message for the LiveMusicClientMessage call."""2232122322  setup_complete: Optional[LiveMusicServerSetupComplete] = Field(22323      default=None,22324      description="""Message sent in response to a `LiveMusicClientSetup` message from the client.22325      Clients should wait for this message before sending any additional messages.""",22326  )22327  server_content: Optional[LiveMusicServerContent] = Field(22328      default=None,22329      description="""Content generated by the model in response to client messages.""",22330  )22331  filtered_prompt: Optional[LiveMusicFilteredPrompt] = Field(22332      default=None,22333      description="""A prompt that was filtered with the reason.""",22334  )223352233622337class LiveMusicServerMessageDict(TypedDict, total=False):22338  """Response message for the LiveMusicClientMessage call."""2233922340  setup_complete: Optional[LiveMusicServerSetupCompleteDict]22341  """Message sent in response to a `LiveMusicClientSetup` message from the client.22342      Clients should wait for this message before sending any additional messages."""2234322344  server_content: Optional[LiveMusicServerContentDict]22345  """Content generated by the model in response to client messages."""2234622347  filtered_prompt: Optional[LiveMusicFilteredPromptDict]22348  """A prompt that was filtered with the reason."""223492235022351LiveMusicServerMessageOrDict = Union[22352    LiveMusicServerMessage, LiveMusicServerMessageDict22353]223542235522356class LiveMusicConnectParameters(_common.BaseModel):22357  """Parameters for connecting to the live API."""2235822359  model: Optional[str] = Field(22360      default=None, description="""The model's resource name."""22361  )223622236322364class LiveMusicConnectParametersDict(TypedDict, total=False):22365  """Parameters for connecting to the live API."""2236622367  model: Optional[str]22368  """The model's resource name."""223692237022371LiveMusicConnectParametersOrDict = Union[22372    LiveMusicConnectParameters, LiveMusicConnectParametersDict22373]223742237522376class LiveMusicSetConfigParameters(_common.BaseModel):22377  """Parameters for setting config for the live music API."""2237822379  music_generation_config: Optional[LiveMusicGenerationConfig] = Field(22380      default=None, description="""Configuration for music generation."""22381  )223822238322384class LiveMusicSetConfigParametersDict(TypedDict, total=False):22385  """Parameters for setting config for the live music API."""2238622387  music_generation_config: Optional[LiveMusicGenerationConfigDict]22388  """Configuration for music generation."""223892239022391LiveMusicSetConfigParametersOrDict = Union[22392    LiveMusicSetConfigParameters, LiveMusicSetConfigParametersDict22393]223942239522396class LiveMusicSetWeightedPromptsParameters(_common.BaseModel):22397  """Parameters for setting weighted prompts for the live music API."""2239822399  weighted_prompts: Optional[list[WeightedPrompt]] = Field(22400      default=None,22401      description="""A map of text prompts to weights to use for the generation request.""",22402  )224032240422405class LiveMusicSetWeightedPromptsParametersDict(TypedDict, total=False):22406  """Parameters for setting weighted prompts for the live music API."""2240722408  weighted_prompts: Optional[list[WeightedPromptDict]]22409  """A map of text prompts to weights to use for the generation request."""224102241122412LiveMusicSetWeightedPromptsParametersOrDict = Union[22413    LiveMusicSetWeightedPromptsParameters,22414    LiveMusicSetWeightedPromptsParametersDict,22415]224162241722418class AuthToken(_common.BaseModel):22419  """Config for auth_tokens.create parameters."""2242022421  name: Optional[str] = Field(22422      default=None, description="""The name of the auth token."""22423  )22424  expire_time: Optional[str] = Field(22425      default=None,22426      description="""Optional. Input only. Immutable. An optional time after which, when using the resulting token, messages in BidiGenerateContent sessions will be rejected. (Gemini may preemptively close the session after this time.) If not set then this defaults to 30 minutes in the future. If set, this value must be less than 20 hours in the future.""",22427  )22428  new_session_expire_time: Optional[str] = Field(22429      default=None,22430      description="""Optional. Input only. Immutable. The time after which new Live API sessions using the token resulting from this request will be rejected. If not set this defaults to 60 seconds in the future. If set, this value must be less than 20 hours in the future.""",22431  )22432  uses: Optional[int] = Field(22433      default=None,22434      description="""Optional. Input only. Immutable. The number of times the token can be used. If this value is zero then no limit is applied. Resuming a Live API session does not count as a use. If unspecified, the default is 1.""",22435  )224362243722438class AuthTokenDict(TypedDict, total=False):22439  """Config for auth_tokens.create parameters."""2244022441  name: Optional[str]22442  """The name of the auth token."""2244322444  expire_time: Optional[str]22445  """Optional. Input only. Immutable. An optional time after which, when using the resulting token, messages in BidiGenerateContent sessions will be rejected. (Gemini may preemptively close the session after this time.) If not set then this defaults to 30 minutes in the future. If set, this value must be less than 20 hours in the future."""2244622447  new_session_expire_time: Optional[str]22448  """Optional. Input only. Immutable. The time after which new Live API sessions using the token resulting from this request will be rejected. If not set this defaults to 60 seconds in the future. If set, this value must be less than 20 hours in the future."""2244922450  uses: Optional[int]22451  """Optional. Input only. Immutable. The number of times the token can be used. If this value is zero then no limit is applied. Resuming a Live API session does not count as a use. If unspecified, the default is 1."""224522245322454AuthTokenOrDict = Union[AuthToken, AuthTokenDict]224552245622457class LiveConnectConstraints(_common.BaseModel):22458  """Config for LiveConnectConstraints for Auth Token creation."""2245922460  model: Optional[str] = Field(22461      default=None,22462      description="""ID of the model to configure in the ephemeral token for Live API.22463      For a list of models, see `Gemini models22464      <https://ai.google.dev/gemini-api/docs/models>`.""",22465  )22466  config: Optional[LiveConnectConfig] = Field(22467      default=None,22468      description="""Configuration specific to Live API connections created using this token.""",22469  )224702247122472class LiveConnectConstraintsDict(TypedDict, total=False):22473  """Config for LiveConnectConstraints for Auth Token creation."""2247422475  model: Optional[str]22476  """ID of the model to configure in the ephemeral token for Live API.22477      For a list of models, see `Gemini models22478      <https://ai.google.dev/gemini-api/docs/models>`."""2247922480  config: Optional[LiveConnectConfigDict]22481  """Configuration specific to Live API connections created using this token."""224822248322484LiveConnectConstraintsOrDict = Union[22485    LiveConnectConstraints, LiveConnectConstraintsDict22486]224872248822489class CreateAuthTokenConfig(_common.BaseModel):22490  """Optional parameters."""2249122492  http_options: Optional[HttpOptions] = Field(22493      default=None, description="""Used to override HTTP request options."""22494  )22495  expire_time: Optional[datetime.datetime] = Field(22496      default=None,22497      description="""An optional time after which, when using the resulting token,22498      messages in Live API sessions will be rejected. (Gemini may22499      preemptively close the session after this time.)2250022501      If not set then this defaults to 30 minutes in the future. If set, this22502      value must be less than 20 hours in the future.""",22503  )22504  new_session_expire_time: Optional[datetime.datetime] = Field(22505      default=None,22506      description="""The time after which new Live API sessions using the token22507      resulting from this request will be rejected.2250822509      If not set this defaults to 60 seconds in the future. If set, this value22510      must be less than 20 hours in the future.""",22511  )22512  uses: Optional[int] = Field(22513      default=None,22514      description="""The number of times the token can be used. If this value is zero22515      then no limit is applied. Default is 1. Resuming a Live API session does22516      not count as a use.""",22517  )22518  live_connect_constraints: Optional[LiveConnectConstraints] = Field(22519      default=None,22520      description="""Configuration specific to Live API connections created using this token.""",22521  )22522  lock_additional_fields: Optional[list[str]] = Field(22523      default=None,22524      description="""Additional fields to lock in the effective LiveConnectParameters.""",22525  )225262252722528class CreateAuthTokenConfigDict(TypedDict, total=False):22529  """Optional parameters."""2253022531  http_options: Optional[HttpOptionsDict]22532  """Used to override HTTP request options."""2253322534  expire_time: Optional[datetime.datetime]22535  """An optional time after which, when using the resulting token,22536      messages in Live API sessions will be rejected. (Gemini may22537      preemptively close the session after this time.)2253822539      If not set then this defaults to 30 minutes in the future. If set, this22540      value must be less than 20 hours in the future."""2254122542  new_session_expire_time: Optional[datetime.datetime]22543  """The time after which new Live API sessions using the token22544      resulting from this request will be rejected.2254522546      If not set this defaults to 60 seconds in the future. If set, this value22547      must be less than 20 hours in the future."""2254822549  uses: Optional[int]22550  """The number of times the token can be used. If this value is zero22551      then no limit is applied. Default is 1. Resuming a Live API session does22552      not count as a use."""2255322554  live_connect_constraints: Optional[LiveConnectConstraintsDict]22555  """Configuration specific to Live API connections created using this token."""2255622557  lock_additional_fields: Optional[list[str]]22558  """Additional fields to lock in the effective LiveConnectParameters."""225592256022561CreateAuthTokenConfigOrDict = Union[22562    CreateAuthTokenConfig, CreateAuthTokenConfigDict22563]225642256522566class CreateAuthTokenParameters(_common.BaseModel):22567  """Config for auth_tokens.create parameters."""2256822569  config: Optional[CreateAuthTokenConfig] = Field(22570      default=None, description="""Optional parameters for the request."""22571  )225722257322574class CreateAuthTokenParametersDict(TypedDict, total=False):22575  """Config for auth_tokens.create parameters."""2257622577  config: Optional[CreateAuthTokenConfigDict]22578  """Optional parameters for the request."""225792258022581CreateAuthTokenParametersOrDict = Union[22582    CreateAuthTokenParameters, CreateAuthTokenParametersDict22583]225842258522586class CountTokensResult(_common.BaseModel):22587  """Local tokenizer count tokens result."""2258822589  total_tokens: Optional[int] = Field(22590      default=None, description="""The total number of tokens."""22591  )225922259322594class CountTokensResultDict(TypedDict, total=False):22595  """Local tokenizer count tokens result."""2259622597  total_tokens: Optional[int]22598  """The total number of tokens."""225992260022601CountTokensResultOrDict = Union[CountTokensResult, CountTokensResultDict]226022260322604class ComputeTokensResult(_common.BaseModel):22605  """Local tokenizer compute tokens result."""2260622607  tokens_info: Optional[list[TokensInfo]] = Field(22608      default=None, description="""Lists of tokens info from the input."""22609  )226102261122612class ComputeTokensResultDict(TypedDict, total=False):22613  """Local tokenizer compute tokens result."""2261422615  tokens_info: Optional[list[TokensInfoDict]]22616  """Lists of tokens info from the input."""226172261822619ComputeTokensResultOrDict = Union[ComputeTokensResult, ComputeTokensResultDict]226202262122622class CreateTuningJobParameters(_common.BaseModel):22623  """Fine-tuning job creation parameters - optional fields."""2262422625  base_model: Optional[str] = Field(22626      default=None,22627      description="""The base model that is being tuned, e.g., "gemini-2.5-flash".""",22628  )22629  training_dataset: Optional[TuningDataset] = Field(22630      default=None,22631      description="""Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""",22632  )22633  config: Optional[CreateTuningJobConfig] = Field(22634      default=None, description="""Configuration for the tuning job."""22635  )226362263722638class CreateTuningJobParametersDict(TypedDict, total=False):22639  """Fine-tuning job creation parameters - optional fields."""2264022641  base_model: Optional[str]22642  """The base model that is being tuned, e.g., "gemini-2.5-flash"."""2264322644  training_dataset: Optional[TuningDatasetDict]22645  """Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file."""2264622647  config: Optional[CreateTuningJobConfigDict]22648  """Configuration for the tuning job."""226492265022651CreateTuningJobParametersOrDict = Union[22652    CreateTuningJobParameters, CreateTuningJobParametersDict22653]226542265522656class EmbedContentParameters(_common.BaseModel):22657  """Parameters for the embed_content method."""2265822659  model: Optional[str] = Field(22660      default=None,22661      description="""ID of the model to use. For a list of models, see `Google models22662    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",22663  )22664  contents: Optional[ContentListUnion] = Field(22665      default=None,22666      description="""The content to embed. Only the `parts.text` fields will be counted.22667      """,22668  )22669  config: Optional[EmbedContentConfig] = Field(22670      default=None,22671      description="""Configuration that contains optional parameters.22672      """,22673  )226742267522676class EmbedContentParametersDict(TypedDict, total=False):22677  """Parameters for the embed_content method."""2267822679  model: Optional[str]22680  """ID of the model to use. For a list of models, see `Google models22681    <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""2268222683  contents: Optional[ContentListUnionDict]22684  """The content to embed. Only the `parts.text` fields will be counted.22685      """2268622687  config: Optional[EmbedContentConfigDict]22688  """Configuration that contains optional parameters.22689      """226902269122692EmbedContentParametersOrDict = Union[22693    EmbedContentParameters, EmbedContentParametersDict22694]226952269622697class UserContent(Content):22698  """UserContent facilitates the creation of a Content object with a user role.2269922700  Example usages:227012270222703  - Create a user Content object with a string:22704    user_content = UserContent("Why is the sky blue?")22705  - Create a user Content object with a file data Part object:22706    user_content = UserContent(Part.from_uri(file_uri="gs://bucket/file.txt",22707    mime_type="text/plain"))22708  - Create a user Content object with byte data Part object:22709    user_content = UserContent(Part.from_bytes(data=b"Hello, World!",22710    mime_type="text/plain"))2271122712    You can create a user Content object using other classmethods in the Part22713    class as well.22714    You can also create a user Content using a list of Part objects or strings.22715  """2271622717  role: Literal['user'] = Field(default='user', init=False, frozen=True)22718  parts: list[Part] = Field()2271922720  def __init__(22721      self, parts: Union['PartUnionDict', list['PartUnionDict'], list['Part']]22722  ):22723    from . import _transformers as t2272422725    super().__init__(parts=t.t_parts(parts=parts))227262272722728class ModelContent(Content):22729  """ModelContent facilitates the creation of a Content object with a model role.2273022731  Example usages:2273222733  - Create a model Content object with a string:22734    model_content = ModelContent("Why is the sky blue?")22735  - Create a model Content object with a file data Part object:22736    model_content = ModelContent(Part.from_uri(file_uri="gs://bucket/file.txt",22737    mime_type="text/plain"))22738  - Create a model Content object with byte data Part object:22739    model_content = ModelContent(Part.from_bytes(data=b"Hello, World!",22740    mime_type="text/plain"))2274122742    You can create a model Content object using other classmethods in the Part22743    class as well.22744    You can also create a model Content using a list of Part objects or strings.22745  """2274622747  role: Literal['model'] = Field(default='model', init=False, frozen=True)22748  parts: list[Part] = Field()2274922750  def __init__(22751      self, parts: Union['PartUnionDict', list['PartUnionDict'], list['Part']]22752  ):22753    from . import _transformers as t2275422755    super().__init__(parts=t.t_parts(parts=parts))227562275722758class CustomOutputFormatConfig(_common.BaseModel):22759  """Config for custom output format."""2276022761  return_raw_output: Optional[bool] = Field(22762      default=None, description="""Optional. Whether to return raw output."""22763  )227642276522766class CustomOutputFormatConfigDict(TypedDict, total=False):22767  """Config for custom output format."""2276822769  return_raw_output: Optional[bool]22770  """Optional. Whether to return raw output."""227712277222773CustomOutputFormatConfigOrDict = Union[22774    CustomOutputFormatConfig, CustomOutputFormatConfigDict22775]227762277722778class BleuSpec(_common.BaseModel):22779  """Spec for bleu metric."""2278022781  use_effective_order: Optional[bool] = Field(22782      default=None,22783      description="""Optional. Whether to use_effective_order to compute bleu score.""",22784  )227852278622787class BleuSpecDict(TypedDict, total=False):22788  """Spec for bleu metric."""2278922790  use_effective_order: Optional[bool]22791  """Optional. Whether to use_effective_order to compute bleu score."""227922279322794BleuSpecOrDict = Union[BleuSpec, BleuSpecDict]227952279622797class Metric(_common.BaseModel):22798  """The metric used for evaluation."""2279922800  name: Optional[str] = Field(22801      default=None, description="""The name of the metric."""22802  )22803  custom_function: Optional[Callable[..., Any]] = Field(22804      default=None,22805      description="""The custom function that defines the end-to-end logic for metric computation.""",22806  )22807  prompt_template: Optional[str] = Field(22808      default=None, description="""The prompt template for the metric."""22809  )22810  judge_model_system_instruction: Optional[str] = Field(22811      default=None,22812      description="""The system instruction for the judge model.""",22813  )22814  return_raw_output: Optional[bool] = Field(22815      default=None,22816      description="""Whether to return the raw output from the judge model.""",22817  )22818  parse_and_reduce_fn: Optional[Callable[..., Any]] = Field(22819      default=None,22820      description="""The parse and reduce function for the judge model.""",22821  )22822  aggregate_summary_fn: Optional[Callable[..., Any]] = Field(22823      default=None,22824      description="""The aggregate summary function for the judge model.""",22825  )2282622827  # Allow extra fields to support metric-specific config fields.22828  model_config = ConfigDict(extra='allow')2282922830  _is_predefined: bool = PrivateAttr(default=False)22831  """A boolean indicating whether the metric is predefined."""2283222833  _config_source: Optional[str] = PrivateAttr(default=None)22834  """An optional string indicating the source of the metric configuration."""2283522836  _version: Optional[str] = PrivateAttr(default=None)22837  """An optional string indicating the version of the metric."""2283822839  @model_validator(mode='after')  # type: ignore[arg-type]22840  def validate_name(self) -> 'Metric':22841    if not self.name:22842      raise ValueError('Metric name cannot be empty.')22843    self.name = self.name.lower()22844    return self2284522846  def to_yaml_file(self, file_path: str, version: Optional[str] = None) -> None:22847    """Dumps the metric object to a YAML file.2284822849    Args:22850        file_path: The path to the YAML file.22851        version: Optional version string to include in the YAML output.2285222853    Raises:22854        ImportError: If the pyyaml library is not installed.22855    """22856    try:22857      import yaml22858    except ImportError:22859      raise ImportError(22860          'YAML serialization requires the pyyaml library. Please install'22861          " it using 'pip install google-cloud-aiplatform[evaluation]'."22862      )2286322864    fields_to_exclude_callables = set()22865    for field_name, field_info in self.model_fields.items():22866      annotation = field_info.annotation22867      origin = typing.get_origin(annotation)2286822869      is_field_callable_type = False22870      if annotation is Callable or origin is Callable:  # type: ignore[comparison-overlap]22871        is_field_callable_type = True22872      elif origin is Union:22873        args = typing.get_args(annotation)22874        if any(22875            arg is Callable or typing.get_origin(arg) is Callable22876            for arg in args22877        ):22878          is_field_callable_type = True2287922880      if is_field_callable_type:22881        fields_to_exclude_callables.add(field_name)2288222883    data_to_dump = self.model_dump(22884        exclude_unset=True,22885        exclude_none=True,22886        mode='json',22887        exclude=fields_to_exclude_callables22888        if fields_to_exclude_callables22889        else None,22890    )2289122892    if version:22893      data_to_dump['version'] = version2289422895    with open(file_path, 'w', encoding='utf-8') as f:22896      yaml.dump(data_to_dump, f, sort_keys=False, allow_unicode=True)228972289822899class MetricDict(TypedDict, total=False):22900  """The metric used for evaluation."""2290122902  name: Optional[str]22903  """The name of the metric."""2290422905  custom_function: Optional[Callable[..., Any]]22906  """The custom function that defines the end-to-end logic for metric computation."""2290722908  prompt_template: Optional[str]22909  """The prompt template for the metric."""2291022911  judge_model_system_instruction: Optional[str]22912  """The system instruction for the judge model."""2291322914  return_raw_output: Optional[bool]22915  """Whether to return the raw output from the judge model."""2291622917  parse_and_reduce_fn: Optional[Callable[..., Any]]22918  """The parse and reduce function for the judge model."""2291922920  aggregate_summary_fn: Optional[Callable[..., Any]]22921  """The aggregate summary function for the judge model."""229222292322924MetricOrDict = Union[Metric, MetricDict]229252292622927class PairwiseMetricSpec(_common.BaseModel):22928  """Spec for pairwise metric."""2292922930  metric_prompt_template: Optional[str] = Field(22931      default=None,22932      description="""Required. Metric prompt template for pairwise metric.""",22933  )22934  baseline_response_field_name: Optional[str] = Field(22935      default=None,22936      description="""Optional. The field name of the baseline response.""",22937  )22938  candidate_response_field_name: Optional[str] = Field(22939      default=None,22940      description="""Optional. The field name of the candidate response.""",22941  )22942  custom_output_format_config: Optional[CustomOutputFormatConfig] = Field(22943      default=None,22944      description="""Optional. CustomOutputFormatConfig allows customization of metric output. When this config is set, the default output is replaced with the raw output string. If a custom format is chosen, the `pairwise_choice` and `explanation` fields in the corresponding metric result will be empty.""",22945  )22946  system_instruction: Optional[str] = Field(22947      default=None,22948      description="""Optional. System instructions for pairwise metric.""",22949  )229502295122952class PairwiseMetricSpecDict(TypedDict, total=False):22953  """Spec for pairwise metric."""2295422955  metric_prompt_template: Optional[str]22956  """Required. Metric prompt template for pairwise metric."""2295722958  baseline_response_field_name: Optional[str]22959  """Optional. The field name of the baseline response."""2296022961  candidate_response_field_name: Optional[str]22962  """Optional. The field name of the candidate response."""2296322964  custom_output_format_config: Optional[CustomOutputFormatConfigDict]22965  """Optional. CustomOutputFormatConfig allows customization of metric output. When this config is set, the default output is replaced with the raw output string. If a custom format is chosen, the `pairwise_choice` and `explanation` fields in the corresponding metric result will be empty."""2296622967  system_instruction: Optional[str]22968  """Optional. System instructions for pairwise metric."""229692297022971PairwiseMetricSpecOrDict = Union[PairwiseMetricSpec, PairwiseMetricSpecDict]229722297322974class PointwiseMetricSpec(_common.BaseModel):22975  """Spec for pointwise metric."""2297622977  metric_prompt_template: Optional[str] = Field(22978      default=None,22979      description="""Required. Metric prompt template for pointwise metric.""",22980  )22981  custom_output_format_config: Optional[CustomOutputFormatConfig] = Field(22982      default=None,22983      description="""Optional. CustomOutputFormatConfig allows customization of metric output. By default, metrics return a score and explanation. When this config is set, the default output is replaced with either: - The raw output string. - A parsed output based on a user-defined schema. If a custom format is chosen, the `score` and `explanation` fields in the corresponding metric result will be empty.""",22984  )22985  system_instruction: Optional[str] = Field(22986      default=None,22987      description="""Optional. System instructions for pointwise metric.""",22988  )229892299022991class PointwiseMetricSpecDict(TypedDict, total=False):22992  """Spec for pointwise metric."""2299322994  metric_prompt_template: Optional[str]22995  """Required. Metric prompt template for pointwise metric."""2299622997  custom_output_format_config: Optional[CustomOutputFormatConfigDict]22998  """Optional. CustomOutputFormatConfig allows customization of metric output. By default, metrics return a score and explanation. When this config is set, the default output is replaced with either: - The raw output string. - A parsed output based on a user-defined schema. If a custom format is chosen, the `score` and `explanation` fields in the corresponding metric result will be empty."""2299923000  system_instruction: Optional[str]23001  """Optional. System instructions for pointwise metric."""230022300323004PointwiseMetricSpecOrDict = Union[PointwiseMetricSpec, PointwiseMetricSpecDict]230052300623007class RougeSpec(_common.BaseModel):23008  """Spec for rouge metric."""2300923010  rouge_type: Optional[str] = Field(23011      default=None,23012      description="""Optional. Supported rouge types are rougen[1-9], rougeL, and rougeLsum.""",23013  )23014  split_summaries: Optional[bool] = Field(23015      default=None,23016      description="""Optional. Whether to split summaries while using rougeLsum.""",23017  )23018  use_stemmer: Optional[bool] = Field(23019      default=None,23020      description="""Optional. Whether to use stemmer to compute rouge score.""",23021  )230222302323024class RougeSpecDict(TypedDict, total=False):23025  """Spec for rouge metric."""2302623027  rouge_type: Optional[str]23028  """Optional. Supported rouge types are rougen[1-9], rougeL, and rougeLsum."""2302923030  split_summaries: Optional[bool]23031  """Optional. Whether to split summaries while using rougeLsum."""2303223033  use_stemmer: Optional[bool]23034  """Optional. Whether to use stemmer to compute rouge score."""230352303623037RougeSpecOrDict = Union[RougeSpec, RougeSpecDict]230382303923040class PredefinedMetricSpec(_common.BaseModel):23041  """Spec for predefined metric."""2304223043  metric_spec_name: Optional[str] = Field(23044      default=None,23045      description="""The name of a pre-defined metric, such as "instruction_following_v1" or23046      "text_quality_v1".""",23047  )23048  metric_spec_parameters: Optional[dict[str, Any]] = Field(23049      default=None,23050      description="""The parameters needed to run the pre-defined metric.""",23051  )230522305323054class PredefinedMetricSpecDict(TypedDict, total=False):23055  """Spec for predefined metric."""2305623057  metric_spec_name: Optional[str]23058  """The name of a pre-defined metric, such as "instruction_following_v1" or23059      "text_quality_v1"."""2306023061  metric_spec_parameters: Optional[dict[str, Any]]23062  """The parameters needed to run the pre-defined metric."""230632306423065PredefinedMetricSpecOrDict = Union[23066    PredefinedMetricSpec, PredefinedMetricSpecDict23067]230682306923070class RubricGenerationSpec(_common.BaseModel):23071  """Specification for how rubrics should be generated."""2307223073  prompt_template: Optional[str] = Field(23074      default=None,23075      description="""Template for the prompt used to generate rubrics.""",23076  )23077  rubric_content_type: Optional[RubricContentType] = Field(23078      default=None,23079      description="""The type of rubric content to be generated.""",23080  )23081  rubric_type_ontology: Optional[list[str]] = Field(23082      default=None,23083      description="""An optional, pre-defined list of allowed types for generated rubrics.23084      If this field is provided, it implies `include_rubric_type` should be true,23085      and the generated rubric types should be chosen from this ontology.""",23086  )230872308823089class RubricGenerationSpecDict(TypedDict, total=False):23090  """Specification for how rubrics should be generated."""2309123092  prompt_template: Optional[str]23093  """Template for the prompt used to generate rubrics."""2309423095  rubric_content_type: Optional[RubricContentType]23096  """The type of rubric content to be generated."""2309723098  rubric_type_ontology: Optional[list[str]]23099  """An optional, pre-defined list of allowed types for generated rubrics.23100      If this field is provided, it implies `include_rubric_type` should be true,23101      and the generated rubric types should be chosen from this ontology."""231022310323104RubricGenerationSpecOrDict = Union[23105    RubricGenerationSpec, RubricGenerationSpecDict23106]231072310823109class EvaluationParserConfigCustomCodeParserConfig(_common.BaseModel):23110  """Configuration for parsing the LLM response using custom code.2311123112  This data type is not supported in Gemini API.23113  """2311423115  parsing_function: Optional[str] = Field(23116      default=None,23117      description="""Required. Python function for parsing results. The function should be defined within this string. The function takes a list of strings (LLM responses) and should return either a list of dictionaries (for rubrics) or a single dictionary (for a metric result). Example function signature: def parse(responses: list[str]) -> list[dict[str, Any]] | dict[str, Any]: When parsing rubrics, return a list of dictionaries, where each dictionary represents a Rubric. Example for rubrics: [ { "content": {"property": {"description": "The response is factual."}}, "type": "FACTUALITY", "importance": "HIGH" }, { "content": {"property": {"description": "The response is fluent."}}, "type": "FLUENCY", "importance": "MEDIUM" } ] When parsing critique results, return a dictionary representing a MetricResult. Example for a metric result: { "score": 0.8, "explanation": "The model followed most instructions.", "rubric_verdicts": [...] } ... code for result extraction and aggregation""",23118  )23119  code_execution_region: Optional[str] = Field(23120      default=None,23121      description="""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used.""",23122  )231232312423125class EvaluationParserConfigCustomCodeParserConfigDict(TypedDict, total=False):23126  """Configuration for parsing the LLM response using custom code.2312723128  This data type is not supported in Gemini API.23129  """2313023131  parsing_function: Optional[str]23132  """Required. Python function for parsing results. The function should be defined within this string. The function takes a list of strings (LLM responses) and should return either a list of dictionaries (for rubrics) or a single dictionary (for a metric result). Example function signature: def parse(responses: list[str]) -> list[dict[str, Any]] | dict[str, Any]: When parsing rubrics, return a list of dictionaries, where each dictionary represents a Rubric. Example for rubrics: [ { "content": {"property": {"description": "The response is factual."}}, "type": "FACTUALITY", "importance": "HIGH" }, { "content": {"property": {"description": "The response is fluent."}}, "type": "FLUENCY", "importance": "MEDIUM" } ] When parsing critique results, return a dictionary representing a MetricResult. Example for a metric result: { "score": 0.8, "explanation": "The model followed most instructions.", "rubric_verdicts": [...] } ... code for result extraction and aggregation"""2313323134  code_execution_region: Optional[str]23135  """Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used."""231362313723138EvaluationParserConfigCustomCodeParserConfigOrDict = Union[23139    EvaluationParserConfigCustomCodeParserConfig,23140    EvaluationParserConfigCustomCodeParserConfigDict,23141]231422314323144class EvaluationParserConfig(_common.BaseModel):23145  """Config for parsing LLM responses.2314623147  It can be used to parse the LLM response to be evaluated, or the LLM response23148  from LLM-based metrics/Autoraters. This data type is not supported in Gemini23149  API.23150  """2315123152  custom_code_parser_config: Optional[23153      EvaluationParserConfigCustomCodeParserConfig23154  ] = Field(23155      default=None,23156      description="""Optional. Use custom code to parse the LLM response.""",23157  )231582315923160class EvaluationParserConfigDict(TypedDict, total=False):23161  """Config for parsing LLM responses.2316223163  It can be used to parse the LLM response to be evaluated, or the LLM response23164  from LLM-based metrics/Autoraters. This data type is not supported in Gemini23165  API.23166  """2316723168  custom_code_parser_config: Optional[23169      EvaluationParserConfigCustomCodeParserConfigDict23170  ]23171  """Optional. Use custom code to parse the LLM response."""231722317323174EvaluationParserConfigOrDict = Union[23175    EvaluationParserConfig, EvaluationParserConfigDict23176]231772317823179class LLMBasedMetricSpec(_common.BaseModel):23180  """Specification for an LLM based metric."""2318123182  metric_prompt_template: Optional[str] = Field(23183      default=None,23184      description="""Template for the prompt sent to the judge model.""",23185  )23186  system_instruction: Optional[str] = Field(23187      default=None, description="""System instruction for the judge model."""23188  )23189  judge_autorater_config: Optional[AutoraterConfig] = Field(23190      default=None,23191      description="""Optional configuration for the judge LLM (Autorater).""",23192  )23193  rubric_group_key: Optional[str] = Field(23194      default=None,23195      description="""Use a pre-defined group of rubrics associated with the input.23196      Refers to a key in the rubric_groups map of EvaluationInstance.""",23197  )23198  predefined_rubric_generation_spec: Optional[PredefinedMetricSpec] = Field(23199      default=None,23200      description="""Dynamically generate rubrics using a predefined spec.""",23201  )23202  rubric_generation_spec: Optional[RubricGenerationSpec] = Field(23203      default=None,23204      description="""Dynamically generate rubrics using this specification.""",23205  )23206  additional_config: Optional[dict[str, Any]] = Field(23207      default=None,23208      description="""Optional. Optional additional configuration for the metric.""",23209  )23210  result_parser_config: Optional[EvaluationParserConfig] = Field(23211      default=None,23212      description="""Optional. The parser config for the metric result.""",23213  )232142321523216class LLMBasedMetricSpecDict(TypedDict, total=False):23217  """Specification for an LLM based metric."""2321823219  metric_prompt_template: Optional[str]23220  """Template for the prompt sent to the judge model."""2322123222  system_instruction: Optional[str]23223  """System instruction for the judge model."""2322423225  judge_autorater_config: Optional[AutoraterConfigDict]23226  """Optional configuration for the judge LLM (Autorater)."""2322723228  rubric_group_key: Optional[str]23229  """Use a pre-defined group of rubrics associated with the input.23230      Refers to a key in the rubric_groups map of EvaluationInstance."""2323123232  predefined_rubric_generation_spec: Optional[PredefinedMetricSpecDict]23233  """Dynamically generate rubrics using a predefined spec."""2323423235  rubric_generation_spec: Optional[RubricGenerationSpecDict]23236  """Dynamically generate rubrics using this specification."""2323723238  additional_config: Optional[dict[str, Any]]23239  """Optional. Optional additional configuration for the metric."""2324023241  result_parser_config: Optional[EvaluationParserConfigDict]23242  """Optional. The parser config for the metric result."""232432324423245LLMBasedMetricSpecOrDict = Union[LLMBasedMetricSpec, LLMBasedMetricSpecDict]232462324723248class CustomCodeExecutionSpec(_common.BaseModel):23249  """Specifies a metric that is computed by running user-defined Python functions remotely."""2325023251  evaluation_function: Optional[str] = Field(23252      default=None,23253      description="""A string representing a user-defined function for evaluation.23254  Expected user to define the following function, e.g.:23255    def evaluate(instance: dict[str, Any]) -> float:23256  Please include this function signature in the code snippet.23257  Instance is the evaluation instance, any fields populated in the instance23258  are available to the function as instance[field_name].""",23259  )23260  code_execution_region: Optional[str] = Field(23261      default=None,23262      description="""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED.""",23263  )232642326523266class CustomCodeExecutionSpecDict(TypedDict, total=False):23267  """Specifies a metric that is computed by running user-defined Python functions remotely."""2326823269  evaluation_function: Optional[str]23270  """A string representing a user-defined function for evaluation.23271  Expected user to define the following function, e.g.:23272    def evaluate(instance: dict[str, Any]) -> float:23273  Please include this function signature in the code snippet.23274  Instance is the evaluation instance, any fields populated in the instance23275  are available to the function as instance[field_name]."""2327623277  code_execution_region: Optional[str]23278  """Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED."""232792328023281CustomCodeExecutionSpecOrDict = Union[23282    CustomCodeExecutionSpec, CustomCodeExecutionSpecDict23283]232842328523286class ComputationBasedMetricSpec(_common.BaseModel):23287  """Specification for a computation based metric."""2328823289  type: Optional[ComputationBasedMetricType] = Field(23290      default=None, description="""The type of the computation based metric."""23291  )23292  parameters: Optional[dict[str, Any]] = Field(23293      default=None,23294      description="""A map of parameters for the metric. ROUGE example: {"rouge_type": "rougeL", "split_summaries": True, "use_stemmer": True}. BLEU example: {"use_effective_order": True}.""",23295  )232962329723298class ComputationBasedMetricSpecDict(TypedDict, total=False):23299  """Specification for a computation based metric."""2330023301  type: Optional[ComputationBasedMetricType]23302  """The type of the computation based metric."""2330323304  parameters: Optional[dict[str, Any]]23305  """A map of parameters for the metric. ROUGE example: {"rouge_type": "rougeL", "split_summaries": True, "use_stemmer": True}. BLEU example: {"use_effective_order": True}."""233062330723308ComputationBasedMetricSpecOrDict = Union[23309    ComputationBasedMetricSpec, ComputationBasedMetricSpecDict23310]233112331223313class UnifiedMetric(_common.BaseModel):23314  """The unified metric used for evaluation."""2331523316  bleu_spec: Optional[BleuSpec] = Field(23317      default=None, description="""The Bleu metric spec."""23318  )23319  rouge_spec: Optional[RougeSpec] = Field(23320      default=None, description="""The rouge metric spec."""23321  )23322  pointwise_metric_spec: Optional[PointwiseMetricSpec] = Field(23323      default=None, description="""The pointwise metric spec."""23324  )23325  llm_based_metric_spec: Optional[LLMBasedMetricSpec] = Field(23326      default=None, description="""The spec for an LLM based metric."""23327  )23328  custom_code_execution_spec: Optional[CustomCodeExecutionSpec] = Field(23329      default=None,23330      description="""The spec for a custom code execution metric.""",23331  )23332  predefined_metric_spec: Optional[PredefinedMetricSpec] = Field(23333      default=None, description="""The spec for a pre-defined metric."""23334  )23335  computation_based_metric_spec: Optional[ComputationBasedMetricSpec] = Field(23336      default=None, description="""The spec for a computation based metric."""23337  )233382333923340class UnifiedMetricDict(TypedDict, total=False):23341  """The unified metric used for evaluation."""2334223343  bleu_spec: Optional[BleuSpecDict]23344  """The Bleu metric spec."""2334523346  rouge_spec: Optional[RougeSpecDict]23347  """The rouge metric spec."""2334823349  pointwise_metric_spec: Optional[PointwiseMetricSpecDict]23350  """The pointwise metric spec."""2335123352  llm_based_metric_spec: Optional[LLMBasedMetricSpecDict]23353  """The spec for an LLM based metric."""2335423355  custom_code_execution_spec: Optional[CustomCodeExecutionSpecDict]23356  """The spec for a custom code execution metric."""2335723358  predefined_metric_spec: Optional[PredefinedMetricSpecDict]23359  """The spec for a pre-defined metric."""2336023361  computation_based_metric_spec: Optional[ComputationBasedMetricSpecDict]23362  """The spec for a computation based metric."""233632336423365UnifiedMetricOrDict = Union[UnifiedMetric, UnifiedMetricDict]233662336723368class UploadToFileSearchStoreResponse(_common.BaseModel):23369  """The response when long-running operation for uploading a file to a FileSearchStore complete."""2337023371  sdk_http_response: Optional[HttpResponse] = Field(23372      default=None, description="""Used to retain the full HTTP response."""23373  )23374  parent: Optional[str] = Field(23375      default=None,23376      description="""The name of the FileSearchStore containing Documents.""",23377  )23378  document_name: Optional[str] = Field(23379      default=None, description="""The identifier for the Document imported."""23380  )233812338223383class UploadToFileSearchStoreResponseDict(TypedDict, total=False):23384  """The response when long-running operation for uploading a file to a FileSearchStore complete."""2338523386  sdk_http_response: Optional[HttpResponseDict]23387  """Used to retain the full HTTP response."""2338823389  parent: Optional[str]23390  """The name of the FileSearchStore containing Documents."""2339123392  document_name: Optional[str]23393  """The identifier for the Document imported."""233942339523396UploadToFileSearchStoreResponseOrDict = Union[23397    UploadToFileSearchStoreResponse, UploadToFileSearchStoreResponseDict23398]233992340023401class UploadToFileSearchStoreOperation(_common.BaseModel, Operation):23402  """Long-running operation for uploading a file to a FileSearchStore."""2340323404  response: Optional[UploadToFileSearchStoreResponse] = Field(23405      default=None,23406      description="""The result of the UploadToFileSearchStore operation, available when the operation is done.""",23407  )2340823409  @classmethod23410  def from_api_response(23411      cls, api_response: Any, is_vertex_ai: bool = False23412  ) -> Self:23413    """Instantiates a UploadToFileSearchStoreOperation from an API response."""2341423415    response_dict = _UploadToFileSearchStoreOperation_from_mldev(api_response)23416    return cls._from_response(response=response_dict, kwargs={})234172341823419class DownloadMediaConfig(_common.BaseModel):23420  """Used to override the default configuration."""2342123422  http_options: Optional[HttpOptions] = Field(23423      default=None, description="""Used to override HTTP request options."""23424  )234252342623427class DownloadMediaConfigDict(TypedDict, total=False):23428  """Used to override the default configuration."""2342923430  http_options: Optional[HttpOptionsDict]23431  """Used to override HTTP request options."""234322343323434DownloadMediaConfigOrDict = Union[DownloadMediaConfig, DownloadMediaConfigDict]23435