12
12
from pydantic_core import PydanticCustomError
13
13
14
14
from crewai .agent import Agent
15
+ from crewai .agents import CacheHandler
15
16
from crewai .process import Process
16
17
from crewai .task import Task
17
18
from crewai .tools .agent_tools import AgentTools
18
- from crewai .agents import CacheHandler
19
19
20
20
21
21
class Crew (BaseModel ):
@@ -31,8 +31,8 @@ class Config:
31
31
process : Process = Field (
32
32
description = "Process that the crew will follow." , default = Process .sequential
33
33
)
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
36
36
)
37
37
config : Optional [Union [Json , Dict [str , Any ]]] = Field (
38
38
description = "Configuration of the crew." , default = None
@@ -103,15 +103,20 @@ def __sequential_loop(self) -> str:
103
103
tools = AgentTools (agents = self .agents ).tools ()
104
104
task .tools += tools
105
105
106
- self .__log (f" \n Working 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 } ..." )
108
108
109
109
task_outcome = task .execute (task_outcome )
110
110
111
- self .__log (f"Task output: { task_outcome } " )
111
+ self .__log ("debug" , f"Task output: { task_outcome } " )
112
112
113
113
return task_outcome
114
114
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 :
117
122
print (message )
0 commit comments