fixing tasks order

This commit is contained in:
João Moura
2024-09-27 20:21:31 -03:00
parent bc31019b67
commit 44c8765add
6 changed files with 145 additions and 156 deletions

View File

@@ -70,7 +70,10 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
self.log_error_after = 3
self.have_forced_answer = False
self.name_to_tool_map = {tool.name: tool for tool in self.tools}
self.llm.stop = self.stop
if self.llm.stop:
self.llm.stop = list(set(self.llm.stop + self.stop))
else:
self.llm.stop = self.stop
def invoke(self, inputs: Dict[str, str]) -> Dict[str, Any]:
if "system" in self.prompt:

View File

@@ -1,6 +1,7 @@
from functools import wraps
from crewai.project.utils import memoize
from crewai import Crew
def task(func):
@@ -72,7 +73,7 @@ def pipeline(func):
return memoize(func)
def crew(func):
def crew(func) -> "Crew":
def wrapper(self, *args, **kwargs):
instantiated_tasks = []
instantiated_agents = []

View File

@@ -5,11 +5,8 @@ from typing import Any, Callable, Dict, Type, TypeVar
import yaml
from dotenv import load_dotenv
from crewai.crew import Crew
load_dotenv()
T = TypeVar("T", bound=Type[Any])
@@ -37,19 +34,6 @@ def CrewBase(cls: T) -> T:
self.map_all_agent_variables()
self.map_all_task_variables()
def crew(self) -> "Crew":
agents = [
getattr(self, name)()
for name, func in self._get_all_functions().items()
if hasattr(func, "is_agent")
]
tasks = [
getattr(self, name)()
for name, func in reversed(self._get_all_functions().items())
if hasattr(func, "is_task")
]
return Crew(agents=agents, tasks=tasks)
@staticmethod
def load_yaml(config_path: Path):
try: