Skip to content

Commit 9fb22d4

Browse files
jaycee-licopybara-github
authored andcommitted
chore: Use both Gemini and Vertex discovery docs in the generator
feat: Add enable_enhanced_civic_answers in GenerationConfig feat: Add grounding_attributions in Candidate PiperOrigin-RevId: 810594082
1 parent f0083a2 commit 9fb22d4

File tree

7 files changed

+229
-100
lines changed

7 files changed

+229
-100
lines changed

google/genai/_live_converters.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ def _GenerationConfig_to_vertex(
226226
if getv(from_object, ['top_p']) is not None:
227227
setv(to_object, ['topP'], getv(from_object, ['top_p']))
228228

229+
if getv(from_object, ['enable_enhanced_civic_answers']) is not None:
230+
raise ValueError(
231+
'enable_enhanced_civic_answers parameter is not supported in Vertex AI.'
232+
)
233+
229234
return to_object
230235

231236

google/genai/batches.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,13 @@ def _Candidate_from_mldev(
433433
[item for item in getv(from_object, ['safetyRatings'])],
434434
)
435435

436+
if getv(from_object, ['groundingAttributions']) is not None:
437+
setv(
438+
to_object,
439+
['grounding_attributions'],
440+
[item for item in getv(from_object, ['groundingAttributions'])],
441+
)
442+
436443
return to_object
437444

438445

google/genai/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ def _Candidate_from_mldev(
124124
[item for item in getv(from_object, ['safetyRatings'])],
125125
)
126126

127+
if getv(from_object, ['groundingAttributions']) is not None:
128+
setv(
129+
to_object,
130+
['grounding_attributions'],
131+
[item for item in getv(from_object, ['groundingAttributions'])],
132+
)
133+
127134
return to_object
128135

129136

@@ -2398,6 +2405,11 @@ def _GenerationConfig_to_vertex(
23982405
if getv(from_object, ['top_p']) is not None:
23992406
setv(to_object, ['topP'], getv(from_object, ['top_p']))
24002407

2408+
if getv(from_object, ['enable_enhanced_civic_answers']) is not None:
2409+
raise ValueError(
2410+
'enable_enhanced_civic_answers parameter is not supported in Vertex AI.'
2411+
)
2412+
24012413
return to_object
24022414

24032415

google/genai/tests/live/test_live.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,11 @@ async def test_bidi_setup_to_api_speech_config(vertexai):
720720
result = await get_connect_message(
721721
mock_api_client(vertexai=vertexai), model='test_model', config=config_dict
722722
)
723-
assert result == expected_result
723+
assert types.LiveClientMessage._from_response(
724+
response=result, kwargs=None
725+
) == types.LiveClientMessage._from_response(
726+
response=expected_result, kwargs=None
727+
)
724728
# Config is a LiveConnectConfig
725729
config = types.LiveConnectConfig(
726730
speech_config=types.SpeechConfig(
@@ -745,7 +749,11 @@ async def test_bidi_setup_to_api_speech_config(vertexai):
745749
mock_api_client(vertexai=vertexai),
746750
model='test_model', config=config
747751
)
748-
assert result == expected_result
752+
assert types.LiveClientMessage._from_response(
753+
response=result, kwargs=None
754+
) == types.LiveClientMessage._from_response(
755+
response=expected_result, kwargs=None
756+
)
749757

750758

751759
@pytest.mark.parametrize('vertexai', [True, False])

google/genai/tests/operations/test_get.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2025 Google LLC
1+
# Copyright 2025 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

google/genai/tunings.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -551,36 +551,6 @@ def _TuningJob_from_mldev(
551551
_TunedModel_from_mldev(getv(from_object, ['_self']), to_object),
552552
)
553553

554-
if getv(from_object, ['customBaseModel']) is not None:
555-
setv(
556-
to_object, ['custom_base_model'], getv(from_object, ['customBaseModel'])
557-
)
558-
559-
if getv(from_object, ['experiment']) is not None:
560-
setv(to_object, ['experiment'], getv(from_object, ['experiment']))
561-
562-
if getv(from_object, ['labels']) is not None:
563-
setv(to_object, ['labels'], getv(from_object, ['labels']))
564-
565-
if getv(from_object, ['outputUri']) is not None:
566-
setv(to_object, ['output_uri'], getv(from_object, ['outputUri']))
567-
568-
if getv(from_object, ['pipelineJob']) is not None:
569-
setv(to_object, ['pipeline_job'], getv(from_object, ['pipelineJob']))
570-
571-
if getv(from_object, ['serviceAccount']) is not None:
572-
setv(to_object, ['service_account'], getv(from_object, ['serviceAccount']))
573-
574-
if getv(from_object, ['tunedModelDisplayName']) is not None:
575-
setv(
576-
to_object,
577-
['tuned_model_display_name'],
578-
getv(from_object, ['tunedModelDisplayName']),
579-
)
580-
581-
if getv(from_object, ['veoTuningSpec']) is not None:
582-
setv(to_object, ['veo_tuning_spec'], getv(from_object, ['veoTuningSpec']))
583-
584554
return to_object
585555

586556

0 commit comments

Comments
 (0)