mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 16:48:30 +00:00
fix: Add final type casting for remaining type-checker issues
- Add cast import and type casting in tool_utils.py for ToolUsage constructor - Add cast import and type casting in lite_agent.py for execute_tool_and_check_finality call These changes complete the type-checker fixes for hosted tools implementation. Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -564,9 +564,10 @@ class LiteAgent(FlowTrackable, BaseModel):
|
|||||||
|
|
||||||
if isinstance(formatted_answer, AgentAction):
|
if isinstance(formatted_answer, AgentAction):
|
||||||
try:
|
try:
|
||||||
|
from typing import cast
|
||||||
tool_result = execute_tool_and_check_finality(
|
tool_result = execute_tool_and_check_finality(
|
||||||
agent_action=formatted_answer,
|
agent_action=formatted_answer,
|
||||||
tools=self._parsed_tools, # type: ignore[arg-type]
|
tools=cast(List[Union[CrewStructuredTool, dict]], self._parsed_tools),
|
||||||
i18n=self.i18n,
|
i18n=self.i18n,
|
||||||
agent_key=self.key,
|
agent_key=self.key,
|
||||||
agent_role=self.role,
|
agent_role=self.role,
|
||||||
|
|||||||
@@ -54,10 +54,11 @@ def execute_tool_and_check_finality(
|
|||||||
raise ValueError(f"Failed to set fingerprint: {e}")
|
raise ValueError(f"Failed to set fingerprint: {e}")
|
||||||
|
|
||||||
# Create tool usage instance - filter to only CrewStructuredTool instances for ToolUsage
|
# Create tool usage instance - filter to only CrewStructuredTool instances for ToolUsage
|
||||||
|
from typing import cast
|
||||||
crew_structured_tools = [tool for tool in tools if hasattr(tool, 'name') and hasattr(tool, 'result_as_answer') and not isinstance(tool, dict)]
|
crew_structured_tools = [tool for tool in tools if hasattr(tool, 'name') and hasattr(tool, 'result_as_answer') and not isinstance(tool, dict)]
|
||||||
tool_usage = ToolUsage(
|
tool_usage = ToolUsage(
|
||||||
tools_handler=tools_handler,
|
tools_handler=tools_handler,
|
||||||
tools=crew_structured_tools,
|
tools=cast(List[CrewStructuredTool], crew_structured_tools),
|
||||||
function_calling_llm=function_calling_llm,
|
function_calling_llm=function_calling_llm,
|
||||||
task=task,
|
task=task,
|
||||||
agent=agent,
|
agent=agent,
|
||||||
|
|||||||
Reference in New Issue
Block a user