Skip to content
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

Gemini list as tool call param fix phi 2238 #1687

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading