Spaces:
Runtime error
Runtime error
Commit
·
d2aba87
1
Parent(s):
51e2c4c
Add task description field to CreateTaskTool and UpdateTaskTool for enhanced task details
Browse files
agency_ai_demo/agents/NotionProjectAgent/tools/CreateTask.py
CHANGED
@@ -28,6 +28,11 @@ class CreateTaskTool(BaseTool):
|
|
28 |
description="The title of the task (required).",
|
29 |
)
|
30 |
|
|
|
|
|
|
|
|
|
|
|
31 |
status: str = Field(
|
32 |
default=None,
|
33 |
description="Status of the task. Options: Backlog, In Progress, In Review, Testing, Completed.",
|
@@ -105,6 +110,14 @@ class CreateTaskTool(BaseTool):
|
|
105 |
"title": [{"type": "text", "text": {"content": self.title}}]
|
106 |
}
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
# Add status if provided
|
109 |
if self.status:
|
110 |
properties["Status"] = {"status": {"name": self.status}}
|
|
|
28 |
description="The title of the task (required).",
|
29 |
)
|
30 |
|
31 |
+
task_description: str = Field(
|
32 |
+
default=None,
|
33 |
+
description="A text description of the task.",
|
34 |
+
)
|
35 |
+
|
36 |
status: str = Field(
|
37 |
default=None,
|
38 |
description="Status of the task. Options: Backlog, In Progress, In Review, Testing, Completed.",
|
|
|
110 |
"title": [{"type": "text", "text": {"content": self.title}}]
|
111 |
}
|
112 |
|
113 |
+
# Add task description if provided
|
114 |
+
if self.task_description:
|
115 |
+
properties["Task Description"] = {
|
116 |
+
"rich_text": [
|
117 |
+
{"type": "text", "text": {"content": self.task_description}}
|
118 |
+
]
|
119 |
+
}
|
120 |
+
|
121 |
# Add status if provided
|
122 |
if self.status:
|
123 |
properties["Status"] = {"status": {"name": self.status}}
|
agency_ai_demo/agents/NotionProjectAgent/tools/GetTask.py
CHANGED
@@ -13,7 +13,7 @@ class GetTaskTool(BaseTool):
|
|
13 |
"""
|
14 |
Tool for retrieving a specific task (page) from Notion.
|
15 |
This tool fetches the properties of a specific task using its page ID and
|
16 |
-
by default,
|
17 |
"""
|
18 |
|
19 |
# Add example_field with a default value to satisfy BaseTool validation
|
@@ -28,7 +28,7 @@ class GetTaskTool(BaseTool):
|
|
28 |
)
|
29 |
|
30 |
include_content: bool = Field(
|
31 |
-
default=
|
32 |
description="Whether to include the page content (blocks) in the response. When True, all nested blocks will be included.",
|
33 |
)
|
34 |
|
|
|
13 |
"""
|
14 |
Tool for retrieving a specific task (page) from Notion.
|
15 |
This tool fetches the properties of a specific task using its page ID and
|
16 |
+
by default, does not fetch the page content (blocks). Content can be included by setting include_content to True.
|
17 |
"""
|
18 |
|
19 |
# Add example_field with a default value to satisfy BaseTool validation
|
|
|
28 |
)
|
29 |
|
30 |
include_content: bool = Field(
|
31 |
+
default=False,
|
32 |
description="Whether to include the page content (blocks) in the response. When True, all nested blocks will be included.",
|
33 |
)
|
34 |
|
agency_ai_demo/agents/NotionProjectAgent/tools/GetTasks.py
CHANGED
@@ -19,37 +19,37 @@ class GetTasksTool(BaseTool):
|
|
19 |
# Add example_field with a default value to satisfy BaseTool validation
|
20 |
example_field: str = Field(
|
21 |
default="notion_tasks",
|
22 |
-
description="Identifier for this tool. Can be left at its default value."
|
23 |
)
|
24 |
|
25 |
status: str = Field(
|
26 |
default=None,
|
27 |
-
description="Filter tasks by status. Options: Backlog, In Progress, In Review, Testing, Completed."
|
28 |
)
|
29 |
-
|
30 |
priority: str = Field(
|
31 |
default=None,
|
32 |
-
description="Filter tasks by priority. Options: High, Medium, Low."
|
33 |
)
|
34 |
-
|
35 |
due_date_before: str = Field(
|
36 |
default=None,
|
37 |
-
description="Filter tasks due before this date (format: YYYY-MM-DD)."
|
38 |
)
|
39 |
-
|
40 |
due_date_after: str = Field(
|
41 |
default=None,
|
42 |
-
description="Filter tasks due after this date (format: YYYY-MM-DD)."
|
43 |
)
|
44 |
-
|
45 |
sort_by: str = Field(
|
46 |
default="Due Date",
|
47 |
-
description="Property to sort by. Options: Due Date, Status, Priority, Task Name."
|
48 |
)
|
49 |
-
|
50 |
sort_direction: str = Field(
|
51 |
default="ascending",
|
52 |
-
description="Sort direction. Options: ascending, descending."
|
53 |
)
|
54 |
|
55 |
def run(self):
|
@@ -60,7 +60,7 @@ class GetTasksTool(BaseTool):
|
|
60 |
dict: The JSON response from the Notion API containing the tasks.
|
61 |
"""
|
62 |
import requests
|
63 |
-
|
64 |
# Use the database ID from the environment variable
|
65 |
database_id = os.getenv("NOTION_DATABASE_ID")
|
66 |
|
@@ -76,61 +76,42 @@ class GetTasksTool(BaseTool):
|
|
76 |
|
77 |
# Prepare the request body
|
78 |
data = {}
|
79 |
-
|
80 |
# Build filter
|
81 |
filters = []
|
82 |
-
|
83 |
if self.status:
|
84 |
-
filters.append({
|
85 |
-
|
86 |
-
"status": {
|
87 |
-
"equals": self.status
|
88 |
-
}
|
89 |
-
})
|
90 |
-
|
91 |
if self.priority:
|
92 |
-
filters.append(
|
93 |
-
"property": "Priority",
|
94 |
-
|
95 |
-
|
96 |
-
}
|
97 |
-
})
|
98 |
-
|
99 |
if self.due_date_before:
|
100 |
-
filters.append(
|
101 |
-
"property": "Due Date",
|
102 |
-
|
103 |
-
|
104 |
-
}
|
105 |
-
})
|
106 |
-
|
107 |
if self.due_date_after:
|
108 |
-
filters.append(
|
109 |
-
"property": "Due Date",
|
110 |
-
|
111 |
-
|
112 |
-
}
|
113 |
-
})
|
114 |
-
|
115 |
if filters:
|
116 |
if len(filters) > 1:
|
117 |
-
data["filter"] = {
|
118 |
-
"and": filters
|
119 |
-
}
|
120 |
else:
|
121 |
data["filter"] = filters[0]
|
122 |
-
|
123 |
# Add sorting
|
124 |
if self.sort_by:
|
125 |
data["sorts"] = [
|
126 |
-
{
|
127 |
-
"property": self.sort_by,
|
128 |
-
"direction": self.sort_direction
|
129 |
-
}
|
130 |
]
|
131 |
|
132 |
# Make the request
|
133 |
response = requests.post(url, headers=headers, json=data)
|
134 |
|
135 |
# Return the JSON response
|
136 |
-
return response.json()
|
|
|
19 |
# Add example_field with a default value to satisfy BaseTool validation
|
20 |
example_field: str = Field(
|
21 |
default="notion_tasks",
|
22 |
+
description="Identifier for this tool. Can be left at its default value.",
|
23 |
)
|
24 |
|
25 |
status: str = Field(
|
26 |
default=None,
|
27 |
+
description="Filter tasks by status. Options: Backlog, In Progress, In Review, Testing, Completed.",
|
28 |
)
|
29 |
+
|
30 |
priority: str = Field(
|
31 |
default=None,
|
32 |
+
description="Filter tasks by priority. Options: High, Medium, Low.",
|
33 |
)
|
34 |
+
|
35 |
due_date_before: str = Field(
|
36 |
default=None,
|
37 |
+
description="Filter tasks due before this date (format: YYYY-MM-DD).",
|
38 |
)
|
39 |
+
|
40 |
due_date_after: str = Field(
|
41 |
default=None,
|
42 |
+
description="Filter tasks due after this date (format: YYYY-MM-DD).",
|
43 |
)
|
44 |
+
|
45 |
sort_by: str = Field(
|
46 |
default="Due Date",
|
47 |
+
description="Property to sort by. Options: Due Date, Status, Priority, Task Name.",
|
48 |
)
|
49 |
+
|
50 |
sort_direction: str = Field(
|
51 |
default="ascending",
|
52 |
+
description="Sort direction. Options: ascending, descending.",
|
53 |
)
|
54 |
|
55 |
def run(self):
|
|
|
60 |
dict: The JSON response from the Notion API containing the tasks.
|
61 |
"""
|
62 |
import requests
|
63 |
+
|
64 |
# Use the database ID from the environment variable
|
65 |
database_id = os.getenv("NOTION_DATABASE_ID")
|
66 |
|
|
|
76 |
|
77 |
# Prepare the request body
|
78 |
data = {}
|
79 |
+
|
80 |
# Build filter
|
81 |
filters = []
|
82 |
+
|
83 |
if self.status:
|
84 |
+
filters.append({"property": "Status", "status": {"equals": self.status}})
|
85 |
+
|
|
|
|
|
|
|
|
|
|
|
86 |
if self.priority:
|
87 |
+
filters.append(
|
88 |
+
{"property": "Priority", "select": {"equals": self.priority}}
|
89 |
+
)
|
90 |
+
|
|
|
|
|
|
|
91 |
if self.due_date_before:
|
92 |
+
filters.append(
|
93 |
+
{"property": "Due Date", "date": {"before": self.due_date_before}}
|
94 |
+
)
|
95 |
+
|
|
|
|
|
|
|
96 |
if self.due_date_after:
|
97 |
+
filters.append(
|
98 |
+
{"property": "Due Date", "date": {"after": self.due_date_after}}
|
99 |
+
)
|
100 |
+
|
|
|
|
|
|
|
101 |
if filters:
|
102 |
if len(filters) > 1:
|
103 |
+
data["filter"] = {"and": filters}
|
|
|
|
|
104 |
else:
|
105 |
data["filter"] = filters[0]
|
106 |
+
|
107 |
# Add sorting
|
108 |
if self.sort_by:
|
109 |
data["sorts"] = [
|
110 |
+
{"property": self.sort_by, "direction": self.sort_direction}
|
|
|
|
|
|
|
111 |
]
|
112 |
|
113 |
# Make the request
|
114 |
response = requests.post(url, headers=headers, json=data)
|
115 |
|
116 |
# Return the JSON response
|
117 |
+
return response.json()
|
agency_ai_demo/agents/NotionProjectAgent/tools/UpdateTask.py
CHANGED
@@ -32,6 +32,11 @@ class UpdateTaskTool(BaseTool):
|
|
32 |
description="The new title of the task.",
|
33 |
)
|
34 |
|
|
|
|
|
|
|
|
|
|
|
35 |
status: str = Field(
|
36 |
default=None,
|
37 |
description="New status of the task. Options: Backlog, In Progress, In Review, Testing, Completed.",
|
@@ -91,6 +96,14 @@ class UpdateTaskTool(BaseTool):
|
|
91 |
"title": [{"type": "text", "text": {"content": self.title}}]
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
# Add status if provided
|
95 |
if self.status is not None:
|
96 |
properties["Status"] = {"status": {"name": self.status}}
|
|
|
32 |
description="The new title of the task.",
|
33 |
)
|
34 |
|
35 |
+
task_description: str = Field(
|
36 |
+
default=None,
|
37 |
+
description="The new text description of the task.",
|
38 |
+
)
|
39 |
+
|
40 |
status: str = Field(
|
41 |
default=None,
|
42 |
description="New status of the task. Options: Backlog, In Progress, In Review, Testing, Completed.",
|
|
|
96 |
"title": [{"type": "text", "text": {"content": self.title}}]
|
97 |
}
|
98 |
|
99 |
+
# Add task description if provided
|
100 |
+
if self.task_description is not None:
|
101 |
+
properties["Task Description"] = {
|
102 |
+
"rich_text": [
|
103 |
+
{"type": "text", "text": {"content": self.task_description}}
|
104 |
+
]
|
105 |
+
}
|
106 |
+
|
107 |
# Add status if provided
|
108 |
if self.status is not None:
|
109 |
properties["Status"] = {"status": {"name": self.status}}
|