Skip to content

Commit d6c60f8

Browse files
committed
Adding verbose levels
1 parent ff46652 commit d6c60f8

File tree

3 files changed

+743
-9
lines changed

3 files changed

+743
-9
lines changed

crewai/crew.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from pydantic_core import PydanticCustomError
1313

1414
from crewai.agent import Agent
15+
from crewai.agents import CacheHandler
1516
from crewai.process import Process
1617
from crewai.task import Task
1718
from crewai.tools.agent_tools import AgentTools
18-
from crewai.agents import CacheHandler
1919

2020

2121
class Crew(BaseModel):
@@ -31,8 +31,8 @@ class Config:
3131
process: Process = Field(
3232
description="Process that the crew will follow.", default=Process.sequential
3333
)
34-
verbose: bool = Field(
35-
description="Verbose mode for the Agent Execution", default=False
34+
verbose: Union[int, bool] = Field(
35+
description="Verbose mode for the Agent Execution", default=0
3636
)
3737
config: Optional[Union[Json, Dict[str, Any]]] = Field(
3838
description="Configuration of the crew.", default=None
@@ -103,15 +103,20 @@ def __sequential_loop(self) -> str:
103103
tools = AgentTools(agents=self.agents).tools()
104104
task.tools += tools
105105

106-
self.__log(f"\nWorking Agent: {task.agent.role}")
107-
self.__log(f"Starting Task: {task.description} ...")
106+
self.__log("debug", f"Working Agent: {task.agent.role}")
107+
self.__log("info", f"Starting Task: {task.description} ...")
108108

109109
task_outcome = task.execute(task_outcome)
110110

111-
self.__log(f"Task output: {task_outcome}")
111+
self.__log("debug", f"Task output: {task_outcome}")
112112

113113
return task_outcome
114114

115-
def __log(self, message):
116-
if self.verbose:
115+
def __log(self, level, message):
116+
"""Log a message"""
117+
level_map = {"debug": 1, "info": 2}
118+
verbose_level = (
119+
2 if isinstance(self.verbose, bool) and self.verbose else self.verbose
120+
)
121+
if verbose_level and level_map[level] <= verbose_level:
117122
print(message)

0 commit comments

Comments
 (0)