Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions google/genai/_live_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,6 @@ def _GenerationConfig_to_vertex(
getv(from_object, ['model_selection_config']),
)

if getv(from_object, ['response_json_schema']) is not None:
setv(
to_object,
['responseJsonSchema'],
getv(from_object, ['response_json_schema']),
)

if getv(from_object, ['audio_timestamp']) is not None:
setv(to_object, ['audioTimestamp'], getv(from_object, ['audio_timestamp']))

Expand Down Expand Up @@ -195,6 +188,13 @@ def _GenerationConfig_to_vertex(
to_object, ['presencePenalty'], getv(from_object, ['presence_penalty'])
)

if getv(from_object, ['response_json_schema']) is not None:
setv(
to_object,
['responseJsonSchema'],
getv(from_object, ['response_json_schema']),
)

if getv(from_object, ['response_logprobs']) is not None:
setv(
to_object,
Expand Down
148 changes: 76 additions & 72 deletions google/genai/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,60 +849,62 @@ def _GenerateContentConfig_to_mldev(
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}

if getv(from_object, ['system_instruction']) is not None:
setv(
parent_object,
['systemInstruction'],
_Content_to_mldev(
t.t_content(getv(from_object, ['system_instruction'])), to_object
),
if getv(from_object, ['model_selection_config']) is not None:
raise ValueError(
'model_selection_config parameter is not supported in Gemini API.'
)

if getv(from_object, ['temperature']) is not None:
setv(to_object, ['temperature'], getv(from_object, ['temperature']))

if getv(from_object, ['top_p']) is not None:
setv(to_object, ['topP'], getv(from_object, ['top_p']))

if getv(from_object, ['top_k']) is not None:
setv(to_object, ['topK'], getv(from_object, ['top_k']))
if getv(from_object, ['audio_timestamp']) is not None:
raise ValueError(
'audio_timestamp parameter is not supported in Gemini API.'
)

if getv(from_object, ['candidate_count']) is not None:
setv(to_object, ['candidateCount'], getv(from_object, ['candidate_count']))

if getv(from_object, ['max_output_tokens']) is not None:
setv(
to_object, ['maxOutputTokens'], getv(from_object, ['max_output_tokens'])
if getv(from_object, ['enable_affective_dialog']) is not None:
raise ValueError(
'enable_affective_dialog parameter is not supported in Gemini API.'
)

if getv(from_object, ['stop_sequences']) is not None:
setv(to_object, ['stopSequences'], getv(from_object, ['stop_sequences']))

if getv(from_object, ['response_logprobs']) is not None:
if getv(from_object, ['frequency_penalty']) is not None:
setv(
to_object,
['responseLogprobs'],
getv(from_object, ['response_logprobs']),
['frequencyPenalty'],
getv(from_object, ['frequency_penalty']),
)

if getv(from_object, ['logprobs']) is not None:
setv(to_object, ['logprobs'], getv(from_object, ['logprobs']))

if getv(from_object, ['max_output_tokens']) is not None:
setv(
to_object, ['maxOutputTokens'], getv(from_object, ['max_output_tokens'])
)

if getv(from_object, ['media_resolution']) is not None:
setv(
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
)

if getv(from_object, ['presence_penalty']) is not None:
setv(
to_object, ['presencePenalty'], getv(from_object, ['presence_penalty'])
)

if getv(from_object, ['frequency_penalty']) is not None:
if getv(from_object, ['response_json_schema']) is not None:
setv(
to_object,
['frequencyPenalty'],
getv(from_object, ['frequency_penalty']),
['responseJsonSchema'],
getv(from_object, ['response_json_schema']),
)

if getv(from_object, ['seed']) is not None:
setv(to_object, ['seed'], getv(from_object, ['seed']))
if getv(from_object, ['response_logprobs']) is not None:
setv(
to_object,
['responseLogprobs'],
getv(from_object, ['response_logprobs']),
)

if getv(from_object, ['response_mime_type']) is not None:
setv(
Expand All @@ -911,26 +913,62 @@ def _GenerateContentConfig_to_mldev(
getv(from_object, ['response_mime_type']),
)

if getv(from_object, ['response_modalities']) is not None:
setv(
to_object,
['responseModalities'],
getv(from_object, ['response_modalities']),
)

if getv(from_object, ['response_schema']) is not None:
setv(
to_object,
['responseSchema'],
t.t_schema(api_client, getv(from_object, ['response_schema'])),
)

if getv(from_object, ['response_json_schema']) is not None:
if getv(from_object, ['routing_config']) is not None:
raise ValueError('routing_config parameter is not supported in Gemini API.')

if getv(from_object, ['seed']) is not None:
setv(to_object, ['seed'], getv(from_object, ['seed']))

if getv(from_object, ['speech_config']) is not None:
setv(
to_object,
['responseJsonSchema'],
getv(from_object, ['response_json_schema']),
['speechConfig'],
t.t_speech_config(getv(from_object, ['speech_config'])),
)

if getv(from_object, ['routing_config']) is not None:
raise ValueError('routing_config parameter is not supported in Gemini API.')
if getv(from_object, ['stop_sequences']) is not None:
setv(to_object, ['stopSequences'], getv(from_object, ['stop_sequences']))

if getv(from_object, ['model_selection_config']) is not None:
raise ValueError(
'model_selection_config parameter is not supported in Gemini API.'
if getv(from_object, ['temperature']) is not None:
setv(to_object, ['temperature'], getv(from_object, ['temperature']))

if getv(from_object, ['thinking_config']) is not None:
setv(to_object, ['thinkingConfig'], getv(from_object, ['thinking_config']))

if getv(from_object, ['top_k']) is not None:
setv(to_object, ['topK'], getv(from_object, ['top_k']))

if getv(from_object, ['top_p']) is not None:
setv(to_object, ['topP'], getv(from_object, ['top_p']))

if getv(from_object, ['enable_enhanced_civic_answers']) is not None:
setv(
to_object,
['enableEnhancedCivicAnswers'],
getv(from_object, ['enable_enhanced_civic_answers']),
)

if getv(from_object, ['system_instruction']) is not None:
setv(
parent_object,
['systemInstruction'],
_Content_to_mldev(
t.t_content(getv(from_object, ['system_instruction'])), to_object
),
)

if getv(from_object, ['safety_settings']) is not None:
Expand Down Expand Up @@ -972,47 +1010,13 @@ def _GenerateContentConfig_to_mldev(
),
)

if getv(from_object, ['response_modalities']) is not None:
setv(
to_object,
['responseModalities'],
getv(from_object, ['response_modalities']),
)

if getv(from_object, ['media_resolution']) is not None:
setv(
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
)

if getv(from_object, ['speech_config']) is not None:
setv(
to_object,
['speechConfig'],
t.t_speech_config(getv(from_object, ['speech_config'])),
)

if getv(from_object, ['audio_timestamp']) is not None:
raise ValueError(
'audio_timestamp parameter is not supported in Gemini API.'
)

if getv(from_object, ['thinking_config']) is not None:
setv(to_object, ['thinkingConfig'], getv(from_object, ['thinking_config']))

if getv(from_object, ['image_config']) is not None:
setv(
to_object,
['imageConfig'],
_ImageConfig_to_mldev(getv(from_object, ['image_config']), to_object),
)

if getv(from_object, ['enable_enhanced_civic_answers']) is not None:
setv(
to_object,
['enableEnhancedCivicAnswers'],
getv(from_object, ['enable_enhanced_civic_answers']),
)

return to_object


Expand Down
Loading
Loading