Skip to content

Commit 470ad3a

Browse files
MarkDaoustcopybara-github
authored andcommitted
chore:test
PiperOrigin-RevId: 888287753
1 parent aed1559 commit 470ad3a

File tree

4 files changed

+49
-13
lines changed

4 files changed

+49
-13
lines changed

google/genai/batches.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,9 @@ def _GenerateContentConfig_to_mldev(
10521052
'model_armor_config parameter is not supported in Gemini API.'
10531053
)
10541054

1055+
if getv(from_object, ['service_tier']) is not None:
1056+
setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier']))
1057+
10551058
return to_object
10561059

10571060

google/genai/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,9 @@ def _GenerateContentConfig_to_mldev(
13161316
'model_armor_config parameter is not supported in Gemini API.'
13171317
)
13181318

1319+
if getv(from_object, ['service_tier']) is not None:
1320+
setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier']))
1321+
13191322
return to_object
13201323

13211324

@@ -1502,6 +1505,9 @@ def _GenerateContentConfig_to_vertex(
15021505
getv(from_object, ['model_armor_config']),
15031506
)
15041507

1508+
if getv(from_object, ['service_tier']) is not None:
1509+
raise ValueError('service_tier parameter is not supported in Vertex AI.')
1510+
15051511
return to_object
15061512

15071513

google/genai/tests/models/test_generate_content.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ class InstrumentEnum(Enum):
142142
model=GEMINI_FLASH_LATEST,
143143
contents=t.t_contents('high'),
144144
config={
145-
'system_instruction': t.t_content(
146-
'I say high, you say low'
147-
)
145+
'system_instruction': t.t_content('I say high, you say low')
148146
},
149147
),
150148
),
@@ -237,13 +235,13 @@ class InstrumentEnum(Enum):
237235
config=types.GenerateContentConfig(
238236
tools=[{'google_maps': {}}],
239237
tool_config={
240-
"retrieval_config": {
241-
"lat_lng": {
242-
"latitude": 37.421993,
243-
"longitude": -122.079725,
238+
'retrieval_config': {
239+
'lat_lng': {
240+
'latitude': 37.421993,
241+
'longitude': -122.079725,
244242
}
245243
}
246-
}
244+
},
247245
),
248246
),
249247
),
@@ -357,9 +355,7 @@ class InstrumentEnum(Enum):
357355
name='test_speech_with_config',
358356
parameters=types._GenerateContentParameters(
359357
model='gemini-2.5-flash-preview-tts',
360-
contents=t.t_contents(
361-
'Produce a speech response saying "Cheese"'
362-
),
358+
contents=t.t_contents('Produce a speech response saying "Cheese"'),
363359
config=types.GenerateContentConfig(
364360
response_modalities=['audio'],
365361
speech_config=types.SpeechConfig(
@@ -536,8 +532,8 @@ class InstrumentEnum(Enum):
536532
parameters=types._GenerateContentParameters(
537533
model=GEMINI_FLASH_LATEST,
538534
contents=t.t_contents(
539-
'Summarize the evidence that confirms widespread voter fraud was'
540-
' the reason the last national election results were'
535+
'Summarize the evidence that confirms widespread voter fraud'
536+
' was the reason the last national election results were'
541537
' inaccurate.'
542538
),
543539
config={
@@ -562,6 +558,17 @@ class InstrumentEnum(Enum):
562558
),
563559
exception_if_mldev='not supported',
564560
),
561+
pytest_helper.TestTableItem(
562+
name='test_service_tier',
563+
parameters=types._GenerateContentParameters(
564+
model=GEMINI_FLASH_LATEST,
565+
contents=t.t_contents('What is your name?'),
566+
config={
567+
'service_tier': 'flex',
568+
},
569+
),
570+
exception_if_vertex='not supported',
571+
),
565572
]
566573

567574
pytestmark = pytest_helper.setup(

google/genai/types.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,19 @@ class ResourceScope(_common.CaseInSensitiveEnum):
831831
"https://aiplatform.googleapis.com/publishers/google/models/gemini-3-pro-preview"""
832832

833833

834+
class ServiceTier(_common.CaseInSensitiveEnum):
835+
"""Pricing and performance service tier."""
836+
837+
unspecified = 'unspecified'
838+
"""Default service tier, which is standard."""
839+
standard = 'standard'
840+
"""Standard service tier."""
841+
flex = 'flex'
842+
"""Flex service tier."""
843+
priority = 'priority'
844+
"""Priority service tier."""
845+
846+
834847
class JSONSchemaType(Enum):
835848
"""The type of the data supported by JSON Schema.
836849

@@ -5933,6 +5946,10 @@ class GenerateContentConfig(_common.BaseModel):
59335946
service. If supplied, safety_settings must not be supplied.
59345947
""",
59355948
)
5949+
service_tier: Optional[ServiceTier] = Field(
5950+
default=None,
5951+
description="""The service tier to use for the request. For example, FLEX.""",
5952+
)
59365953

59375954
@pydantic.field_validator('response_schema', mode='before')
59385955
@classmethod
@@ -6147,6 +6164,9 @@ class GenerateContentConfigDict(TypedDict, total=False):
61476164
service. If supplied, safety_settings must not be supplied.
61486165
"""
61496166

6167+
service_tier: Optional[ServiceTier]
6168+
"""The service tier to use for the request. For example, FLEX."""
6169+
61506170

61516171
GenerateContentConfigOrDict = Union[
61526172
GenerateContentConfig, GenerateContentConfigDict

0 commit comments

Comments
 (0)