feat: add CodeInterpreterTool to run when enable code execution (#804)

* feat: add CodeInterpreterTool to run when enable code execution is allowed on agent

* feat: change to allow_code_execution

* feat: add readme for CodeInterpreterTool
This commit is contained in:
Eduardo Chiarotti
2024-06-27 02:25:39 -03:00
committed by GitHub
parent bf0e70999e
commit 6018fe5872
2 changed files with 38 additions and 0 deletions

View File

@@ -133,6 +133,9 @@ class Agent(BaseModel):
response_template: Optional[str] = Field(
default=None, description="Response format for the agent."
)
allow_code_execution: Optional[bool] = Field(
default=False, description="Enable code execution for the agent."
)
_original_role: str | None = None
_original_goal: str | None = None
@@ -409,6 +412,12 @@ class Agent(BaseModel):
tools_list.append(tool.to_langchain())
else:
tools_list.append(tool)
if self.allow_code_execution:
from crewai_tools.code_interpreter_tool import CodeInterpreterTool
tools_list.append(CodeInterpreterTool)
except ModuleNotFoundError:
for tool in tools:
tools_list.append(tool)