feat(vertex_httpx.py): Support gemini 'response_schema' param

Fixes https://github.com/BerriAI/litellm/pull/3366#issuecomment-2269183338
This commit is contained in:
Krrish Dholakia 2024-08-05 07:56:44 -07:00
parent 1c747f3ad3
commit aab09f5b86
2 changed files with 10 additions and 4 deletions

View file

@ -182,7 +182,12 @@ class GoogleAIStudioGeminiConfig: # key diff from VertexAI - 'frequency_penalty
if param == "max_tokens":
optional_params["max_output_tokens"] = value
if param == "response_format" and value["type"] == "json_object": # type: ignore
optional_params["response_mime_type"] = "application/json"
if value["type"] == "json_object": # type: ignore
optional_params["response_mime_type"] = "application/json"
elif value["type"] == "text": # type: ignore
optional_params["response_mime_type"] = "text/plain"
if "response_schema" in value: # type: ignore
optional_params["response_schema"] = value["response_schema"] # type: ignore
if param == "tools" and isinstance(value, list):
gtool_func_declarations = []
for tool in value: