mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-03 08:12:39 +00:00
adding verbose option to agents
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
"""Generic agent."""
|
"""Generic agent."""
|
||||||
|
|
||||||
from typing import List, Any
|
from typing import List, Any, Optional
|
||||||
from pydantic.v1 import BaseModel, Field
|
from pydantic.v1 import BaseModel, Field, root_validator
|
||||||
|
|
||||||
from langchain.agents import AgentExecutor
|
from langchain.agents import AgentExecutor
|
||||||
from langchain.chat_models import ChatOpenAI as OpenAI
|
from langchain.chat_models import ChatOpenAI as OpenAI
|
||||||
@@ -18,6 +18,11 @@ class Agent(BaseModel):
|
|||||||
role: str = Field(description="Role of the agent")
|
role: str = Field(description="Role of the agent")
|
||||||
goal: str = Field(description="Objective of the agent")
|
goal: str = Field(description="Objective of the agent")
|
||||||
backstory: str = Field(description="Backstory of the agent")
|
backstory: str = Field(description="Backstory of the agent")
|
||||||
|
llm: Optional[OpenAI] = Field(description="LLM that will run the agent")
|
||||||
|
verbose: bool = Field(
|
||||||
|
description="Verbose mode for the Agent Execution",
|
||||||
|
default=False
|
||||||
|
)
|
||||||
allow_delegation: bool = Field(
|
allow_delegation: bool = Field(
|
||||||
description="Allow delegation of tasks to agents",
|
description="Allow delegation of tasks to agents",
|
||||||
default=True
|
default=True
|
||||||
@@ -26,13 +31,15 @@ class Agent(BaseModel):
|
|||||||
description="Tools at agents disposal",
|
description="Tools at agents disposal",
|
||||||
default=[]
|
default=[]
|
||||||
)
|
)
|
||||||
llm: OpenAI = Field(
|
|
||||||
description="LLM that will run the agent",
|
@root_validator(pre=True)
|
||||||
default=OpenAI(
|
def check_llm(_cls, values):
|
||||||
temperature=0.7,
|
if not values.get('llm'):
|
||||||
model_name="gpt-4"
|
values['llm'] = OpenAI(
|
||||||
)
|
temperature=0.7,
|
||||||
)
|
model_name="gpt-4"
|
||||||
|
)
|
||||||
|
return values
|
||||||
|
|
||||||
def __init__(self, **data):
|
def __init__(self, **data):
|
||||||
super().__init__(**data)
|
super().__init__(**data)
|
||||||
@@ -61,7 +68,8 @@ class Agent(BaseModel):
|
|||||||
agent=inner_agent,
|
agent=inner_agent,
|
||||||
tools=self.tools,
|
tools=self.tools,
|
||||||
memory=summary_memory,
|
memory=summary_memory,
|
||||||
handle_parsing_errors=True
|
verbose=self.verbose,
|
||||||
|
handle_parsing_errors=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def execute_task(self, task: str, context: str = None, tools: List[Any] = None) -> str:
|
def execute_task(self, task: str, context: str = None, tools: List[Any] = None) -> str:
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Task(BaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@root_validator(pre=False)
|
@root_validator(pre=False)
|
||||||
def _set_tools(cls, values):
|
def _set_tools(_cls, values):
|
||||||
if (values.get('agent')) and not (values.get('tools')):
|
if (values.get('agent')) and not (values.get('tools')):
|
||||||
values['tools'] = values.get('agent').tools
|
values['tools'] = values.get('agent').tools
|
||||||
return values
|
return values
|
||||||
|
|||||||
Reference in New Issue
Block a user