-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Multimodal Abilities to Crew (#1805)
* initial fix on delegation tools * fixing tests for delegations and coding * Refactor prepare tool and adding initial add images logic * supporting image tool * fixing linter * fix linter * Making sure multimodal feature support i18n * fix linter and types * mixxing translations * fix types and linter * Revert "fixing linter" This reverts commit 2eda5fd. * fix linters * test * fix * fix * fix linter * fix * ignore * type improvements
- Loading branch information
1 parent
6cc2f51
commit 8264735
Showing
15 changed files
with
2,990 additions
and
544 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from typing import Dict, Optional, Union | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
from crewai.tools.base_tool import BaseTool | ||
from crewai.utilities import I18N | ||
|
||
i18n = I18N() | ||
|
||
class AddImageToolSchema(BaseModel): | ||
image_url: str = Field(..., description="The URL or path of the image to add") | ||
action: Optional[str] = Field( | ||
default=None, | ||
description="Optional context or question about the image" | ||
) | ||
|
||
|
||
class AddImageTool(BaseTool): | ||
"""Tool for adding images to the content""" | ||
|
||
name: str = Field(default_factory=lambda: i18n.tools("add_image")["name"]) # type: ignore | ||
description: str = Field(default_factory=lambda: i18n.tools("add_image")["description"]) # type: ignore | ||
args_schema: type[BaseModel] = AddImageToolSchema | ||
|
||
def _run( | ||
self, | ||
image_url: str, | ||
action: Optional[str] = None, | ||
**kwargs, | ||
) -> dict: | ||
action = action or i18n.tools("add_image")["default_action"] # type: ignore | ||
content = [ | ||
{"type": "text", "text": action}, | ||
{ | ||
"type": "image_url", | ||
"image_url": { | ||
"url": image_url, | ||
}, | ||
} | ||
] | ||
|
||
return { | ||
"role": "user", | ||
"content": content | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.