Skip to content

Commit

Permalink
simplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
Avi-Robusta committed Dec 19, 2024
1 parent 6d1c9a5 commit 92179ed
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions holmes/core/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,17 @@ def get_openai_format(self, model: Optional[str]):
"function": {
"name": self.name,
"description": self.description,
"parameters": {
"properties": tool_properties,
"required": [param_name for param_name, param_attributes in self.parameters.items() if param_attributes.required],
"type": "object",
}
},
}
is_gemini = "gemini" in model
# if there are no properties gemini removes it
is_gemini_with_tool_properties = is_gemini and tool_properties is not None

if not is_gemini or is_gemini_with_tool_properties:
result["function"]["parameters"] = {
"properties": tool_properties,
"required": [
param_name
for param_name, param_attributes in self.parameters.items()
if param_attributes.required
],
"type": "object",
}

# gemini doesnt have parameters object if it is without params
if "gemini" in model and tool_properties is None:
result["function"].pop("parameters")

return result

Expand Down

0 comments on commit 92179ed

Please sign in to comment.