-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Multimodal Abilities to Crew #1805
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3e58c99
initial fix on delegation tools
joaomdmoura e6be4ed
fixing tests for delegations and coding
joaomdmoura 93bee87
Refactor prepare tool and adding initial add images logic
joaomdmoura e61f2f5
supporting image tool
joaomdmoura 2357d3e
Merge branch 'main' into joaomdmoura/multimodal-crew
joaomdmoura 2eda5fd
fixing linter
joaomdmoura d56db9f
fix linter
joaomdmoura 8735b58
Making sure multimodal feature support i18n
joaomdmoura 2e5bb3f
fix linter and types
joaomdmoura ffff182
mixxing translations
joaomdmoura 5bd4fdc
fix types and linter
joaomdmoura 9a55b54
Revert "fixing linter"
joaomdmoura b5f2161
fix linters
joaomdmoura ee9d7ae
test
joaomdmoura 8e93f3a
fix
joaomdmoura 75136fc
fix
joaomdmoura 2bbcba1
fix linter
joaomdmoura afeb8ca
fix
joaomdmoura 842e5fb
ignore
joaomdmoura 7eee68d
type improvements
joaomdmoura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will this work for local images? Asking cause the OpenAI Vision has a base64 strategy to handle such cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depends on the model, for most you need to have uploaded image or base64, but that is out of our control