google-genai 1.29.0__py3-none-any.whl → 1.30.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
google/genai/types.py CHANGED
@@ -26,7 +26,7 @@ import types as builtin_types
26
26
  import typing
27
27
  from typing import Any, Callable, Literal, Optional, Sequence, Union, _UnionGenericAlias # type: ignore
28
28
  import pydantic
29
- from pydantic import Field
29
+ from pydantic import ConfigDict, Field, PrivateAttr, model_validator
30
30
  from typing_extensions import Self, TypedDict
31
31
  from . import _common
32
32
 
@@ -76,10 +76,20 @@ else:
76
76
  McpClientSession = None
77
77
  McpCallToolResult = None
78
78
 
79
+ if typing.TYPE_CHECKING:
80
+ import yaml
81
+ else:
82
+ try:
83
+ import yaml
84
+ except ImportError:
85
+ yaml = None
86
+
79
87
  logger = logging.getLogger('google_genai.types')
80
88
 
81
89
  T = typing.TypeVar('T', bound='GenerateContentResponse')
82
90
 
91
+ MetricSubclass = typing.TypeVar('MetricSubclass', bound='Metric')
92
+
83
93
 
84
94
  class Outcome(_common.CaseInSensitiveEnum):
85
95
  """Required. Outcome of the code execution."""
@@ -223,15 +233,6 @@ class ApiSpec(_common.CaseInSensitiveEnum):
223
233
  """Elastic search API spec."""
224
234
 
225
235
 
226
- class Environment(_common.CaseInSensitiveEnum):
227
- """Required. The environment being operated."""
228
-
229
- ENVIRONMENT_UNSPECIFIED = 'ENVIRONMENT_UNSPECIFIED'
230
- """Defaults to browser."""
231
- ENVIRONMENT_BROWSER = 'ENVIRONMENT_BROWSER'
232
- """Operates in a web browser."""
233
-
234
-
235
236
  class UrlRetrievalStatus(_common.CaseInSensitiveEnum):
236
237
  """Status of the url retrieval."""
237
238
 
@@ -398,6 +399,17 @@ class JobState(_common.CaseInSensitiveEnum):
398
399
  """The job is partially succeeded, some results may be missing due to errors."""
399
400
 
400
401
 
402
+ class TuningMode(_common.CaseInSensitiveEnum):
403
+ """Tuning mode."""
404
+
405
+ TUNING_MODE_UNSPECIFIED = 'TUNING_MODE_UNSPECIFIED'
406
+ """Tuning mode is unspecified."""
407
+ TUNING_MODE_FULL = 'TUNING_MODE_FULL'
408
+ """Full fine-tuning mode."""
409
+ TUNING_MODE_PEFT_ADAPTER = 'TUNING_MODE_PEFT_ADAPTER'
410
+ """PEFT adapter tuning mode."""
411
+
412
+
401
413
  class AdapterSize(_common.CaseInSensitiveEnum):
402
414
  """Optional. Adapter size for tuning."""
403
415
 
@@ -448,6 +460,15 @@ class DynamicRetrievalConfigMode(_common.CaseInSensitiveEnum):
448
460
  """Run retrieval only when system decides it is necessary."""
449
461
 
450
462
 
463
+ class Environment(_common.CaseInSensitiveEnum):
464
+ """The environment being operated."""
465
+
466
+ ENVIRONMENT_UNSPECIFIED = 'ENVIRONMENT_UNSPECIFIED'
467
+ """Defaults to browser."""
468
+ ENVIRONMENT_BROWSER = 'ENVIRONMENT_BROWSER'
469
+ """Operates in a web browser."""
470
+
471
+
451
472
  class FunctionCallingConfigMode(_common.CaseInSensitiveEnum):
452
473
  """Config for the function calling config mode."""
453
474
 
@@ -2237,7 +2258,16 @@ class FunctionDeclaration(_common.BaseModel):
2237
2258
  callable: Callable[..., Any],
2238
2259
  behavior: Optional[Behavior] = None,
2239
2260
  ) -> 'FunctionDeclaration':
2240
- """Converts a Callable to a FunctionDeclaration based on the client."""
2261
+ """Converts a Callable to a FunctionDeclaration based on the client.
2262
+
2263
+ Note: For best results prefer
2264
+ [Google-style
2265
+ docstring](https://google.github.io/styleguide/pyguide.html#383-functions-and-methods)
2266
+ when describing arguments. This function does **not** parse argument
2267
+ descriptions into the property description slots of the resulting structure.
2268
+ Instead it sends the whole docstring in the top-level function description.
2269
+ Google-style docstring are closest to what the model is trained on.
2270
+ """
2241
2271
  if client.vertexai:
