mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
small refractoring for new version
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user