mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
fix type issues
This commit is contained in:
@@ -280,27 +280,26 @@ class LangChainAgentAdapter(BaseAgent):
|
|||||||
"LangGraph library not found. Please run `uv add langgraph` to add LangGraph support."
|
"LangGraph library not found. Please run `uv add langgraph` to add LangGraph support."
|
||||||
) from e
|
) from e
|
||||||
|
|
||||||
# Otherwise, create a new executor from the LLM.
|
# Ensure raw_tools is always a list, even if tools and self.tools are None.
|
||||||
raw_tools = tools or self.tools
|
raw_tools = tools or self.tools or []
|
||||||
|
# Fallback: if raw_tools is still empty, try to extract them from the wrapped langchain agent.
|
||||||
# Fallback: if raw_tools is empty, try to extract them from the wrapped langchain agent.
|
|
||||||
if not raw_tools:
|
if not raw_tools:
|
||||||
if hasattr(self.langchain_agent, "agent") and hasattr(
|
if hasattr(self.langchain_agent, "agent") and hasattr(
|
||||||
self.langchain_agent.agent, "tools"
|
self.langchain_agent.agent, "tools"
|
||||||
):
|
):
|
||||||
raw_tools = self.langchain_agent.agent.tools
|
raw_tools = self.langchain_agent.agent.tools or []
|
||||||
else:
|
else:
|
||||||
raw_tools = getattr(self.langchain_agent, "tools", [])
|
raw_tools = getattr(self.langchain_agent, "tools", []) or []
|
||||||
|
|
||||||
used_tools = []
|
used_tools = []
|
||||||
try:
|
try:
|
||||||
# Import the CrewAI Tool class.
|
# Import the CrewAI Tool class.
|
||||||
from crewai.tools.base_tool import Tool as CrewTool
|
from crewai.tools.base_tool import Tool as CrewTool
|
||||||
except ImportError:
|
except ImportError:
|
||||||
CrewTool = None
|
CrewTool: Optional[Type[BaseTool]] = None # Explicitly annotate as Optional
|
||||||
|
|
||||||
for tool in raw_tools:
|
for tool in raw_tools:
|
||||||
# Only attempt conversion if this is an instance of our CrewAI Tool.
|
# If the tool is a CrewAI Tool, convert it to a LangChain compatible tool.
|
||||||
if CrewTool is not None and isinstance(tool, CrewTool):
|
if CrewTool is not None and isinstance(tool, CrewTool):
|
||||||
used_tools.append(tool.to_langchain())
|
used_tools.append(tool.to_langchain())
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ class BaseTool(BaseModel, ABC):
|
|||||||
"""The schema for the arguments that the tool accepts."""
|
"""The schema for the arguments that the tool accepts."""
|
||||||
description_updated: bool = False
|
description_updated: bool = False
|
||||||
"""Flag to check if the description has been updated."""
|
"""Flag to check if the description has been updated."""
|
||||||
cache_function: Callable = lambda _args=None, _result=None: True
|
cache_function: Callable[[Optional[Any], Optional[Any]], bool] = (
|
||||||
|
lambda _args=None, _result=None: True
|
||||||
|
)
|
||||||
"""Function that will be used to determine if the tool should be cached, should return a boolean. If None, the tool will be cached."""
|
"""Function that will be used to determine if the tool should be cached, should return a boolean. If None, the tool will be cached."""
|
||||||
result_as_answer: bool = False
|
result_as_answer: bool = False
|
||||||
"""Flag to check if the tool should be the final agent answer."""
|
"""Flag to check if the tool should be the final agent answer."""
|
||||||
|
|||||||
Reference in New Issue
Block a user