2242
2272
  return cls.from_callable_with_api_option(
2243
2273
  callable=callable, api_option='VERTEX_AI', behavior=behavior
@@ -2325,6 +2355,11 @@ class GoogleSearch(_common.BaseModel):
2325
2355
  If customers set a start time, they must set an end time (and vice versa).
2326
2356
  """,
2327
2357
  )
2358
+ exclude_domains: Optional[list[str]] = Field(
2359
+ default=None,
2360
+ description="""Optional. List of domains to be excluded from the search results.
2361
+ The default limit is 2000 domains.""",
2362
+ )
2328
2363
 
2329
2364
 
2330
2365
  class GoogleSearchDict(TypedDict, total=False):
@@ -2335,6 +2370,10 @@ class GoogleSearchDict(TypedDict, total=False):
2335
2370
  If customers set a start time, they must set an end time (and vice versa).
2336
2371
  """
2337
2372
 
2373
+ exclude_domains: Optional[list[str]]
2374
+ """Optional. List of domains to be excluded from the search results.
2375
+ The default limit is 2000 domains."""
2376
+
2338
2377
 
2339
2378
  GoogleSearchOrDict = Union[GoogleSearch, GoogleSearchDict]
2340
2379
 
@@ -2391,13 +2430,17 @@ GoogleSearchRetrievalOrDict = Union[
2391
2430
  class EnterpriseWebSearch(_common.BaseModel):
2392
2431
  """Tool to search public web data, powered by Vertex AI Search and Sec4 compliance."""
2393
2432
 
2394
- pass
2433
+ exclude_domains: Optional[list[str]] = Field(
2434
+ default=None,
2435
+ description="""Optional. List of domains to be excluded from the search results. The default limit is 2000 domains.""",
2436
+ )
2395
2437
 
2396
2438
 
2397
2439
  class EnterpriseWebSearchDict(TypedDict, total=False):
2398
2440
  """Tool to search public web data, powered by Vertex AI Search and Sec4 compliance."""
2399
2441
 
2400
- pass
2442
+ exclude_domains: Optional[list[str]]
2443
+ """Optional. List of domains to be excluded from the search results. The default limit is 2000 domains."""
2401
2444
 
2402
2445
 
2403
2446
  EnterpriseWebSearchOrDict = Union[EnterpriseWebSearch, EnterpriseWebSearchDict]
@@ -2607,6 +2650,24 @@ class UrlContextDict(TypedDict, total=False):
2607
2650
  UrlContextOrDict = Union[UrlContext, UrlContextDict]
2608
2651
 
2609
2652
 
2653
+ class ToolComputerUse(_common.BaseModel):
2654
+ """Tool to support computer use."""
2655
+
2656
+ environment: Optional[Environment] = Field(
2657
+ default=None, description="""Required. The environment being operated."""
2658
+ )
2659
+
2660
+
2661
+ class ToolComputerUseDict(TypedDict, total=False):
2662
+ """Tool to support computer use."""
2663
+
2664
+ environment: Optional[Environment]
2665
+ """Required. The environment being operated."""
2666
+
2667
+
2668
+ ToolComputerUseOrDict = Union[ToolComputerUse, ToolComputerUseDict]
2669
+
2670
+
2610
2671
  class ApiAuthApiKeyConfig(_common.BaseModel):
2611
2672
  """The API secret."""
2612
2673
 
@@ -3167,24 +3228,6 @@ class ToolCodeExecutionDict(TypedDict, total=False):
3167
3228
  ToolCodeExecutionOrDict = Union[ToolCodeExecution, ToolCodeExecutionDict]
3168
3229
 
3169
3230
 
3170
- class ToolComputerUse(_common.BaseModel):
3171
- """Tool to support computer use."""
3172
-
3173
- environment: Optional[Environment] = Field(
3174
- default=None, description="""Required. The environment being operated."""
3175
- )
3176
-
3177
-
3178
- class ToolComputerUseDict(TypedDict, total=False):
3179
- """Tool to support computer use."""
3180
-
3181
- environment: Optional[Environment]
3182
- """Required. The environment being operated."""
3183
-
3184
-
3185
- ToolComputerUseOrDict = Union[ToolComputerUse, ToolComputerUseDict]
3186
-
3187
-
3188
3231
  class Tool(_common.BaseModel):
3189
3232
  """Tool details of a tool that the model may use to generate a response."""
3190
3233
 
@@ -3219,13 +3262,15 @@ class Tool(_common.BaseModel):
3219
3262
  default=None,
3220
3263
  description="""Optional. Tool to support URL context retrieval.""",
3221
3264
  )
3222
- code_execution: Optional[ToolCodeExecution] = Field(
3265
+ computer_use: Optional[ToolComputerUse] = Field(
3223
3266
  default=None,
3224
- description="""Optional. CodeExecution tool type. Enables the model to execute code as part of generation.""",
3267
+ description="""Optional. Tool to support the model interacting directly with the
3268
+ computer. If enabled, it automatically populates computer-use specific
3269
+ Function Declarations.""",
3225
3270
  )
3226
- computer_use: Optional[ToolComputerUse] = Field(
3271
+ code_execution: Optional[ToolCodeExecution] = Field(
3227
3272
  default=None,
3228
- description="""Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.""",
3273
+ description="""Optional. CodeExecution tool type. Enables the model to execute code as part of generation.""",
3229
3274
  )
3230
3275
 
3231
3276
 
@@ -3256,12 +3301,14 @@ class ToolDict(TypedDict, total=False):
3256
3301
  url_context: Optional[UrlContextDict]
3257
3302
  """Optional. Tool to support URL context retrieval."""
3258
3303
 
3304
+ computer_use: Optional[ToolComputerUseDict]
3305
+ """Optional. Tool to support the model interacting directly with the
3306
+ computer. If enabled, it automatically populates computer-use specific
3307
+ Function Declarations."""
3308
+
3259
3309
  code_execution: Optional[ToolCodeExecutionDict]
3260
3310
  """Optional. CodeExecution tool type. Enables the model to execute code as part of generation."""
3261
3311
 
3262
- computer_use: Optional[ToolComputerUseDict]
3263
- """Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations."""
3264
-
3265
3312
 
3266
3313
  ToolOrDict = Union[Tool, ToolDict]
3267
3314
  if _is_mcp_imported:
@@ -4485,6 +4532,171 @@ class UrlContextMetadataDict(TypedDict, total=False):
4485
4532
  UrlContextMetadataOrDict = Union[UrlContextMetadata, UrlContextMetadataDict]
4486
4533
 
4487
4534
 
4535
+ class GroundingChunkMapsPlaceAnswerSourcesAuthorAttribution(_common.BaseModel):
4536
+ """Author attribution for a photo or review."""
4537
+
4538
+ display_name: Optional[str] = Field(
4539
+ default=None, description="""Name of the author of the Photo or Review."""
4540
+ )
4541
+ photo_uri: Optional[str] = Field(
4542
+ default=None,
4543
+ description="""Profile photo URI of the author of the Photo or Review.""",
4544
+ )
4545
+ uri: Optional[str] = Field(
4546
+ default=None, description="""URI of the author of the Photo or Review."""
4547
+ )
4548
+
4549
+
4550
+ class GroundingChunkMapsPlaceAnswerSourcesAuthorAttributionDict(
4551
+ TypedDict, total=False
4552
+ ):
4553
+ """Author attribution for a photo or review."""
4554
+
4555
+ display_name: Optional[str]
4556
+ """Name of the author of the Photo or Review."""
4557
+
4558
+ photo_uri: Optional[str]
4559
+ """Profile photo URI of the author of the Photo or Review."""
4560
+
4561
+ uri: Optional[str]
4562
+ """URI of the author of the Photo or Review."""
4563
+
4564
+
4565
+ GroundingChunkMapsPlaceAnswerSourcesAuthorAttributionOrDict = Union[
4566
+ GroundingChunkMapsPlaceAnswerSourcesAuthorAttribution,
4567
+ GroundingChunkMapsPlaceAnswerSourcesAuthorAttributionDict,
4568
+ ]
4569
+
4570
+
4571
+ class GroundingChunkMapsPlaceAnswerSourcesReviewSnippet(_common.BaseModel):
4572
+ """Encapsulates a review snippet."""
4573
+
4574
+ author_attribution: Optional[
4575
+ GroundingChunkMapsPlaceAnswerSourcesAuthorAttribution
4576
+ ] = Field(default=None, description="""This review's author.""")
4577
+ flag_content_uri: Optional[str] = Field(
4578
+ default=None,
4579
+ description="""A link where users can flag a problem with the review.""",
4580
+ )
4581
+ google_maps_uri: Optional[str] = Field(
4582
+ default=None, description="""A link to show the review on Google Maps."""
4583
+ )
4584
+ relative_publish_time_description: Optional[str] = Field(
4585
+ default=None,
4586
+ 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.""",
4587
+ )
4588
+ review: Optional[str] = Field(
4589
+ default=None,
4590
+ description="""A reference representing this place review which may be used to look up this place review again.""",
4591
+ )
4592
+
4593
+
4594
+ class GroundingChunkMapsPlaceAnswerSourcesReviewSnippetDict(
4595
+ TypedDict, total=False
4596
+ ):
4597
+ """Encapsulates a review snippet."""
4598
+
4599
+ author_attribution: Optional[
4600
+ GroundingChunkMapsPlaceAnswerSourcesAuthorAttributionDict
4601
+ ]
4602
+ """This review's author."""
4603
+
4604
+ flag_content_uri: Optional[str]
4605
+ """A link where users can flag a problem with the review."""
4606
+
4607
+ google_maps_uri: Optional[str]
4608
+ """A link to show the review on Google Maps."""
4609
+
4610
+ relative_publish_time_description: Optional[str]
4611
+ """A string of formatted recent time, expressing the review time relative to the current time in a form appropriate for the language and country."""
4612
+
4613
+ review: Optional[str]
4614
+ """A reference representing this place review which may be used to look up this place review again."""
4615
+
4616
+
4617
+ GroundingChunkMapsPlaceAnswerSourcesReviewSnippetOrDict = Union[
4618
+ GroundingChunkMapsPlaceAnswerSourcesReviewSnippet,
4619
+ GroundingChunkMapsPlaceAnswerSourcesReviewSnippetDict,
4620
+ ]
4621
+
4622
+
4623
+ class GroundingChunkMapsPlaceAnswerSources(_common.BaseModel):
4624
+ """Sources used to generate the place answer."""
4625
+
4626
+ flag_content_uri: Optional[str] = Field(
4627
+ default=None,
4628
+ description="""A link where users can flag a problem with the generated answer.""",
4629
+ )
4630
+ review_snippets: Optional[
4631
+ list[GroundingChunkMapsPlaceAnswerSourcesReviewSnippet]
4632
+ ] = Field(
4633
+ default=None,
4634
+ description="""Snippets of reviews that are used to generate the answer.""",
4635
+ )
4636
+
4637
+
4638
+ class GroundingChunkMapsPlaceAnswerSourcesDict(TypedDict, total=False):
4639
+ """Sources used to generate the place answer."""
4640
+
4641
+ flag_content_uri: Optional[str]
4642
+ """A link where users can flag a problem with the generated answer."""
4643
+
4644
+ review_snippets: Optional[
4645
+ list[GroundingChunkMapsPlaceAnswerSourcesReviewSnippetDict]
4646
+ ]
4647
+ """Snippets of reviews that are used to generate the answer."""
4648
+
4649
+
4650
+ GroundingChunkMapsPlaceAnswerSourcesOrDict = Union[
4651
+ GroundingChunkMapsPlaceAnswerSources,
4652
+ GroundingChunkMapsPlaceAnswerSourcesDict,
4653
+ ]
4654
+
4655
+
4656
+ class GroundingChunkMaps(_common.BaseModel):
4657
+ """Chunk from Google Maps."""
4658
+
4659
+ place_answer_sources: Optional[GroundingChunkMapsPlaceAnswerSources] = Field(
4660
+ default=None,
4661
+ description="""Sources used to generate the place answer. This includes review snippets and photos that were used to generate the answer, as well as uris to flag content.""",
4662
+ )
4663
+ place_id: Optional[str] = Field(
4664
+ default=None,
4665
+ description="""This Place's resource name, in `places/{place_id}` format. Can be used to look up the Place.""",
4666
+ )
4667
+ text: Optional[str] = Field(
4668
+ default=None, description="""Text of the chunk."""
4669
+ )
4670
+ title: Optional[str] = Field(
4671
+ default=None, description="""Title of the chunk."""
4672
+ )
4673
+ uri: Optional[str] = Field(
4674
+ default=None, description="""URI reference of the chunk."""
4675
+ )
4676
+
4677
+
4678
+ class GroundingChunkMapsDict(TypedDict, total=False):
4679
+ """Chunk from Google Maps."""
4680
+
4681
+ place_answer_sources: Optional[GroundingChunkMapsPlaceAnswerSourcesDict]
4682
+ """Sources used to generate the place answer. This includes review snippets and photos that were used to generate the answer, as well as uris to flag content."""
4683
+
4684
+ place_id: Optional[str]
4685
+ """This Place's resource name, in `places/{place_id}` format. Can be used to look up the Place."""
4686
+
4687
+ text: Optional[str]
4688
+ """Text of the chunk."""
4689
+
4690
+ title: Optional[str]
4691
+ """Title of the chunk."""
4692
+
4693
+ uri: Optional[str]
4694
+ """URI reference of the chunk."""
4695
+
4696
+
4697
+ GroundingChunkMapsOrDict = Union[GroundingChunkMaps, GroundingChunkMapsDict]
4698
+
4699
+
4488
4700
  class RagChunkPageSpan(_common.BaseModel):
4489
4701
  """Represents where the chunk starts and ends in the document."""
4490
4702
 
@@ -4539,6 +4751,10 @@ RagChunkOrDict = Union[RagChunk, RagChunkDict]
4539
4751
  class GroundingChunkRetrievedContext(_common.BaseModel):
4540
4752
  """Chunk from context retrieved by the retrieval tools."""
4541
4753
 
4754
+ document_name: Optional[str] = Field(
4755
+ default=None,
4756
+ description="""Output only. The full document name for the referenced Vertex AI Search document.""",
4757
+ )
4542
4758
  rag_chunk: Optional[RagChunk] = Field(
4543
4759
  default=None,
4544
4760
  description="""Additional context for the RAG retrieval result. This is only populated when using the RAG retrieval tool.""",
@@ -4557,6 +4773,9 @@ class GroundingChunkRetrievedContext(_common.BaseModel):
4557
4773
  class GroundingChunkRetrievedContextDict(TypedDict, total=False):
4558
4774
  """Chunk from context retrieved by the retrieval tools."""
4559
4775
 
4776
+ document_name: Optional[str]
4777
+ """Output only. The full document name for the referenced Vertex AI Search document."""
4778
+
4560
4779
  rag_chunk: Optional[RagChunkDict]
4561
4780
  """Additional context for the RAG retrieval result. This is only populated when using the RAG retrieval tool."""
4562
4781
 
@@ -4608,6 +4827,9 @@ GroundingChunkWebOrDict = Union[GroundingChunkWeb, GroundingChunkWebDict]
4608
4827
  class GroundingChunk(_common.BaseModel):
4609
4828
  """Grounding chunk."""
4610
4829
 
4830
+ maps: Optional[GroundingChunkMaps] = Field(
4831
+ default=None, description="""Grounding chunk from Google Maps."""
4832
+ )
4611
4833
  retrieved_context: Optional[GroundingChunkRetrievedContext] = Field(
4612
4834
  default=None,
4613
4835
  description="""Grounding chunk from context retrieved by the retrieval tools.""",
@@ -4620,6 +4842,9 @@ class GroundingChunk(_common.BaseModel):
4620
4842
  class GroundingChunkDict(TypedDict, total=False):
4621
4843
  """Grounding chunk."""
4622
4844
 
4845
+ maps: Optional[GroundingChunkMapsDict]
4846
+ """Grounding chunk from Google Maps."""
4847
+
4623
4848
  retrieved_context: Optional[GroundingChunkRetrievedContextDict]
4624
4849
  """Grounding chunk from context retrieved by the retrieval tools."""
4625
4850
 
@@ -4751,6 +4976,10 @@ SearchEntryPointOrDict = Union[SearchEntryPoint, SearchEntryPointDict]
4751
4976
  class GroundingMetadata(_common.BaseModel):
4752
4977
  """Metadata returned to client when grounding is enabled."""
4753
4978
 
4979
+ google_maps_widget_context_token: Optional[str] = Field(
4980
+ default=None,
4981
+ description="""Optional. Output only. Resource name of the Google Maps widget context token to be used with the PlacesContextElement widget to render contextual data. This is populated only for Google Maps grounding.""",
4982
+ )
4754
4983
  grounding_chunks: Optional[list[GroundingChunk]] = Field(
4755
4984
  default=None,
4756
4985
  description="""List of supporting references retrieved from specified grounding source.""",
@@ -4778,6 +5007,9 @@ class GroundingMetadata(_common.BaseModel):
4778
5007
  class GroundingMetadataDict(TypedDict, total=False):
4779
5008
  """Metadata returned to client when grounding is enabled."""
4780
5009
 
5010
+ google_maps_widget_context_token: Optional[str]
5011
+ """Optional. Output only. Resource name of the Google Maps widget context token to be used with the PlacesContextElement widget to render contextual data. This is populated only for Google Maps grounding."""
5012
+
4781
5013
  grounding_chunks: Optional[list[GroundingChunkDict]]
4782
5014
  """List of supporting references retrieved from specified grounding source."""
4783
5015
 
@@ -7437,7 +7669,7 @@ class GenerationConfigThinkingConfig(_common.BaseModel):
7437
7669
  )
7438
7670
  thinking_budget: Optional[int] = Field(
7439
7671
  default=None,
7440
- description="""Optional. Indicates the thinking budget in tokens. This is only applied when enable_thinking is true.""",
7672
+ description="""Optional. Indicates the thinking budget in tokens.""",
7441
7673
  )
7442
7674
 
7443
7675
 
@@ -7448,7 +7680,7 @@ class GenerationConfigThinkingConfigDict(TypedDict, total=False):
7448
7680
  """Optional. Indicates whether to include thoughts in the response. If true, thoughts are returned only when available."""
7449
7681
 
7450
7682
  thinking_budget: Optional[int]
7451
- """Optional. Indicates the thinking budget in tokens. This is only applied when enable_thinking is true."""
7683
+ """Optional. Indicates the thinking budget in tokens."""
7452
7684
 
7453
7685
 
7454
7686
  GenerationConfigThinkingConfigOrDict = Union[
@@ -8360,7 +8592,7 @@ class TunedModel(_common.BaseModel):
8360
8592
 
8361
8593
  model: Optional[str] = Field(
8362
8594
  default=None,
8363
- description="""Output only. The resource name of the TunedModel. Format: `projects/{project}/locations/{location}/models/{model}`.""",
8595
+ description="""Output only. The resource name of the TunedModel. Format: `projects/{project}/locations/{location}/models/{model}@{version_id}` When tuning from a base model, the version_id will be 1. For continuous tuning, the version id will be incremented by 1 from the last version id in the parent model. E.g., `projects/{project}/locations/{location}/models/{model}@{last_version_id + 1}`""",
8364
8596
  )
8365
8597
  endpoint: Optional[str] = Field(
8366
8598
  default=None,
@@ -8377,7 +8609,7 @@ class TunedModel(_common.BaseModel):
8377
8609
  class TunedModelDict(TypedDict, total=False):
8378
8610
 
8379
8611
  model: Optional[str]
8380
- """Output only. The resource name of the TunedModel. Format: `projects/{project}/locations/{location}/models/{model}`."""
8612
+ """Output only. The resource name of the TunedModel. Format: `projects/{project}/locations/{location}/models/{model}@{version_id}` When tuning from a base model, the version_id will be 1. For continuous tuning, the version id will be incremented by 1 from the last version id in the parent model. E.g., `projects/{project}/locations/{location}/models/{model}@{last_version_id + 1}`"""
8381
8613
 
8382
8614
  endpoint: Optional[str]
8383
8615
  """Output only. A resource name of an Endpoint. Format: `projects/{project}/locations/{location}/endpoints/{endpoint}`."""
@@ -8391,105 +8623,423 @@ class TunedModelDict(TypedDict, total=False):
8391
8623
  TunedModelOrDict = Union[TunedModel, TunedModelDict]
8392
8624
 
8393
8625
 
8394
- class GoogleRpcStatus(_common.BaseModel):
8395
- """The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs.
8396
-
8397
- It is used by [gRPC](https://github.com/grpc). Each `Status` message contains
8398
- three pieces of data: error code, error message, and error details. You can
8399
- find out more about this error model and how to work with it in the [API
8400
- Design Guide](https://cloud.google.com/apis/design/errors).
8401
- """
8626
+ class GcsDestination(_common.BaseModel):
8627
+ """The Google Cloud Storage location where the output is to be written to."""
8402
8628
 
8403
- code: Optional[int] = Field(
8404
- default=None,
8405
- description="""The status code, which should be an enum value of google.rpc.Code.""",
8406
- )
8407
- details: Optional[list[dict[str, Any]]] = Field(
8408
- default=None,
8409
- description="""A list of messages that carry the error details. There is a common set of message types for APIs to use.""",
8410
- )
8411
- message: Optional[str] = Field(
8629
+ output_uri_prefix: Optional[str] = Field(
8412
8630
  default=None,
8413
- 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.""",
8631
+ 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.""",
8414
8632
  )
8415
8633
 
8634
+ @pydantic.model_validator(mode='after')
8635
+ def _validate_gcs_path(self) -> 'GcsDestination':
8636
+ if self.output_uri_prefix and not self.output_uri_prefix.startswith(
8637
+ 'gs://'
8638
+ ):
8639
+ raise ValueError(
8640
+ 'output_uri_prefix must be a valid GCS path starting with "gs://".'
8641
+ )
8642
+ return self
8416
8643
 
8417
- class GoogleRpcStatusDict(TypedDict, total=False):
8418
- """The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs.
8419
8644
 
8420
- It is used by [gRPC](https://github.com/grpc). Each `Status` message contains
8421
- three pieces of data: error code, error message, and error details. You can
8422
- find out more about this error model and how to work with it in the [API
8423
- Design Guide](https://cloud.google.com/apis/design/errors).
8424
- """
8645
+ class GcsDestinationDict(TypedDict, total=False):
8646
+ """The Google Cloud Storage location where the output is to be written to."""
8425
8647
 
8426
- code: Optional[int]
8427
- """The status code, which should be an enum value of google.rpc.Code."""
8648
+ output_uri_prefix: Optional[str]
8649
+ """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."""
8428
8650
 
8429
- details: Optional[list[dict[str, Any]]]
8430
- """A list of messages that carry the error details. There is a common set of message types for APIs to use."""
8431
8651
 
8432
- message: Optional[str]
8433
- """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."""
8652
+ GcsDestinationOrDict = Union[GcsDestination, GcsDestinationDict]
8434
8653
 
8435
8654
 
8436
- GoogleRpcStatusOrDict = Union[GoogleRpcStatus, GoogleRpcStatusDict]
8655
+ class OutputConfig(_common.BaseModel):
8656
+ """Config for evaluation output."""
8437
8657
 
8658
+ gcs_destination: Optional[GcsDestination] = Field(
8659
+ default=None,
8660
+ description="""Cloud storage destination for evaluation output.""",
8661
+ )
8438
8662
 
8439
- class SupervisedHyperParameters(_common.BaseModel):
8440
- """Hyperparameters for SFT."""
8441
8663
 
8442
- adapter_size: Optional[AdapterSize] = Field(
8443
- default=None, description="""Optional. Adapter size for tuning."""
8664
+ class OutputConfigDict(TypedDict, total=False):
8665
+ """Config for evaluation output."""
8666
+
8667
+ gcs_destination: Optional[GcsDestinationDict]
8668
+ """Cloud storage destination for evaluation output."""
8669
+
8670
+
8671
+ OutputConfigOrDict = Union[OutputConfig, OutputConfigDict]
8672
+
8673
+
8674
+ class AutoraterConfig(_common.BaseModel):
8675
+ """Autorater config used for evaluation."""
8676
+
8677
+ sampling_count: Optional[int] = Field(
8678
+ default=None,
8679
+ description="""Number of samples for each instance in the dataset.
8680
+ If not specified, the default is 4. Minimum value is 1, maximum value
8681
+ is 32.""",
8444
8682
  )
8445
- epoch_count: Optional[int] = Field(
8683
+ flip_enabled: Optional[bool] = Field(
8446
8684
  default=None,
8447
- description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""",
8685
+ description="""Optional. Default is true. Whether to flip the candidate and baseline
8686
+ responses. This is only applicable to the pairwise metric. If enabled, also
8687
+ provide PairwiseMetricSpec.candidate_response_field_name and
8688
+ PairwiseMetricSpec.baseline_response_field_name. When rendering
8689
+ PairwiseMetricSpec.metric_prompt_template, the candidate and baseline
8690
+ fields will be flipped for half of the samples to reduce bias.""",
8448
8691
  )
8449
- learning_rate_multiplier: Optional[float] = Field(
8692
+ autorater_model: Optional[str] = Field(
8450
8693
  default=None,
8451
- description="""Optional. Multiplier for adjusting the default learning rate. Mutually exclusive with `learning_rate`.""",
8694
+ description="""The fully qualified name of the publisher model or tuned autorater
8695
+ endpoint to use.
8696
+
8697
+ Publisher model format:
8698
+ `projects/{project}/locations/{location}/publishers/*/models/*`
8699
+
8700
+ Tuned model endpoint format:
8701
+ `projects/{project}/locations/{location}/endpoints/{endpoint}`""",
8452
8702
  )
8453
8703
 
8454
8704
 
8455
- class SupervisedHyperParametersDict(TypedDict, total=False):
8456
- """Hyperparameters for SFT."""
8705
+ class AutoraterConfigDict(TypedDict, total=False):
8706
+ """Autorater config used for evaluation."""
8457
8707
 
8458
- adapter_size: Optional[AdapterSize]
8459
- """Optional. Adapter size for tuning."""
8708
+ sampling_count: Optional[int]
8709
+ """Number of samples for each instance in the dataset.
8710
+ If not specified, the default is 4. Minimum value is 1, maximum value
8711
+ is 32."""
8460
8712
 
8461
- epoch_count: Optional[int]
8462
- """Optional. Number of complete passes the model makes over the entire training dataset during training."""
8713
+ flip_enabled: Optional[bool]
8714
+ """Optional. Default is true. Whether to flip the candidate and baseline
8715
+ responses. This is only applicable to the pairwise metric. If enabled, also
8716
+ provide PairwiseMetricSpec.candidate_response_field_name and
8717
+ PairwiseMetricSpec.baseline_response_field_name. When rendering
8718
+ PairwiseMetricSpec.metric_prompt_template, the candidate and baseline
8719
+ fields will be flipped for half of the samples to reduce bias."""
8463
8720
 
8464
- learning_rate_multiplier: Optional[float]
8465
- """Optional. Multiplier for adjusting the default learning rate. Mutually exclusive with `learning_rate`."""
8721
+ autorater_model: Optional[str]
8722
+ """The fully qualified name of the publisher model or tuned autorater
8723
+ endpoint to use.
8466
8724
 
8725
+ Publisher model format:
8726
+ `projects/{project}/locations/{location}/publishers/*/models/*`
8467
8727
 
8468
- SupervisedHyperParametersOrDict = Union[
8469
- SupervisedHyperParameters, SupervisedHyperParametersDict
8470
- ]
8728
+ Tuned model endpoint format:
8729
+ `projects/{project}/locations/{location}/endpoints/{endpoint}`"""
8471
8730
 
8472
8731
 
8473
- class SupervisedTuningSpec(_common.BaseModel):
8474
- """Tuning Spec for Supervised Tuning for first party models."""
8732
+ AutoraterConfigOrDict = Union[AutoraterConfig, AutoraterConfigDict]
8475
8733
 
8476
- export_last_checkpoint_only: Optional[bool] = Field(
8734
+
8735
+ class Metric(_common.BaseModel):
8736
+ """The metric used for evaluation."""
8737
+
8738
+ name: Optional[str] = Field(
8739
+ default=None, description="""The name of the metric."""
8740
+ )
8741
+ custom_function: Optional[Callable[..., Any]] = Field(
8477
8742
  default=None,
8478
- 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.""",
8743
+ description="""The custom function that defines the end-to-end logic for metric computation.""",
8479
8744
  )
8480
- hyper_parameters: Optional[SupervisedHyperParameters] = Field(
8481
- default=None, description="""Optional. Hyperparameters for SFT."""
8745
+ prompt_template: Optional[str] = Field(
8746
+ default=None, description="""The prompt template for the metric."""
8482
8747
  )
8483
- training_dataset_uri: Optional[str] = Field(
8748
+ judge_model_system_instruction: Optional[str] = Field(
8484
8749
  default=None,
8485
- 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.""",
8750
+ description="""The system instruction for the judge model.""",
8486
8751
  )
8487
- validation_dataset_uri: Optional[str] = Field(
8752
+ return_raw_output: Optional[bool] = Field(
8488
8753
  default=None,
8489
- 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.""",
8754
+ description="""Whether to return the raw output from the judge model.""",
8490
8755
  )
8491
-
8492
-
8756
+ parse_and_reduce_fn: Optional[Callable[..., Any]] = Field(
8757
+ default=None,
8758
+ description="""The parse and reduce function for the judge model.""",
8759
+ )
8760
+ aggregate_summary_fn: Optional[Callable[..., Any]] = Field(
8761
+ default=None,
8762
+ description="""The aggregate summary function for the judge model.""",
8763
+ )
8764
+
8765
+ # Allow extra fields to support metric-specific config fields.
8766
+ model_config = ConfigDict(extra='allow')
8767
+
8768
+ _is_predefined: bool = PrivateAttr(default=False)
8769
+ """A boolean indicating whether the metric is predefined."""
8770
+
8771
+ _config_source: Optional[str] = PrivateAttr(default=None)
8772
+ """An optional string indicating the source of the metric configuration."""
8773
+
8774
+ _version: Optional[str] = PrivateAttr(default=None)
8775
+ """An optional string indicating the version of the metric."""
8776
+
8777
+ @model_validator(mode='after') # type: ignore[arg-type]
8778
+ @classmethod
8779
+ def validate_name(cls, model: 'Metric') -> 'Metric':
8780
+ if not model.name:
8781
+ raise ValueError('Metric name cannot be empty.')
8782
+ model.name = model.name.lower()
8783
+ return model
8784
+
8785
+ def to_yaml_file(self, file_path: str, version: Optional[str] = None) -> None:
8786
+ """Dumps the metric object to a YAML file.
8787
+
8788
+ Args:
8789
+ file_path: The path to the YAML file.
8790
+ version: Optional version string to include in the YAML output.
8791
+
8792
+ Raises:
8793
+ ImportError: If the pyyaml library is not installed.
8794
+ """
8795
+ if yaml is None:
8796
+ raise ImportError(
8797
+ 'YAML serialization requires the pyyaml library. Please install'
8798
+ " it using 'pip install google-cloud-aiplatform[evaluation]'."
8799
+ )
8800
+
8801
+ fields_to_exclude_callables = set()
8802
+ for field_name, field_info in self.model_fields.items():
8803
+ annotation = field_info.annotation
8804
+ origin = typing.get_origin(annotation)
8805
+
8806
+ is_field_callable_type = False
8807
+ if annotation is Callable or origin is Callable: # type: ignore[comparison-overlap]
8808
+ is_field_callable_type = True
8809
+ elif origin is Union:
8810
+ args = typing.get_args(annotation)
8811
+ if any(
8812
+ arg is Callable or typing.get_origin(arg) is Callable
8813
+ for arg in args
8814
+ ):
8815
+ is_field_callable_type = True
8816
+
8817
+ if is_field_callable_type:
8818
+ fields_to_exclude_callables.add(field_name)
8819
+
8820
+ data_to_dump = self.model_dump(
8821
+ exclude_unset=True,
8822
+ exclude_none=True,
8823
+ mode='json',
8824
+ exclude=fields_to_exclude_callables
8825
+ if fields_to_exclude_callables
8826
+ else None,
8827
+ )
8828
+
8829
+ if version:
8830
+ data_to_dump['version'] = version
8831
+
8832
+ with open(file_path, 'w', encoding='utf-8') as f:
8833
+ yaml.dump(data_to_dump, f, sort_keys=False, allow_unicode=True)
8834
+
8835
+
8836
+ class MetricDict(TypedDict, total=False):
8837
+ """The metric used for evaluation."""
8838
+
8839
+ name: Optional[str]
8840
+ """The name of the metric."""
8841
+
8842
+ custom_function: Optional[Callable[..., Any]]
8843
+ """The custom function that defines the end-to-end logic for metric computation."""
8844
+
8845
+ prompt_template: Optional[str]
8846
+ """The prompt template for the metric."""
8847
+
8848
+ judge_model_system_instruction: Optional[str]
8849
+ """The system instruction for the judge model."""
8850
+
8851
+ return_raw_output: Optional[bool]
8852
+ """Whether to return the raw output from the judge model."""
8853
+
8854
+ parse_and_reduce_fn: Optional[Callable[..., Any]]
8855
+ """The parse and reduce function for the judge model."""
8856
+
8857
+ aggregate_summary_fn: Optional[Callable[..., Any]]
8858
+ """The aggregate summary function for the judge model."""
8859
+
8860
+
8861
+ MetricOrDict = Union[Metric, MetricDict]
8862
+
8863
+
8864
+ class EvaluationConfig(_common.BaseModel):
8865
+ """Evaluation config for tuning."""
8866
+
8867
+ metrics: Optional[list[Metric]] = Field(
8868
+ default=None, description="""The metrics used for evaluation."""
8869
+ )
8870
+ output_config: Optional[OutputConfig] = Field(
8871
+ default=None, description="""Config for evaluation output."""
8872
+ )
8873
+ autorater_config: Optional[AutoraterConfig] = Field(
8874
+ default=None, description="""Autorater config for evaluation."""
8875
+ )
8876
+
8877
+
8878
+ class EvaluationConfigDict(TypedDict, total=False):
8879
+ """Evaluation config for tuning."""
8880
+
8881
+ metrics: Optional[list[MetricDict]]
8882
+ """The metrics used for evaluation."""
8883
+
8884
+ output_config: Optional[OutputConfigDict]
8885
+ """Config for evaluation output."""
8886
+
8887
+ autorater_config: Optional[AutoraterConfigDict]
8888
+ """Autorater config for evaluation."""
8889
+
8890
+
8891
+ EvaluationConfigOrDict = Union[EvaluationConfig, EvaluationConfigDict]
8892
+
8893
+
8894
+ class GoogleRpcStatus(_common.BaseModel):
8895
+ """The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs.
8896
+
8897
+ It is used by [gRPC](https://github.com/grpc). Each `Status` message contains
8898
+ three pieces of data: error code, error message, and error details. You can
8899
+ find out more about this error model and how to work with it in the [API
8900
+ Design Guide](https://cloud.google.com/apis/design/errors).
8901
+ """
8902
+
8903
+ code: Optional[int] = Field(
8904
+ default=None,
8905
+ description="""The status code, which should be an enum value of google.rpc.Code.""",
8906
+ )
8907
+ details: Optional[list[dict[str, Any]]] = Field(
8908
+ default=None,
8909
+ description="""A list of messages that carry the error details. There is a common set of message types for APIs to use.""",
8910
+ )
8911
+ message: Optional[str] = Field(
8912
+ default=None,
8913
+ 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.""",
8914
+ )
8915
+
8916
+
8917
+ class GoogleRpcStatusDict(TypedDict, total=False):
8918
+ """The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs.
8919
+
8920
+ It is used by [gRPC](https://github.com/grpc). Each `Status` message contains
8921
+ three pieces of data: error code, error message, and error details. You can
8922
+ find out more about this error model and how to work with it in the [API
8923
+ Design Guide](https://cloud.google.com/apis/design/errors).
8924
+ """
8925
+
8926
+ code: Optional[int]
8927
+ """The status code, which should be an enum value of google.rpc.Code."""
8928
+
8929
+ details: Optional[list[dict[str, Any]]]
8930
+ """A list of messages that carry the error details. There is a common set of message types for APIs to use."""
8931
+
8932
+ message: Optional[str]
8933
+ """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."""
8934
+
8935
+
8936
+ GoogleRpcStatusOrDict = Union[GoogleRpcStatus, GoogleRpcStatusDict]
8937
+
8938
+
8939
+ class PreTunedModel(_common.BaseModel):
8940
+ """A pre-tuned model for continuous tuning."""
8941
+
8942
+ base_model: Optional[str] = Field(
8943
+ default=None,
8944
+ description="""Output only. The name of the base model this PreTunedModel was tuned from.""",
8945
+ )
8946
+ checkpoint_id: Optional[str] = Field(
8947
+ default=None,
8948
+ description="""Optional. The source checkpoint id. If not specified, the default checkpoint will be used.""",
8949
+ )
8950
+ tuned_model_name: Optional[str] = Field(
8951
+ default=None,
8952
+ 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}`""",
8953
+ )
8954
+
8955
+
8956
+ class PreTunedModelDict(TypedDict, total=False):
8957
+ """A pre-tuned model for continuous tuning."""
8958
+
8959
+ base_model: Optional[str]
8960
+ """Output only. The name of the base model this PreTunedModel was tuned from."""
8961
+
8962
+ checkpoint_id: Optional[str]
8963
+ """Optional. The source checkpoint id. If not specified, the default checkpoint will be used."""
8964
+
8965
+ tuned_model_name: Optional[str]
8966
+ """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}`"""
8967
+
8968
+
8969
+ PreTunedModelOrDict = Union[PreTunedModel, PreTunedModelDict]
8970
+
8971
+
8972
+ class SupervisedHyperParameters(_common.BaseModel):
8973
+ """Hyperparameters for SFT."""
8974
+
8975
+ adapter_size: Optional[AdapterSize] = Field(
8976
+ default=None, description="""Optional. Adapter size for tuning."""
8977
+ )
8978
+ batch_size: Optional[int] = Field(
8979
+ default=None,
8980
+ description="""Optional. Batch size for tuning. This feature is only available for open source models.""",
8981
+ )
8982
+ epoch_count: Optional[int] = Field(
8983
+ default=None,
8984
+ description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""",
8985
+ )
8986
+ learning_rate: Optional[float] = Field(
8987
+ default=None,
8988
+ description="""Optional. Learning rate for tuning. Mutually exclusive with `learning_rate_multiplier`. This feature is only available for open source models.""",
8989
+ )
8990
+ learning_rate_multiplier: Optional[float] = Field(
8991
+ default=None,
8992
+ description="""Optional. Multiplier for adjusting the default learning rate. Mutually exclusive with `learning_rate`. This feature is only available for 1P models.""",
8993
+ )
8994
+
8995
+
8996
+ class SupervisedHyperParametersDict(TypedDict, total=False):
8997
+ """Hyperparameters for SFT."""
8998
+
8999
+ adapter_size: Optional[AdapterSize]
9000
+ """Optional. Adapter size for tuning."""
9001
+
9002
+ batch_size: Optional[int]
9003
+ """Optional. Batch size for tuning. This feature is only available for open source models."""
9004
+
9005
+ epoch_count: Optional[int]
9006
+ """Optional. Number of complete passes the model makes over the entire training dataset during training."""
9007
+
9008
+ learning_rate: Optional[float]
9009
+ """Optional. Learning rate for tuning. Mutually exclusive with `learning_rate_multiplier`. This feature is only available for open source models."""
9010
+
9011
+ learning_rate_multiplier: Optional[float]
9012
+ """Optional. Multiplier for adjusting the default learning rate. Mutually exclusive with `learning_rate`. This feature is only available for 1P models."""
9013
+
9014
+
9015
+ SupervisedHyperParametersOrDict = Union[
9016
+ SupervisedHyperParameters, SupervisedHyperParametersDict
9017
+ ]
9018
+
9019
+
9020
+ class SupervisedTuningSpec(_common.BaseModel):
9021
+ """Tuning Spec for Supervised Tuning for first party models."""
9022
+
9023
+ export_last_checkpoint_only: Optional[bool] = Field(
9024
+ default=None,
9025
+ 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.""",
9026
+ )
9027
+ hyper_parameters: Optional[SupervisedHyperParameters] = Field(
9028
+ default=None, description="""Optional. Hyperparameters for SFT."""
9029
+ )
9030
+ training_dataset_uri: Optional[str] = Field(
9031
+ default=None,
9032
+ 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.""",
9033
+ )
9034
+ tuning_mode: Optional[TuningMode] = Field(
9035
+ default=None, description="""Tuning mode."""
9036
+ )
9037
+ validation_dataset_uri: Optional[str] = Field(
9038
+ default=None,
9039
+ 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.""",
9040
+ )
9041
+
9042
+
8493
9043
  class SupervisedTuningSpecDict(TypedDict, total=False):
8494
9044
  """Tuning Spec for Supervised Tuning for first party models."""
8495
9045
 
@@ -8502,6 +9052,9 @@ class SupervisedTuningSpecDict(TypedDict, total=False):
8502
9052
  training_dataset_uri: Optional[str]
8503
9053
  """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."""
8504
9054
 
9055
+ tuning_mode: Optional[TuningMode]
9056
+ """Tuning mode."""
9057
+
8505
9058
  validation_dataset_uri: Optional[str]
8506
9059
  """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."""
8507
9060
 
@@ -8701,6 +9254,132 @@ DistillationDataStatsOrDict = Union[
8701
9254
  ]
8702
9255
 
8703
9256
 
9257
+ class GeminiPreferenceExampleCompletion(_common.BaseModel):
9258
+ """Completion and its preference score."""
9259
+
9260
+ completion: Optional[Content] = Field(
9261
+ default=None,
9262
+ description="""Single turn completion for the given prompt.""",
9263
+ )
9264
+ score: Optional[float] = Field(
9265
+ default=None, description="""The score for the given completion."""
9266
+ )
9267
+
9268
+
9269
+ class GeminiPreferenceExampleCompletionDict(TypedDict, total=False):
9270
+ """Completion and its preference score."""
9271
+
9272
+ completion: Optional[ContentDict]
9273
+ """Single turn completion for the given prompt."""
9274
+
9275
+ score: Optional[float]
9276
+ """The score for the given completion."""
9277
+
9278
+
9279
+ GeminiPreferenceExampleCompletionOrDict = Union[
9280
+ GeminiPreferenceExampleCompletion, GeminiPreferenceExampleCompletionDict
9281
+ ]
9282
+
9283
+
9284
+ class GeminiPreferenceExample(_common.BaseModel):
9285
+ """Input example for preference optimization."""
9286
+
9287
+ completions: Optional[list[GeminiPreferenceExampleCompletion]] = Field(
9288
+ default=None, description="""List of completions for a given prompt."""
9289
+ )
9290
+ contents: Optional[list[Content]] = Field(
9291
+ default=None,
9292
+ description="""Multi-turn contents that represents the Prompt.""",
9293
+ )
9294
+
9295
+
9296
+ class GeminiPreferenceExampleDict(TypedDict, total=False):
9297
+ """Input example for preference optimization."""
9298
+
9299
+ completions: Optional[list[GeminiPreferenceExampleCompletionDict]]
9300
+ """List of completions for a given prompt."""
9301
+
9302
+ contents: Optional[list[ContentDict]]
9303
+ """Multi-turn contents that represents the Prompt."""
9304
+
9305
+
9306
+ GeminiPreferenceExampleOrDict = Union[
9307
+ GeminiPreferenceExample, GeminiPreferenceExampleDict
9308
+ ]
9309
+
9310
+
9311
+ class PreferenceOptimizationDataStats(_common.BaseModel):
9312
+ """Statistics computed for datasets used for preference optimization."""
9313
+
9314
+ score_variance_per_example_distribution: Optional[DatasetDistribution] = (
9315
+ Field(
9316
+ default=None,
9317
+ description="""Output only. Dataset distributions for scores variance per example.""",
9318
+ )
9319
+ )
9320
+ scores_distribution: Optional[DatasetDistribution] = Field(
9321
+ default=None,
9322
+ description="""Output only. Dataset distributions for scores.""",
9323
+ )
9324
+ total_billable_token_count: Optional[int] = Field(
9325
+ default=None,
9326
+ description="""Output only. Number of billable tokens in the tuning dataset.""",
9327
+ )
9328
+ tuning_dataset_example_count: Optional[int] = Field(
9329
+ default=None,
9330
+ description="""Output only. Number of examples in the tuning dataset.""",
9331
+ )
9332
+ tuning_step_count: Optional[int] = Field(
9333
+ default=None,
9334
+ description="""Output only. Number of tuning steps for this Tuning Job.""",
9335
+ )
9336
+ user_dataset_examples: Optional[list[GeminiPreferenceExample]] = Field(
9337
+ default=None,
9338
+ description="""Output only. Sample user examples in the training dataset.""",
9339
+ )
9340
+ user_input_token_distribution: Optional[DatasetDistribution] = Field(
9341
+ default=None,
9342
+ description="""Output only. Dataset distributions for the user input tokens.""",
9343
+ )
9344
+ user_output_token_distribution: Optional[DatasetDistribution] = Field(
9345
+ default=None,
9346
+ description="""Output only. Dataset distributions for the user output tokens.""",
9347
+ )
9348
+
9349
+
9350
+ class PreferenceOptimizationDataStatsDict(TypedDict, total=False):
9351
+ """Statistics computed for datasets used for preference optimization."""
9352
+
9353
+ score_variance_per_example_distribution: Optional[DatasetDistributionDict]
9354
+ """Output only. Dataset distributions for scores variance per example."""
9355
+
9356
+ scores_distribution: Optional[DatasetDistributionDict]
9357
+ """Output only. Dataset distributions for scores."""
9358
+
9359
+ total_billable_token_count: Optional[int]
9360
+ """Output only. Number of billable tokens in the tuning dataset."""
9361
+
9362
+ tuning_dataset_example_count: Optional[int]
9363
+ """Output only. Number of examples in the tuning dataset."""
9364
+
9365
+ tuning_step_count: Optional[int]
9366
+ """Output only. Number of tuning steps for this Tuning Job."""
9367
+
9368
+ user_dataset_examples: Optional[list[GeminiPreferenceExampleDict]]
9369
+ """Output only. Sample user examples in the training dataset."""
9370
+
9371
+ user_input_token_distribution: Optional[DatasetDistributionDict]
9372
+ """Output only. Dataset distributions for the user input tokens."""
9373
+
9374
+ user_output_token_distribution: Optional[DatasetDistributionDict]
9375
+ """Output only. Dataset distributions for the user output tokens."""
9376
+
9377
+
9378
+ PreferenceOptimizationDataStatsOrDict = Union[
9379
+ PreferenceOptimizationDataStats, PreferenceOptimizationDataStatsDict
9380
+ ]
9381
+
9382
+
8704
9383
  class SupervisedTuningDatasetDistributionDatasetBucket(_common.BaseModel):
8705
9384
  """Dataset bucket used to create a histogram for the distribution given a population of values."""
8706
9385
 
@@ -8932,6 +9611,12 @@ class TuningDataStats(_common.BaseModel):
8932
9611
  distillation_data_stats: Optional[DistillationDataStats] = Field(
8933
9612
  default=None, description="""Output only. Statistics for distillation."""
8934
9613
  )
9614
+ preference_optimization_data_stats: Optional[
9615
+ PreferenceOptimizationDataStats
9616
+ ] = Field(
9617
+ default=None,
9618
+ description="""Output only. Statistics for preference optimization.""",
9619
+ )
8935
9620
  supervised_tuning_data_stats: Optional[SupervisedTuningDataStats] = Field(
8936
9621
  default=None, description="""The SFT Tuning data stats."""
8937
9622
  )
@@ -8943,127 +9628,47 @@ class TuningDataStatsDict(TypedDict, total=False):
8943
9628
  distillation_data_stats: Optional[DistillationDataStatsDict]
8944
9629
  """Output only. Statistics for distillation."""
8945
9630
 
8946
- supervised_tuning_data_stats: Optional[SupervisedTuningDataStatsDict]
8947
- """The SFT Tuning data stats."""
8948
-
8949
-
8950
- TuningDataStatsOrDict = Union[TuningDataStats, TuningDataStatsDict]
8951
-
8952
-
8953
- class EncryptionSpec(_common.BaseModel):
8954
- """Represents a customer-managed encryption key spec that can be applied to a top-level resource."""
8955
-
8956
- kms_key_name: Optional[str] = Field(
8957
- default=None,
8958
- description="""Required. The Cloud KMS resource identifier of the customer managed encryption key used to protect a resource. Has the form: `projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key`. The key needs to be in the same region as where the compute resource is created.""",
8959
- )
8960
-
8961
-
8962
- class EncryptionSpecDict(TypedDict, total=False):
8963
- """Represents a customer-managed encryption key spec that can be applied to a top-level resource."""
8964
-
8965
- kms_key_name: Optional[str]
8966
- """Required. The Cloud KMS resource identifier of the customer managed encryption key used to protect a resource. Has the form: `projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key`. The key needs to be in the same region as where the compute resource is created."""
8967
-
8968
-
8969
- EncryptionSpecOrDict = Union[EncryptionSpec, EncryptionSpecDict]
8970
-
8971
-
8972
- class PartnerModelTuningSpec(_common.BaseModel):
8973
- """Tuning spec for Partner models."""
8974
-
8975
- hyper_parameters: Optional[dict[str, Any]] = Field(
8976
- default=None,
8977
- description="""Hyperparameters for tuning. The accepted hyper_parameters and their valid range of values will differ depending on the base model.""",
8978
- )
8979
- training_dataset_uri: Optional[str] = Field(
8980
- default=None,
8981
- description="""Required. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""",
8982
- )
8983
- validation_dataset_uri: Optional[str] = Field(
8984
- default=None,
8985
- description="""Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""",
8986
- )
8987
-
8988
-
8989
- class PartnerModelTuningSpecDict(TypedDict, total=False):
8990
- """Tuning spec for Partner models."""
8991
-
8992
- hyper_parameters: Optional[dict[str, Any]]
8993
- """Hyperparameters for tuning. The accepted hyper_parameters and their valid range of values will differ depending on the base model."""
8994
-
8995
- training_dataset_uri: Optional[str]
8996
- """Required. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file."""
9631
+ preference_optimization_data_stats: Optional[
9632
+ PreferenceOptimizationDataStatsDict
9633
+ ]
9634
+ """Output only. Statistics for preference optimization."""
8997
9635
 
8998
- validation_dataset_uri: Optional[str]
8999
- """Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file."""
9636
+ supervised_tuning_data_stats: Optional[SupervisedTuningDataStatsDict]
9637
+ """The SFT Tuning data stats."""
9000
9638
 
9001
9639
 
9002
- PartnerModelTuningSpecOrDict = Union[
9003
- PartnerModelTuningSpec, PartnerModelTuningSpecDict
9004
- ]
9640
+ TuningDataStatsOrDict = Union[TuningDataStats, TuningDataStatsDict]
9005
9641
 
9006
9642
 
9007
- class DistillationHyperParameters(_common.BaseModel):
9008
- """Hyperparameters for Distillation."""
9643
+ class EncryptionSpec(_common.BaseModel):
9644
+ """Represents a customer-managed encryption key spec that can be applied to a top-level resource."""
9009
9645
 
9010
- adapter_size: Optional[AdapterSize] = Field(
9011
- default=None, description="""Optional. Adapter size for distillation."""
9012
- )
9013
- epoch_count: Optional[int] = Field(
9014
- default=None,
9015
- description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""",
9016
- )
9017
- learning_rate_multiplier: Optional[float] = Field(
9646
+ kms_key_name: Optional[str] = Field(
9018
9647
  default=None,
9019
- description="""Optional. Multiplier for adjusting the default learning rate.""",
9648
+ description="""Required. The Cloud KMS resource identifier of the customer managed encryption key used to protect a resource. Has the form: `projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key`. The key needs to be in the same region as where the compute resource is created.""",
9020
9649
  )
9021
9650
 
9022
9651
 
9023
- class DistillationHyperParametersDict(TypedDict, total=False):
9024
- """Hyperparameters for Distillation."""
9025
-
9026
- adapter_size: Optional[AdapterSize]
9027
- """Optional. Adapter size for distillation."""
9028
-
9029
- epoch_count: Optional[int]
9030
- """Optional. Number of complete passes the model makes over the entire training dataset during training."""
9652
+ class EncryptionSpecDict(TypedDict, total=False):
9653
+ """Represents a customer-managed encryption key spec that can be applied to a top-level resource."""
9031
9654
 
9032
- learning_rate_multiplier: Optional[float]
9033
- """Optional. Multiplier for adjusting the default learning rate."""
9655
+ kms_key_name: Optional[str]
9656
+ """Required. The Cloud KMS resource identifier of the customer managed encryption key used to protect a resource. Has the form: `projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key`. The key needs to be in the same region as where the compute resource is created."""
9034
9657
 
9035
9658
 
9036
- DistillationHyperParametersOrDict = Union[
9037
- DistillationHyperParameters, DistillationHyperParametersDict
9038
- ]
9659
+ EncryptionSpecOrDict = Union[EncryptionSpec, EncryptionSpecDict]
9039
9660
 
9040
9661
 
9041
- class DistillationSpec(_common.BaseModel):
9042
- """Tuning Spec for Distillation."""
9662
+ class PartnerModelTuningSpec(_common.BaseModel):
9663
+ """Tuning spec for Partner models."""
9043
9664
 
9044
- base_teacher_model: Optional[str] = Field(
9045
- default=None,
9046
- 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).""",
9047
- )
9048
- hyper_parameters: Optional[DistillationHyperParameters] = Field(
9049
- default=None,
9050
- description="""Optional. Hyperparameters for Distillation.""",
9051
- )
9052
- pipeline_root_directory: Optional[str] = Field(
9053
- default=None,
9054
- 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.""",
9055
- )
9056
- student_model: Optional[str] = Field(
9665
+ hyper_parameters: Optional[dict[str, Any]] = Field(
9057
9666
  default=None,
9058
- description="""The student model that is being tuned, e.g., "google/gemma-2b-1.1-it". Deprecated. Use base_model instead.""",
9667
+ description="""Hyperparameters for tuning. The accepted hyper_parameters and their valid range of values will differ depending on the base model.""",
9059
9668
  )
9060
9669
  training_dataset_uri: Optional[str] = Field(
9061
9670
  default=None,
9062
- description="""Deprecated. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""",
9063
- )
9064
- tuned_teacher_model_source: Optional[str] = Field(
9065
- default=None,
9066
- description="""The resource name of the Tuned teacher model. Format: `projects/{project}/locations/{location}/models/{model}`.""",
9671
+ description="""Required. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""",
9067
9672
  )
9068
9673
  validation_dataset_uri: Optional[str] = Field(
9069
9674
  default=None,
@@ -9071,32 +9676,22 @@ class DistillationSpec(_common.BaseModel):
9071
9676
  )
9072
9677
 
9073
9678
 
9074
- class DistillationSpecDict(TypedDict, total=False):
9075
- """Tuning Spec for Distillation."""
9076
-
9077
- base_teacher_model: Optional[str]
9078
- """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)."""
9079
-
9080
- hyper_parameters: Optional[DistillationHyperParametersDict]
9081
- """Optional. Hyperparameters for Distillation."""
9082
-
9083
- pipeline_root_directory: Optional[str]
9084
- """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."""
9679
+ class PartnerModelTuningSpecDict(TypedDict, total=False):
9680
+ """Tuning spec for Partner models."""
9085
9681
 
9086
- student_model: Optional[str]
9087
- """The student model that is being tuned, e.g., "google/gemma-2b-1.1-it". Deprecated. Use base_model instead."""
9682
+ hyper_parameters: Optional[dict[str, Any]]
9683
+ """Hyperparameters for tuning. The accepted hyper_parameters and their valid range of values will differ depending on the base model."""
9088
9684
 
9089
9685
  training_dataset_uri: Optional[str]
9090
- """Deprecated. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file."""
9091
-
9092
- tuned_teacher_model_source: Optional[str]
9093
- """The resource name of the Tuned teacher model. Format: `projects/{project}/locations/{location}/models/{model}`."""
9686
+ """Required. Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file."""
9094
9687
 
9095
9688
  validation_dataset_uri: Optional[str]
9096
9689
  """Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file."""
9097
9690
 
9098
9691
 
9099
- DistillationSpecOrDict = Union[DistillationSpec, DistillationSpecDict]
9692
+ PartnerModelTuningSpecOrDict = Union[
9693
+ PartnerModelTuningSpec, PartnerModelTuningSpecDict
9694
+ ]
9100
9695
 
9101
9696
 
9102
9697
  class TuningJob(_common.BaseModel):
@@ -9145,6 +9740,9 @@ class TuningJob(_common.BaseModel):
9145
9740
  default=None,
9146
9741
  description="""Output only. The tuned model resources associated with this TuningJob.""",
9147
9742
  )
9743
+ pre_tuned_model: Optional[PreTunedModel] = Field(
9744
+ default=None, description="""The pre-tuned model for continuous tuning."""
9745
+ )
9148
9746
  supervised_tuning_spec: Optional[SupervisedTuningSpec] = Field(
9149
9747
  default=None, description="""Tuning Spec for Supervised Fine Tuning."""
9150
9748
  )
@@ -9160,8 +9758,12 @@ class TuningJob(_common.BaseModel):
9160
9758
  default=None,
9161
9759
  description="""Tuning Spec for open sourced and third party Partner models.""",
9162
9760
  )
9163
- distillation_spec: Optional[DistillationSpec] = Field(
9164
- default=None, description="""Tuning Spec for Distillation."""
9761
+ evaluation_config: Optional[EvaluationConfig] = Field(
9762
+ default=None, description=""""""
9763
+ )
9764
+ custom_base_model: Optional[str] = Field(
9765
+ default=None,
9766
+ 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.""",
9165
9767
  )
9166
9768
  experiment: Optional[str] = Field(
9167
9769
  default=None,
@@ -9171,16 +9773,14 @@ class TuningJob(_common.BaseModel):
9171
9773
  default=None,
9172
9774
  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.""",
9173
9775
  )
9776
+ output_uri: Optional[str] = Field(
9777
+ default=None,
9778
+ 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.""",
9779
+ )
9174
9780
  pipeline_job: Optional[str] = Field(
9175
9781
  default=None,
9176
9782
  description="""Output only. The resource name of the PipelineJob associated with the TuningJob. Format: `projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}`.""",
9177
9783
  )
9178
- satisfies_pzi: Optional[bool] = Field(
9179
- default=None, description="""Output only. Reserved for future use."""
9180
- )
9181
- satisfies_pzs: Optional[bool] = Field(
9182
- default=None, description="""Output only. Reserved for future use."""
9183
- )
9184
9784
  service_account: Optional[str] = Field(
9185
9785
  default=None,
9186
9786
  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.""",
@@ -9237,6 +9837,9 @@ class TuningJobDict(TypedDict, total=False):
9237
9837
  tuned_model: Optional[TunedModelDict]
9238
9838
  """Output only. The tuned model resources associated with this TuningJob."""
9239
9839
 
9840
+ pre_tuned_model: Optional[PreTunedModelDict]
9841
+ """The pre-tuned model for continuous tuning."""
9842
+
9240
9843
  supervised_tuning_spec: Optional[SupervisedTuningSpecDict]
9241
9844
  """Tuning Spec for Supervised Fine Tuning."""
9242
9845
 
@@ -9249,8 +9852,11 @@ class TuningJobDict(TypedDict, total=False):
9249
9852
  partner_model_tuning_spec: Optional[PartnerModelTuningSpecDict]
9250
9853
  """Tuning Spec for open sourced and third party Partner models."""
9251
9854
 
9252
- distillation_spec: Optional[DistillationSpecDict]
9253
- """Tuning Spec for Distillation."""
9855
+ evaluation_config: Optional[EvaluationConfigDict]
9856
+ """"""
9857
+
9858
+ custom_base_model: Optional[str]
9859
+ """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."""
9254
9860
 
9255
9861
  experiment: Optional[str]
9256
9862
  """Output only. The Experiment associated with this TuningJob."""
@@ -9258,15 +9864,12 @@ class TuningJobDict(TypedDict, total=False):
9258
9864
  labels: Optional[dict[str, str]]
9259
9865
  """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."""
9260
9866
 
9867
+ output_uri: Optional[str]
9868
+ """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."""
9869
+
9261
9870
  pipeline_job: Optional[str]
9262
9871
  """Output only. The resource name of the PipelineJob associated with the TuningJob. Format: `projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}`."""
9263
9872
 
9264
- satisfies_pzi: Optional[bool]
9265
- """Output only. Reserved for future use."""
9266
-
9267
- satisfies_pzs: Optional[bool]
9268
- """Output only. Reserved for future use."""
9269
-
9270
9873
  service_account: Optional[str]
9271
9874
  """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."""
9272
9875
 
@@ -9472,6 +10075,10 @@ class CreateTuningJobConfig(_common.BaseModel):
9472
10075
  default=None,
9473
10076
  description="""If set to true, disable intermediate checkpoints for SFT and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints for SFT.""",
9474
10077
  )
10078
+ pre_tuned_model_checkpoint_id: Optional[str] = Field(
10079
+ default=None,
10080
+ description="""The optional checkpoint id of the pre-tuned model to use for tuning, if applicable.""",
10081
+ )
9475
10082
  adapter_size: Optional[AdapterSize] = Field(
9476
10083
  default=None, description="""Adapter size for tuning."""
9477
10084
  )
@@ -9483,6 +10090,9 @@ class CreateTuningJobConfig(_common.BaseModel):
9483
10090
  default=None,
9484
10091
  description="""The learning rate hyperparameter for tuning. If not set, a default of 0.001 or 0.0002 will be calculated based on the number of training examples.""",
9485
10092
  )
10093
+ evaluation_config: Optional[EvaluationConfig] = Field(
10094
+ default=None, description="""Evaluation config for the tuning job."""
10095
+ )
9486
10096
 
9487
10097
 
9488
10098
  class CreateTuningJobConfigDict(TypedDict, total=False):
@@ -9509,6 +10119,9 @@ class CreateTuningJobConfigDict(TypedDict, total=False):
9509
10119
  export_last_checkpoint_only: Optional[bool]
9510
10120
  """If set to true, disable intermediate checkpoints for SFT and only the last checkpoint will be exported. Otherwise, enable intermediate checkpoints for SFT."""
9511
10121
 
10122
+ pre_tuned_model_checkpoint_id: Optional[str]
10123
+ """The optional checkpoint id of the pre-tuned model to use for tuning, if applicable."""
10124
+
9512
10125
  adapter_size: Optional[AdapterSize]
9513
10126
  """Adapter size for tuning."""
9514
10127
 
@@ -9518,18 +10131,24 @@ class CreateTuningJobConfigDict(TypedDict, total=False):
9518
10131
  learning_rate: Optional[float]
9519
10132
  """The learning rate hyperparameter for tuning. If not set, a default of 0.001 or 0.0002 will be calculated based on the number of training examples."""
9520
10133
 
10134
+ evaluation_config: Optional[EvaluationConfigDict]
10135
+ """Evaluation config for the tuning job."""
10136
+
9521
10137
 
9522
10138
  CreateTuningJobConfigOrDict = Union[
9523
10139
  CreateTuningJobConfig, CreateTuningJobConfigDict
9524
10140
  ]
9525
10141
 
9526
10142
 
9527
- class _CreateTuningJobParameters(_common.BaseModel):
10143
+ class _CreateTuningJobParametersPrivate(_common.BaseModel):
9528
10144
  """Supervised fine-tuning job creation parameters - optional fields."""
9529
10145
 
9530
10146
  base_model: Optional[str] = Field(
9531
10147
  default=None,
9532
- description="""The base model that is being tuned, e.g., "gemini-1.0-pro-002".""",
10148
+ description="""The base model that is being tuned, e.g., "gemini-2.5-flash".""",
10149
+ )
10150
+ pre_tuned_model: Optional[PreTunedModel] = Field(
10151
+ default=None, description="""The PreTunedModel that is being tuned."""
9533
10152
  )
9534
10153
  training_dataset: Optional[TuningDataset] = Field(
9535
10154
  default=None,
@@ -9540,11 +10159,14 @@ class _CreateTuningJobParameters(_common.BaseModel):
9540
10159
  )
9541
10160
 
9542
10161
 
9543
- class _CreateTuningJobParametersDict(TypedDict, total=False):
10162
+ class _CreateTuningJobParametersPrivateDict(TypedDict, total=False):
9544
10163
  """Supervised fine-tuning job creation parameters - optional fields."""
9545
10164
 
9546
10165
  base_model: Optional[str]
9547
- """The base model that is being tuned, e.g., "gemini-1.0-pro-002"."""
10166
+ """The base model that is being tuned, e.g., "gemini-2.5-flash"."""
10167
+
10168
+ pre_tuned_model: Optional[PreTunedModelDict]
10169
+ """The PreTunedModel that is being tuned."""
9548
10170
 
9549
10171
  training_dataset: Optional[TuningDatasetDict]
9550
10172
  """Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file."""
@@ -9553,8 +10175,8 @@ class _CreateTuningJobParametersDict(TypedDict, total=False):
9553
10175
  """Configuration for the tuning job."""
9554
10176
 
9555
10177
 
9556
- _CreateTuningJobParametersOrDict = Union[
9557
- _CreateTuningJobParameters, _CreateTuningJobParametersDict
10178
+ _CreateTuningJobParametersPrivateOrDict = Union[
10179
+ _CreateTuningJobParametersPrivate, _CreateTuningJobParametersPrivateDict
9558
10180
  ]
9559
10181
 
9560
10182
 
@@ -12881,6 +13503,44 @@ LiveClientRealtimeInputOrDict = Union[
12881
13503
  ]
12882
13504
 
12883
13505
 
13506
+ class LiveClientToolResponse(_common.BaseModel):
13507
+ """Client generated response to a `ToolCall` received from the server.
13508
+
13509
+ Individual `FunctionResponse` objects are matched to the respective
13510
+ `FunctionCall` objects by the `id` field.
13511
+
13512
+ Note that in the unary and server-streaming GenerateContent APIs function
13513
+ calling happens by exchanging the `Content` parts, while in the bidi
13514
+ GenerateContent APIs function calling happens over this dedicated set of
13515
+ messages.
13516
+ """
13517
+
13518
+ function_responses: Optional[list[FunctionResponse]] = Field(
13519
+ default=None, description="""The response to the function calls."""
13520
+ )
13521
+
13522
+
13523
+ class LiveClientToolResponseDict(TypedDict, total=False):
13524
+ """Client generated response to a `ToolCall` received from the server.
13525
+
13526
+ Individual `FunctionResponse` objects are matched to the respective
13527
+ `FunctionCall` objects by the `id` field.
13528
+
13529
+ Note that in the unary and server-streaming GenerateContent APIs function
13530
+ calling happens by exchanging the `Content` parts, while in the bidi
13531
+ GenerateContent APIs function calling happens over this dedicated set of
13532
+ messages.
13533
+ """
13534
+
13535
+ function_responses: Optional[list[FunctionResponseDict]]
13536
+ """The response to the function calls."""
13537
+
13538
+
13539
+ LiveClientToolResponseOrDict = Union[
13540
+ LiveClientToolResponse, LiveClientToolResponseDict
13541
+ ]
13542
+
13543
+
12884
13544
  if _is_pillow_image_imported:
12885
13545
  BlobImageUnion = Union[PIL_Image, Blob]
12886
13546
  else:
@@ -12966,44 +13626,6 @@ LiveSendRealtimeInputParametersOrDict = Union[
12966
13626
  ]
12967
13627
 
12968
13628
 
12969
- class LiveClientToolResponse(_common.BaseModel):
12970
- """Client generated response to a `ToolCall` received from the server.
12971
-
12972
- Individual `FunctionResponse` objects are matched to the respective
12973
- `FunctionCall` objects by the `id` field.
12974
-
12975
- Note that in the unary and server-streaming GenerateContent APIs function
12976
- calling happens by exchanging the `Content` parts, while in the bidi
12977
- GenerateContent APIs function calling happens over this dedicated set of
12978
- messages.
12979
- """
12980
-
12981
- function_responses: Optional[list[FunctionResponse]] = Field(
12982
- default=None, description="""The response to the function calls."""
12983
- )
12984
-
12985
-
12986
- class LiveClientToolResponseDict(TypedDict, total=False):
12987
- """Client generated response to a `ToolCall` received from the server.
12988
-
12989
- Individual `FunctionResponse` objects are matched to the respective
12990
- `FunctionCall` objects by the `id` field.
12991
-
12992
- Note that in the unary and server-streaming GenerateContent APIs function
12993
- calling happens by exchanging the `Content` parts, while in the bidi
12994
- GenerateContent APIs function calling happens over this dedicated set of
12995
- messages.
12996
- """
12997
-
12998
- function_responses: Optional[list[FunctionResponseDict]]
12999
- """The response to the function calls."""
13000
-
13001
-
13002
- LiveClientToolResponseOrDict = Union[
13003
- LiveClientToolResponse, LiveClientToolResponseDict
13004
- ]
13005
-
13006
-
13007
13629
  class LiveClientMessage(_common.BaseModel):
13008
13630
  """Messages sent by the client in the API call."""
13009
13631
 
@@ -13885,3 +14507,189 @@ class CreateAuthTokenParametersDict(TypedDict, total=False):
13885
14507
  CreateAuthTokenParametersOrDict = Union[
13886
14508
  CreateAuthTokenParameters, CreateAuthTokenParametersDict
13887
14509
  ]
14510
+
14511
+
14512
+ class CreateTuningJobParameters(_common.BaseModel):
14513
+ """Supervised fine-tuning job creation parameters - optional fields."""
14514
+
14515
+ base_model: Optional[str] = Field(
14516
+ default=None,
14517
+ description="""The base model that is being tuned, e.g., "gemini-2.5-flash".""",
14518
+ )
14519
+ training_dataset: Optional[TuningDataset] = Field(
14520
+ default=None,
14521
+ description="""Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""",
14522
+ )
14523
+ config: Optional[CreateTuningJobConfig] = Field(
14524
+ default=None, description="""Configuration for the tuning job."""
14525
+ )
14526
+
14527
+
14528
+ class CreateTuningJobParametersDict(TypedDict, total=False):
14529
+ """Supervised fine-tuning job creation parameters - optional fields."""
14530
+
14531
+ base_model: Optional[str]
14532
+ """The base model that is being tuned, e.g., "gemini-2.5-flash"."""
14533
+
14534
+ training_dataset: Optional[TuningDatasetDict]
14535
+ """Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file."""
14536
+
14537
+ config: Optional[CreateTuningJobConfigDict]
14538
+ """Configuration for the tuning job."""
14539
+
14540
+
14541
+ CreateTuningJobParametersOrDict = Union[
14542
+ CreateTuningJobParameters, CreateTuningJobParametersDict
14543
+ ]
14544
+
14545
+
14546
+ class CustomOutputFormatConfig(_common.BaseModel):
14547
+ """Config for custom output format."""
14548
+
14549
+ return_raw_output: Optional[bool] = Field(
14550
+ default=None, description="""Optional. Whether to return raw output."""
14551
+ )
14552
+
14553
+
14554
+ class CustomOutputFormatConfigDict(TypedDict, total=False):
14555
+ """Config for custom output format."""
14556
+
14557
+ return_raw_output: Optional[bool]
14558
+ """Optional. Whether to return raw output."""
14559
+
14560
+
14561
+ CustomOutputFormatConfigOrDict = Union[
14562
+ CustomOutputFormatConfig, CustomOutputFormatConfigDict
14563
+ ]
14564
+
14565
+
14566
+ class BleuSpec(_common.BaseModel):
14567
+ """Spec for bleu metric."""
14568
+
14569
+ use_effective_order: Optional[bool] = Field(
14570
+ default=None,
14571
+ description="""Optional. Whether to use_effective_order to compute bleu score.""",
14572
+ )
14573
+
14574
+
14575
+ class BleuSpecDict(TypedDict, total=False):
14576
+ """Spec for bleu metric."""
14577
+
14578
+ use_effective_order: Optional[bool]
14579
+ """Optional. Whether to use_effective_order to compute bleu score."""
14580
+
14581
+
14582
+ BleuSpecOrDict = Union[BleuSpec, BleuSpecDict]
14583
+
14584
+
14585
+ class PairwiseMetricSpec(_common.BaseModel):
14586
+ """Spec for pairwise metric."""
14587
+
14588
+ metric_prompt_template: Optional[str] = Field(
14589
+ default=None,
14590
+ description="""Required. Metric prompt template for pairwise metric.""",
14591
+ )
14592
+ baseline_response_field_name: Optional[str] = Field(
14593
+ default=None,
14594
+ description="""Optional. The field name of the baseline response.""",
14595
+ )
14596
+ candidate_response_field_name: Optional[str] = Field(
14597
+ default=None,
14598
+ description="""Optional. The field name of the candidate response.""",
14599
+ )
14600
+ custom_output_format_config: Optional[CustomOutputFormatConfig] = Field(
14601
+ default=None,
14602
+ 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.""",
14603
+ )
14604
+ system_instruction: Optional[str] = Field(
14605
+ default=None,
14606
+ description="""Optional. System instructions for pairwise metric.""",
14607
+ )
14608
+
14609
+
14610
+ class PairwiseMetricSpecDict(TypedDict, total=False):
14611
+ """Spec for pairwise metric."""
14612
+
14613
+ metric_prompt_template: Optional[str]
14614
+ """Required. Metric prompt template for pairwise metric."""
14615
+
14616
+ baseline_response_field_name: Optional[str]
14617
+ """Optional. The field name of the baseline response."""
14618
+
14619
+ candidate_response_field_name: Optional[str]
14620
+ """Optional. The field name of the candidate response."""
14621
+
14622
+ custom_output_format_config: Optional[CustomOutputFormatConfigDict]
14623
+ """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."""
14624
+
14625
+ system_instruction: Optional[str]
14626
+ """Optional. System instructions for pairwise metric."""
14627
+
14628
+
14629
+ PairwiseMetricSpecOrDict = Union[PairwiseMetricSpec, PairwiseMetricSpecDict]
14630
+
14631
+
14632
+ class PointwiseMetricSpec(_common.BaseModel):
14633
+ """Spec for pointwise metric."""
14634
+
14635
+ metric_prompt_template: Optional[str] = Field(
14636
+ default=None,
14637
+ description="""Required. Metric prompt template for pointwise metric.""",
14638
+ )
14639
+ custom_output_format_config: Optional[CustomOutputFormatConfig] = Field(
14640
+ default=None,
14641
+ 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.""",
14642
+ )
14643
+ system_instruction: Optional[str] = Field(
14644
+ default=None,
14645
+ description="""Optional. System instructions for pointwise metric.""",
14646
+ )
14647
+
14648
+
14649
+ class PointwiseMetricSpecDict(TypedDict, total=False):
14650
+ """Spec for pointwise metric."""
14651
+
14652
+ metric_prompt_template: Optional[str]
14653
+ """Required. Metric prompt template for pointwise metric."""
14654
+
14655
+ custom_output_format_config: Optional[CustomOutputFormatConfigDict]
14656
+ """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."""
14657
+
14658
+ system_instruction: Optional[str]
14659
+ """Optional. System instructions for pointwise metric."""
14660
+
14661
+
14662
+ PointwiseMetricSpecOrDict = Union[PointwiseMetricSpec, PointwiseMetricSpecDict]
14663
+
14664
+
14665
+ class RougeSpec(_common.BaseModel):
14666
+ """Spec for rouge metric."""
14667
+
14668
+ rouge_type: Optional[str] = Field(
14669
+ default=None,
14670
+ description="""Optional. Supported rouge types are rougen[1-9], rougeL, and rougeLsum.""",
14671
+ )
14672
+ split_summaries: Optional[bool] = Field(
14673
+ default=None,
14674
+ description="""Optional. Whether to split summaries while using rougeLsum.""",
14675
+ )
14676
+ use_stemmer: Optional[bool] = Field(
14677
+ default=None,
14678
+ description="""Optional. Whether to use stemmer to compute rouge score.""",
14679
+ )
14680
+
14681
+
14682
+ class RougeSpecDict(TypedDict, total=False):
14683
+ """Spec for rouge metric."""
14684
+
14685
+ rouge_type: Optional[str]
14686
+ """Optional. Supported rouge types are rougen[1-9], rougeL, and rougeLsum."""
14687
+
14688
+ split_summaries: Optional[bool]
14689
+ """Optional. Whether to split summaries while using rougeLsum."""
14690
+
14691
+ use_stemmer: Optional[bool]
14692
+ """Optional. Whether to use stemmer to compute rouge score."""
14693
+
14694
+
14695
+ RougeSpecOrDict = Union[RougeSpec, RougeSpecDict]