Merge branch 'main' of github.com:joaomdmoura/crewAI into lj/optional-agent-in-task-bug

This commit is contained in:
Lorenze Jay
2024-07-01 09:33:08 -07:00
25 changed files with 9659 additions and 205233 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

@@ -6,7 +6,7 @@ authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = ">=3.10,<=3.13"
crewai = { extras = ["tools"], version = "^0.35.0" }
crewai = { extras = ["tools"], version = "^0.35.4" }
[tool.poetry.scripts]
{{folder_name}} = "{{folder_name}}.main:run"

View File

@@ -315,6 +315,10 @@ 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
@@ -442,7 +446,7 @@ class Crew(BaseModel):
backstory=i18n.retrieve("hierarchical_manager_agent", "backstory"),
tools=AgentTools(agents=self.agents).tools(),
llm=self.manager_llm,
verbose=True,
verbose=self.verbose,
)
self.manager_agent = manager
task_output = ""

View File

@@ -98,7 +98,7 @@ class ToolUsage:
tool_string: str,
tool: BaseTool,
calling: Union[ToolCalling, InstructorToolCalling],
) -> None: # TODO: Fix this return type
) -> str: # TODO: Fix this return type --> finecwg : I updated return type to str
if self._check_tool_repeated_usage(calling=calling): # type: ignore # _check_tool_repeated_usage of "ToolUsage" does not return a value (it only ever returns None)
try:
result = self._i18n.errors("task_repeated_usage").format(
@@ -123,7 +123,7 @@ class ToolUsage:
tool=calling.tool_name, input=calling.arguments
)
if not result:
if result is None: #! finecwg: if not result --> if result is None
try:
if calling.tool_name in [
"Delegate work to coworker",