mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 19:54:13 +00:00
fix(vertex_httpx.py): Fix tool calling with empty param list
Fixes https://github.com/BerriAI/litellm/issues/5055
This commit is contained in:
parent
a34aeafdb5
commit
07bd92b527
3 changed files with 38 additions and 1 deletions
|
@ -205,8 +205,9 @@ class GoogleAIStudioGeminiConfig: # key diff from VertexAI - 'frequency_penalty
|
||||||
gtool_func_declaration = FunctionDeclaration(
|
gtool_func_declaration = FunctionDeclaration(
|
||||||
name=tool["function"]["name"],
|
name=tool["function"]["name"],
|
||||||
description=tool["function"].get("description", ""),
|
description=tool["function"].get("description", ""),
|
||||||
parameters=_parameters,
|
|
||||||
)
|
)
|
||||||
|
if len(_parameters.keys()) > 0:
|
||||||
|
gtool_func_declaration["parameters"] = _parameters
|
||||||
gtool_func_declarations.append(gtool_func_declaration)
|
gtool_func_declarations.append(gtool_func_declaration)
|
||||||
optional_params["tools"] = [
|
optional_params["tools"] = [
|
||||||
Tools(function_declarations=gtool_func_declarations)
|
Tools(function_declarations=gtool_func_declarations)
|
||||||
|
|
|
@ -2796,6 +2796,18 @@
|
||||||
"tool_use_system_prompt_tokens": 159,
|
"tool_use_system_prompt_tokens": 159,
|
||||||
"supports_assistant_prefill": true
|
"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": {
|
"openrouter/anthropic/claude-3-sonnet": {
|
||||||
"max_tokens": 200000,
|
"max_tokens": 200000,
|
||||||
"input_cost_per_token": 0.000003,
|
"input_cost_per_token": 0.000003,
|
||||||
|
|
|
@ -337,3 +337,27 @@ def test_groq_parallel_function_call():
|
||||||
print("second response\n", second_response)
|
print("second response\n", second_response)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pytest.fail(f"Error occurred: {e}")
|
pytest.fail(f"Error occurred: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue