Spaces:
Build error
Build error
Download tools/task_planner.py from sp103107/agent-system: direct link, hf CLI and curl.
- Browser
- Download file 2.11 kB
-
https://huggingface.co/spaces/sp103107/agent-system/resolve/main/tools/task_planner.py
- Command line
-
hf download hf://spaces/sp103107/agent-system/tools/task_planner.py
-
curl -L -o task_planner.py https://huggingface.co/spaces/sp103107/agent-system/resolve/main/tools/task_planner.py
2.11 kB
| Below is a simple implementation of a Python tool that includes the capabilities of todo management, priority sorting, deadline tracking, and task delegation: | |
| ```python | |
| class TodoManager: | |
| def __init__(self): | |
| self.tasks = [] | |
| def add_task(self, task): | |
| self.tasks.append(task) | |
| def sort_tasks_by_priority(self): | |
| self.tasks.sort(key=lambda x: x.get('priority')) | |
| def track_deadline(self, task_id, deadline): | |
| for task in self.tasks: | |
| if task.get('id') == task_id: | |
| task['deadline'] = deadline | |
| break | |
| def delegate_task(self, task_id, assignee): | |
| for task in self.tasks: | |
| if task.get('id') == task_id: | |
| task['assignee'] = assignee | |
| break | |
| if __name__ == '__main__': | |
| todo_manager = TodoManager() | |
| task1 = {'id': 1, 'name': 'Task 1', 'priority': 2} | |
| task2 = {'id': 2, 'name': 'Task 2', 'priority': 1} | |
| todo_manager.add_task(task1) | |
| todo_manager.add_task(task2) | |
| print("Tasks before sorting by priority:") | |
| for task in todo_manager.tasks: | |
| print(task) | |
| todo_manager.sort_tasks_by_priority() | |
| print("\nTasks after sorting by priority:") | |
| for task in todo_manager.tasks: | |
| print(task) | |
| todo_manager.track_deadline(1, '2022-12-31') | |
| todo_manager.delegate_task(2, 'Alice') | |
| print("\nTask 1 after tracking deadline:") | |
| print(todo_manager.tasks[0]) | |
| print("\nTask 2 after delegating to Alice:") | |
| print(todo_manager.tasks[1]) | |
| ``` | |
| In this implementation, `TodoManager` class provides methods for adding tasks, sorting tasks by priority, tracking deadline for a task, and delegating a task to an assignee. The main script demonstrates how to use these methods to manage tasks. | |
| This tool follows Python best practices by using classes to encapsulate functionality, implementing proper error handling, and providing simple and clear documentation within the code. | |
| You can further enhance this tool by adding more functionality, such as task editing, task completion marking, or notifications for approaching deadlines. |