Skip to content

Commit

Permalink
add additionalProperties in defs for strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
VRSEN committed Aug 18, 2024
1 parent 43b1267 commit 2791517
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion agency_swarm/tools/BaseTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class BaseTool(BaseModel, ABC):
_event_handler: Any = None

def __init__(self, **kwargs):
super().__init__(**kwargs)
if not self.__class__._shared_state:
self.__class__._shared_state = SharedState()
super().__init__(**kwargs)

class ToolConfig:
strict: bool = False
Expand Down Expand Up @@ -68,6 +68,10 @@ def openai_schema(cls):
if strict:
schema["strict"] = True
schema["parameters"]["additionalProperties"] = False
# iterate through defs and set additionalProperties to false
if "$defs" in schema["parameters"]:
for def_ in schema["parameters"]["$defs"].values():
def_["additionalProperties"] = False
else:
schema["strict"] = False

Expand Down

0 comments on commit 2791517

Please sign in to comment.