Skip to content

Commit

Permalink
Gemini list as tool call param fix phi 2238 (#1687)
Browse files Browse the repository at this point in the history
## Description

This PR adds support for tools with input as a list for Gemini 

## Type of change

Please check the options that are relevant:

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Model update
- [ ] Infrastructure change

## Checklist

- [ ] My code follows Phidata's style guidelines and best practices
- [ ] I have performed a self-review of my code
- [ ] I have added docstrings and comments for complex logic
- [ ] My changes generate no new warnings or errors
- [ ] I have added cookbook examples for my new addition (if needed)
- [ ] I have updated requirements.txt/pyproject.toml (if needed)
- [ ] I have verified my changes in a clean environment
  • Loading branch information
ysolanky authored Jan 6, 2025
1 parent 65c33a8 commit 35b21fd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions phi/model/google/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,19 @@ def format_functions(self, params: Dict[str, Any]) -> Dict[str, Any]:
converted_properties = {}
for prop_key, prop_value in value.items():
property_type = prop_value.get("type")
if property_type == "array":
converted_properties[prop_key] = prop_value
continue
if isinstance(property_type, list):
# Create a copy to avoid modifying the original list
non_null_types = [t for t in property_type if t != "null"]
if non_null_types:
# Use the first non-null type
converted_type = non_null_types[0]
if converted_type == "array":
prop_value["type"] = converted_type
converted_properties[prop_key] = prop_value
continue
else:
# Default type if all types are 'null'
converted_type = "string"
Expand Down

0 comments on commit 35b21fd

Please sign in to comment.