mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-29 18:18:13 +00:00
fix: Fix code execution and multimodal tool handling in Agent class
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -338,21 +338,33 @@ class Agent(BaseAgent):
|
|||||||
return tools
|
return tools
|
||||||
|
|
||||||
def get_multimodal_tools(self) -> Sequence[BaseTool]:
|
def get_multimodal_tools(self) -> Sequence[BaseTool]:
|
||||||
from crewai.tools.agent_tools.add_image_tool import AddImageTool
|
"""Get multimodal tools for the agent.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List[BaseTool]: List containing the AddImageTool if agent is multimodal
|
||||||
|
"""
|
||||||
|
if self.multimodal:
|
||||||
|
from crewai.tools.agent_tools.add_image_tool import AddImageTool
|
||||||
|
return [AddImageTool()]
|
||||||
|
return []
|
||||||
|
|
||||||
return [AddImageTool()]
|
def get_code_execution_tools(self) -> Sequence[BaseTool]:
|
||||||
|
"""Get code execution tools for the agent.
|
||||||
def get_code_execution_tools(self):
|
|
||||||
try:
|
Returns:
|
||||||
from crewai_tools import CodeInterpreterTool # type: ignore
|
List[BaseTool]: List containing the CodeInterpreterTool if code execution is allowed
|
||||||
|
"""
|
||||||
# Set the unsafe_mode based on the code_execution_mode attribute
|
if self.allow_code_execution:
|
||||||
unsafe_mode = self.code_execution_mode == "unsafe"
|
try:
|
||||||
return [CodeInterpreterTool(unsafe_mode=unsafe_mode)]
|
from crewai_tools import CodeInterpreterTool # type: ignore
|
||||||
except ModuleNotFoundError:
|
# Set the unsafe_mode based on the code_execution_mode attribute
|
||||||
self._logger.log(
|
unsafe_mode = self.code_execution_mode == "unsafe"
|
||||||
"info", "Coding tools not available. Install crewai_tools. "
|
return [CodeInterpreterTool(unsafe_mode=unsafe_mode)]
|
||||||
)
|
except ModuleNotFoundError:
|
||||||
|
self._logger.log(
|
||||||
|
"warning", "Coding tools not available. Install crewai_tools.", color="yellow"
|
||||||
|
)
|
||||||
|
return []
|
||||||
|
|
||||||
def get_output_converter(self, llm, text, model, instructions):
|
def get_output_converter(self, llm, text, model, instructions):
|
||||||
return Converter(llm=llm, text=text, model=model, instructions=instructions)
|
return Converter(llm=llm, text=text, model=model, instructions=instructions)
|
||||||
|
|||||||
Reference in New Issue
Block a user