Update tools.py
Browse files
tools.py
CHANGED
@@ -65,23 +65,44 @@ class HubStatsTool(Tool):
|
|
65 |
except Exception as e:
|
66 |
return f"Error fetching models for {author}: {str(e)}"
|
67 |
|
68 |
-
class
|
69 |
-
name = "
|
70 |
-
description = "
|
71 |
inputs = {
|
72 |
-
"
|
|
|
|
|
|
|
|
|
73 |
"type": "string",
|
74 |
-
"description": "The
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
}
|
77 |
output_type = "string"
|
78 |
|
79 |
-
def
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
class CalendarTool(Tool):
|
87 |
name = "calendar"
|
|
|
65 |
except Exception as e:
|
66 |
return f"Error fetching models for {author}: {str(e)}"
|
67 |
|
68 |
+
class CalendarTool(Tool):
|
69 |
+
name = "calendar"
|
70 |
+
description = "Manages and retrieves information about dates and events."
|
71 |
inputs = {
|
72 |
+
"action": {
|
73 |
+
"type": "string",
|
74 |
+
"description": "The action to perform (e.g., 'add', 'get', 'delete')."
|
75 |
+
},
|
76 |
+
"date": {
|
77 |
"type": "string",
|
78 |
+
"description": "The date of the event (format: YYYY-MM-DD)."
|
79 |
+
},
|
80 |
+
"event": {
|
81 |
+
"type": "string",
|
82 |
+
"description": "The event description.",
|
83 |
+
"nullable": True # Add this line to specify that 'event' is nullable
|
84 |
}
|
85 |
}
|
86 |
output_type = "string"
|
87 |
|
88 |
+
def __init__(self):
|
89 |
+
self.events = {}
|
90 |
+
|
91 |
+
def forward(self, action: str, date: str, event: str = None):
|
92 |
+
if action == "add":
|
93 |
+
self.events[date] = event
|
94 |
+
return f"Event '{event}' added to {date}."
|
95 |
+
elif action == "get":
|
96 |
+
return f"Event on {date}: {self.events.get(date, 'No event found.')}"
|
97 |
+
elif action == "delete":
|
98 |
+
if date in self.events:
|
99 |
+
del self.events[date]
|
100 |
+
return f"Event on {date} deleted."
|
101 |
+
else:
|
102 |
+
return f"No event found on {date}."
|
103 |
+
else:
|
104 |
+
return "Invalid action."
|
105 |
+
|
106 |
|
107 |
class CalendarTool(Tool):
|
108 |
name = "calendar"
|