mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 16:48:30 +00:00
fix: planning feature output (#969)
* fix: planning feature output * fix: add validation for planning result
This commit is contained in:
committed by
GitHub
parent
16a949e7e4
commit
fa15c9012a
@@ -561,8 +561,13 @@ class Crew(BaseModel):
|
|||||||
self._logger.log("info", "Planning the crew execution")
|
self._logger.log("info", "Planning the crew execution")
|
||||||
result = CrewPlanner(self.tasks)._handle_crew_planning()
|
result = CrewPlanner(self.tasks)._handle_crew_planning()
|
||||||
|
|
||||||
for task, step_plan in zip(self.tasks, result.list_of_plans_per_task):
|
if result is not None and hasattr(result, "list_of_plans_per_task"):
|
||||||
task.description += step_plan
|
for task, step_plan in zip(self.tasks, result.list_of_plans_per_task):
|
||||||
|
task.description += step_plan
|
||||||
|
else:
|
||||||
|
self._logger.log(
|
||||||
|
"info", "Something went wrong with the planning process of the Crew"
|
||||||
|
)
|
||||||
|
|
||||||
def _store_execution_log(
|
def _store_execution_log(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import List
|
from typing import List, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
@@ -14,14 +14,14 @@ class CrewPlanner:
|
|||||||
def __init__(self, tasks: List[Task]):
|
def __init__(self, tasks: List[Task]):
|
||||||
self.tasks = tasks
|
self.tasks = tasks
|
||||||
|
|
||||||
def _handle_crew_planning(self):
|
def _handle_crew_planning(self) -> Optional[BaseModel]:
|
||||||
"""Handles the Crew planning by creating detailed step-by-step plans for each task."""
|
"""Handles the Crew planning by creating detailed step-by-step plans for each task."""
|
||||||
planning_agent = self._create_planning_agent()
|
planning_agent = self._create_planning_agent()
|
||||||
tasks_summary = self._create_tasks_summary()
|
tasks_summary = self._create_tasks_summary()
|
||||||
|
|
||||||
planner_task = self._create_planner_task(planning_agent, tasks_summary)
|
planner_task = self._create_planner_task(planning_agent, tasks_summary)
|
||||||
|
|
||||||
return planner_task.execute_sync()
|
return planner_task.execute_sync().pydantic
|
||||||
|
|
||||||
def _create_planning_agent(self) -> Agent:
|
def _create_planning_agent(self) -> Agent:
|
||||||
"""Creates the planning agent for the crew planning."""
|
"""Creates the planning agent for the crew planning."""
|
||||||
|
|||||||
Reference in New Issue
Block a user