The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Merge branch 'main' into litellm_gemini_context_caching
Krish Dholakia08bd4788dc28
diff --cc litellm/llms/vertex_ai_and_google_ai_studio/vertex_and_google_ai_studio_gemini.pyindex 6b87ac29e9e,0a7be19b9b0..5392f253f80--- a/litellm/llms/vertex_ai_and_google_ai_studio/vertex_and_google_ai_studio_gemini.py+++ b/litellm/llms/vertex_ai_and_google_ai_studio/vertex_and_google_ai_studio_gemini.py@@@ -307,6 -309,44 +309,43 @@@ class GoogleAIStudioGeminiConfig: # ke"n","stop",]-+ def _map_function(self, value: List[dict]) -> List[Tools]:+ gtool_func_declarations = []+ googleSearchRetrieval: Optional[dict] = None++ for tool in value:+ openai_function_object: Optional[ChatCompletionToolParamFunctionChunk] = (+ None+ )+ if "function" in tool: # tools list+ openai_function_object = ChatCompletionToolParamFunctionChunk( # type: ignore+ **tool["function"]+ )+ elif "name" in tool: # functions list+ openai_function_object = ChatCompletionToolParamFunctionChunk(**tool) # type: ignore++ # check if grounding+ if tool.get("googleSearchRetrieval", None) is not None:+ googleSearchRetrieval = tool["googleSearchRetrieval"]+ elif openai_function_object is not None:+ gtool_func_declaration = FunctionDeclaration(+ name=openai_function_object["name"],+ description=openai_function_object.get("description", ""),+ parameters=openai_function_object.get("parameters", {}),+ )+ gtool_func_declarations.append(gtool_func_declaration)+ else:+ # assume it's a provider-specific param+ verbose_logger.warning(+ "Invalid tool={}. Use `litellm.set_verbose` or `litellm --detailed_debug` to see raw request."+ )++ _tools = Tools(+ function_declarations=gtool_func_declarations,+ )+ if googleSearchRetrieval is not None:+ _tools["googleSearchRetrieval"] = googleSearchRetrieval+ return [_tools]def map_tool_choice_values(self, model: str, tool_choice: Union[str, dict]@@@ -920,19 -963,26 +962,24 @@@ class VertexLLM(BaseLLM)candidate["content"]["parts"][0]["functionCall"]["args"]),)- _tool_response_chunk = ChatCompletionToolCallChunk(- id=f"call_{str(uuid.uuid4())}",- type="function",- function=_function_chunk,- index=candidate.get("index", idx),- )- tools.append(_tool_response_chunk)-+ if litellm_params.get("litellm_param_is_function_call") is True:+ functions = _function_chunk+ else:+ _tool_response_chunk = ChatCompletionToolCallChunk(+ id=f"call_{str(uuid.uuid4())}",+ type="function",+ function=_function_chunk,+ index=candidate.get("index", idx),+ )+ tools.append(_tool_response_chunk)-chat_completion_message["content"] = (content_str if len(content_str) > 0 else None)- chat_completion_message["tool_calls"] = tools+ if len(tools) > 0:+ chat_completion_message["tool_calls"] = tools+ if functions is not None:+ chat_completion_message["function_call"] = functions-choice = litellm.Choices(finish_reason=candidate.get("finishReason", "stop"),index=candidate.get("index", idx),