File size: 814 Bytes
95810d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from services.project_service import project_service
from typing import List, Dict, Any
import logging

logger = logging.getLogger("uvicorn")

class DecompositionTool:
    """
    A tool that allows agents to break down complex goals into actionable tasks.
    """
    async def create_subtasks(self, project_id: str, tasks: List[Dict[str, Any]]) -> str:
        """
        Takes a list of task definitions and adds them to the database for the given project.
        """
        logger.info(f"DecompositionTool: Creating {len(tasks)} subtasks for project {project_id}")
        try:
            await project_service.add_tasks_to_project(project_id, tasks)
            return f"Successfully created {len(tasks)} subtasks."
        except Exception as e:
            return f"Failed to create subtasks: {str(e)}"