@@ -203,11 +203,11 @@ async def _make_request(
203
203
204
204
request_data = _GeminiRequest (contents = contents )
205
205
if sys_prompt_parts :
206
- request_data ['system_instruction ' ] = _GeminiTextContent (role = 'user' , parts = sys_prompt_parts )
206
+ request_data ['systemInstruction ' ] = _GeminiTextContent (role = 'user' , parts = sys_prompt_parts )
207
207
if tools is not None :
208
208
request_data ['tools' ] = tools
209
209
if tool_config is not None :
210
- request_data ['tool_config ' ] = tool_config
210
+ request_data ['toolConfig ' ] = tool_config
211
211
212
212
generation_config : _GeminiGenerationConfig = {}
213
213
if model_settings :
@@ -222,9 +222,9 @@ async def _make_request(
222
222
if (frequency_penalty := model_settings .get ('frequency_penalty' )) is not None :
223
223
generation_config ['frequency_penalty' ] = frequency_penalty
224
224
if (gemini_safety_settings := model_settings .get ('gemini_safety_settings' )) != []:
225
- request_data ['safety_settings ' ] = gemini_safety_settings
225
+ request_data ['safetySettings ' ] = gemini_safety_settings
226
226
if generation_config :
227
- request_data ['generation_config ' ] = generation_config
227
+ request_data ['generationConfig ' ] = generation_config
228
228
229
229
headers = {'Content-Type' : 'application/json' , 'User-Agent' : get_user_agent ()}
230
230
url = f'/{ self ._model_name } :{ "streamGenerateContent" if streamed else "generateContent" } '
@@ -450,17 +450,19 @@ class _GeminiRequest(TypedDict):
450
450
See <https://ai.google.dev/api/generate-content#request-body> for API docs.
451
451
"""
452
452
453
+ # Note: Even though Google supposedly supports camelCase and snake_case, we've had user report misbehavior
454
+ # when using snake_case, which is why this typeddict now uses camelCase. And anyway, the plan is to replace this
455
+ # with an official google SDK in the near future anyway.
453
456
contents : list [_GeminiContent ]
454
457
tools : NotRequired [_GeminiTools ]
455
- tool_config : NotRequired [_GeminiToolConfig ]
456
- safety_settings : NotRequired [list [GeminiSafetySettings ]]
457
- # we don't implement `generationConfig`, instead we use a named tool for the response
458
- system_instruction : NotRequired [_GeminiTextContent ]
458
+ toolConfig : NotRequired [_GeminiToolConfig ]
459
+ safetySettings : NotRequired [list [GeminiSafetySettings ]]
460
+ systemInstruction : NotRequired [_GeminiTextContent ]
459
461
"""
460
462
Developer generated system instructions, see
461
463
<https://ai.google.dev/gemini-api/docs/system-instructions?lang=rest>
462
464
"""
463
- generation_config : NotRequired [_GeminiGenerationConfig ]
465
+ generationConfig : NotRequired [_GeminiGenerationConfig ]
464
466
465
467
466
468
class GeminiSafetySettings (TypedDict ):
0 commit comments