New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix the issues when using tools in gemini #1969
fix: fix the issues when using tools in gemini #1969
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@kan-bayashi could you upload a screenshot of this working with multiple tools for confirmation? |
Hi @krrishdholakia. I updated the PR description, please check it.
I also fixed the issue in |
@krrishdholakia litellm/litellm/llms/vertex_ai.py Lines 435 to 437 in e590f47
should be if tools is not None and bool(
getattr(response.candidates[0].content.parts[0], "function_call", None)
): Then second completion looks fine.
I will make a commit to fix this issue. |
Now everything works fine! Please let me know if you find wondering points. |
Another example works correctly with multiple tools. import litellm
tools = [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
},
},
{
"type": "function",
"function": {
"name": "get_tomorrow_weather",
"description": "Get the tomorrow weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
},
},
{
"type": "function",
"function": {
"name": "get_yesterday_newyork_weather",
"description": "Get the tomorrow weather in New York yesterday",
"parameters": {
"type": "object",
"properties": {},
"required": [],
},
},
},
]
messages = [{"role": "user", "content": "What's the weather like in Boston today?"}]
completion = litellm.completion(
model="gemini-pro", messages=messages, tools=tools, tool_choice="auto"
)
print(messages)
print(completion)
messages = [{"role": "user", "content": "What's the weather like in Boston tomorrow?"}]
completion = litellm.completion(
model="gemini-pro", messages=messages, tools=tools, tool_choice="auto"
)
print(messages)
print(completion)
messages = [{"role": "user", "content": "What's the weather like in New York yesterday?"}]
completion = litellm.completion(
model="gemini-pro", messages=messages, tools=tools, tool_choice="auto"
)
print(messages)
print(completion)
|
nice! i need that fix |
This PR fixes the following two issues:
response.candidates[0].content.parts[0].function_call
exists but empty (not None)Error reproducible code
Before
After fix the first issue
After fix both issues