From 6e783c11edf2fc2d21dfc82243a7d75bb8574e26 Mon Sep 17 00:00:00 2001 From: Eduardo Chiarotti Date: Wed, 14 Aug 2024 16:41:02 -0300 Subject: [PATCH] fix: Fix planning_llm issue --- src/crewai/crew.py | 5 ++--- src/crewai/utilities/planning_handler.py | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/crewai/crew.py b/src/crewai/crew.py index 948014e0d..96c84d9ab 100644 --- a/src/crewai/crew.py +++ b/src/crewai/crew.py @@ -1,9 +1,9 @@ import asyncio import json +import os import uuid from concurrent.futures import Future from hashlib import md5 -import os from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union from langchain_core.callbacks import BaseCallbackHandler @@ -48,7 +48,6 @@ from crewai.utilities.planning_handler import CrewPlanner from crewai.utilities.task_output_storage_handler import TaskOutputStorageHandler from crewai.utilities.training_handler import CrewTrainingHandler - agentops = None if os.environ.get("AGENTOPS_API_KEY"): try: @@ -541,7 +540,7 @@ class Crew(BaseModel): )._handle_crew_planning() for task, step_plan in zip(self.tasks, result.list_of_plans_per_task): - task.description += step_plan + task.description += step_plan.plan def _store_execution_log( self, diff --git a/src/crewai/utilities/planning_handler.py b/src/crewai/utilities/planning_handler.py index 29b89667e..7b9459adf 100644 --- a/src/crewai/utilities/planning_handler.py +++ b/src/crewai/utilities/planning_handler.py @@ -1,14 +1,25 @@ from typing import Any, List, Optional from langchain_openai import ChatOpenAI -from pydantic import BaseModel +from pydantic import BaseModel, Field from crewai.agent import Agent from crewai.task import Task +class PlanPerTask(BaseModel): + task: str = Field(..., description="The task for which the plan is created") + plan: str = Field( + ..., + description="The step by step plan on how the agents can execute their tasks using the available tools with mastery", + ) + + class PlannerTaskPydanticOutput(BaseModel): - list_of_plans_per_task: List[str] + list_of_plans_per_task: List[PlanPerTask] = Field( + ..., + description="Step by step plan on how the agents can execute their tasks using the available tools with mastery", + ) class CrewPlanner: