mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-07 07:08:31 +00:00
Making sure multimodal feature support i18n
This commit is contained in:
@@ -147,7 +147,7 @@ class CrewAgentExecutor(CrewAgentExecutorMixin):
|
||||
# Directly append the result to the messages if the
|
||||
# tool is "Add image to content" in case of multimodal
|
||||
# agents
|
||||
if formatted_answer.tool == "Add image to content":
|
||||
if formatted_answer.tool == self._i18n.tools("add_image")["name"]:
|
||||
self.messages.append(tool_result.result)
|
||||
continue
|
||||
|
||||
|
||||
@@ -725,7 +725,7 @@ class Crew(BaseModel):
|
||||
)
|
||||
|
||||
# Determine which tools to use - task tools take precedence over agent tools
|
||||
tools_for_task = task.tools if task.tools else agent_to_use.tools or []
|
||||
tools_for_task = task.tools or agent_to_use.tools or []
|
||||
tools_for_task = self._prepare_tools(
|
||||
agent_to_use,
|
||||
task,
|
||||
@@ -871,7 +871,6 @@ class Crew(BaseModel):
|
||||
tools = self._inject_delegation_tools(tools, task.agent, [task.agent])
|
||||
else:
|
||||
tools = self._inject_delegation_tools(tools, self.manager_agent, self.agents)
|
||||
# self.manager_agent.tools = tools
|
||||
return tools
|
||||
|
||||
def _get_context(self, task: Task, task_outputs: List[TaskOutput]):
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
from crewai.tools.base_tool import BaseTool
|
||||
from crewai.utilities import I18N
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
i18n = I18N()
|
||||
|
||||
class AddImageToolSchema(BaseModel):
|
||||
image_url: str = Field(..., description="The URL or path of the image to add")
|
||||
action: str = Field(
|
||||
default="Please provide a detailed description of this image, including all visual elements, context, and any notable details you can observe.",
|
||||
default=None,
|
||||
description="Optional context or question about the image"
|
||||
)
|
||||
|
||||
@@ -13,16 +15,17 @@ class AddImageToolSchema(BaseModel):
|
||||
class AddImageTool(BaseTool):
|
||||
"""Tool for adding images to the content"""
|
||||
|
||||
name: str = "Add image to content"
|
||||
description: str = "See image to understand it's content, you can optionally ask a question about the image"
|
||||
name: str = Field(default_factory=lambda: i18n.tools("add_image")["name"])
|
||||
description: str = Field(default_factory=lambda: i18n.tools("add_image")["description"])
|
||||
args_schema: type[BaseModel] = AddImageToolSchema
|
||||
|
||||
def _run(
|
||||
self,
|
||||
image_url: str,
|
||||
action: str = "Please provide a detailed description of this image, including all visual elements, context, and any notable details you can observe.",
|
||||
action: str = None,
|
||||
**kwargs,
|
||||
) -> dict:
|
||||
action = action or i18n.tools("add_image")["default_action"]
|
||||
content = [
|
||||
{"type": "text", "text": action},
|
||||
{
|
||||
|
||||
@@ -37,6 +37,11 @@
|
||||
},
|
||||
"tools": {
|
||||
"delegate_work": "Delegate a specific task to one of the following coworkers: {coworkers}\nThe input to this tool should be the coworker, the task you want them to do, and ALL necessary context to execute the task, they know nothing about the task, so share absolute everything you know, don't reference things but instead explain them.",
|
||||
"ask_question": "Ask a specific question to one of the following coworkers: {coworkers}\nThe input to this tool should be the coworker, the question you have for them, and ALL necessary context to ask the question properly, they know nothing about the question, so share absolute everything you know, don't reference things but instead explain them."
|
||||
"ask_question": "Ask a specific question to one of the following coworkers: {coworkers}\nThe input to this tool should be the coworker, the question you have for them, and ALL necessary context to ask the question properly, they know nothing about the question, so share absolute everything you know, don't reference things but instead explain them.",
|
||||
"add_image": {
|
||||
"name": "Add image to content",
|
||||
"description": "See image to understand it's content, you can optionally ask a question about the image",
|
||||
"default_action": "Please provide a detailed description of this image, including all visual elements, context, and any notable details you can observe."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user