small refractoring for new version

This commit is contained in:
João Moura
2024-07-01 02:00:36 -07:00
parent 64ec4eb1e6
commit dee7bd6258
16 changed files with 9011 additions and 205346 deletions

View File

@@ -255,6 +255,16 @@ class Agent(BaseAgent):
tools = agent_tools.tools()
return tools
def get_code_execution_tools(self):
try:
from crewai_tools import CodeInterpreterTool
return [CodeInterpreterTool()]
except ModuleNotFoundError:
self._logger.log(
"info", "Coding tools not available. Install crewai_tools. "
)
def get_output_converter(self, llm, text, model, instructions):
return Converter(llm=llm, text=text, model=model, instructions=instructions)
@@ -270,13 +280,8 @@ class Agent(BaseAgent):
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:
tools_list = []
for tool in tools:
tools_list.append(tool)
return tools_list

View File

@@ -214,7 +214,7 @@ class BaseAgent(ABC, BaseModel):
self.create_agent_executor()
def increment_formatting_errors(self) -> None:
print("Formatting errors incremented")
self.formatting_errors += 1
def copy(self):
exclude = {

View File

@@ -299,6 +299,8 @@ class Crew(BaseModel):
and not agent.function_calling_llm
):
agent.function_calling_llm = self.function_calling_llm
if hasattr(agent, "allow_code_execution") and agent.allow_code_execution:
agent.tools += agent.get_code_execution_tools()
if hasattr(agent, "step_callback") and not agent.step_callback:
agent.step_callback = self.step_callback