Making sure multimodal feature support i18n

This commit is contained in:
João Moura
2024-12-27 15:56:13 -03:00
parent d56db9f34f
commit 8735b58fc6
4 changed files with 15 additions and 8 deletions

View File

@@ -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},
{