Skip to content

Commit

Permalink
removing necessary crewai-tools dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomdmoura committed Feb 28, 2024
1 parent 997c906 commit e1306a8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/crewai/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import uuid
from typing import Any, Dict, List, Optional, Tuple

from crewai_tools import BaseTool as CrewAITool
from langchain.agents.agent import RunnableAgent
from langchain.agents.tools import tool as LangChainTool
from langchain.memory import ConversationSummaryMemory
Expand Down Expand Up @@ -280,12 +279,18 @@ def format_log_to_str(

def _parse_tools(self, tools: List[Any]) -> List[LangChainTool]:
"""Parse tools to be used for the task."""
# tentatively try to import from crewai_tools import BaseTool as CrewAITool
tools_list = []
for tool in tools:
if isinstance(tool, CrewAITool):
tools_list.append(tool.to_langchain())
else:
tools_list.append(tool)
try:
from crewai_tools import BaseTool as CrewAITool

for tool in tools:
if isinstance(tool, CrewAITool):
tools_list.append(tool.to_langchain())
else:
tools_list.append(tool)
except ModuleNotFoundError:
tools_list.append(tool)
return tools_list

@staticmethod
Expand Down

0 comments on commit e1306a8

Please sign in to comment.