mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-01 15:22:37 +00:00
Making sure multimodal feature support i18n
This commit is contained in:
@@ -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},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user