Skip to content

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]

fix(vertex_httpx.py): Fix tool calling with empty param list

Krrish Dholakia8812da04e3ae
diff --git a/litellm/llms/vertex_httpx.py b/litellm/llms/vertex_httpx.py
index 8af8f6894e3..1b0ef52bcdf 100644
--- a/litellm/llms/vertex_httpx.py
+++ b/litellm/llms/vertex_httpx.py
@@ -205,8 +205,9 @@ class GoogleAIStudioGeminiConfig: # key diff from VertexAI - 'frequency_penalty
gtool_func_declaration = FunctionDeclaration(
name=tool["function"]["name"],
description=tool["function"].get("description", ""),
- parameters=_parameters,
)
+ if len(_parameters.keys()) > 0:
+ gtool_func_declaration["parameters"] = _parameters
gtool_func_declarations.append(gtool_func_declaration)
optional_params["tools"] = [
Tools(function_declarations=gtool_func_declarations)
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index ab36dbb6c94..0f483b083b6 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -2796,6 +2796,18 @@
"tool_use_system_prompt_tokens": 159,
"supports_assistant_prefill": true
},
+ "openrouter/anthropic/claude-3.5-sonnet:beta": {
+ "max_tokens": 4096,
+ "max_input_tokens": 200000,
+ "max_output_tokens": 4096,
+ "input_cost_per_token": 0.000003,
+ "output_cost_per_token": 0.000015,
+ "litellm_provider": "openrouter",
+ "mode": "chat",
+ "supports_function_calling": true,
+ "supports_vision": true,
+ "tool_use_system_prompt_tokens": 159
+ },
"openrouter/anthropic/claude-3-sonnet": {
"max_tokens": 200000,
"input_cost_per_token": 0.000003,
diff --git a/litellm/tests/test_function_calling.py b/litellm/tests/test_function_calling.py
index 5f97dbf87db..a42a2530053 100644
--- a/litellm/tests/test_function_calling.py
+++ b/litellm/tests/test_function_calling.py
@@ -337,3 +337,27 @@ def test_groq_parallel_function_call():
print("second response\n", second_response)
except Exception as e:
pytest.fail(f"Error occurred: {e}")
+
+
[email protected]("model", ["gemini/gemini-1.5-pro"])
+def test_simple_function_call_function_param(model):
+ try:
+ litellm.set_verbose = True
+ messages = [{"role": "user", "content": "What is the weather like in Boston?"}]
+ response = completion(
+ model=model,
+ messages=messages,
+ tools=[
+ {
+ "type": "function",
+ "function": {
+ "name": "plot",
+ "description": "Generate plots",
+ },
+ }
+ ],
+ tool_choice="auto",
+ )
+ print(f"response: {response}")
+ except Exception as e:
+ raise e