Skip to content
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

Support multiple images #151

Merged
merged 13 commits into from
Dec 14, 2024
Merged

Support multiple images #151

merged 13 commits into from
Dec 14, 2024

Conversation

ludomitch
Copy link
Collaborator

No description provided.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Dec 13, 2024
@@ -124,16 +123,22 @@ def create_message(
cls,
role: str = DEFAULT_ROLE,
text: str | None = None,
image: np.ndarray | None = None,
images: list[np.ndarray | str] | None = None,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this will break existing uses of create_message elsewhere. However, imo it's better to make this shift now while it isn't used much than in the future. It will be quite common for users to have multiple images associated with one prompt eg "what species do all the bacteria in these images belong to?". Single images can just be a list of length 1.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can have type list[np.ndarray] | np.ndarray | None. Then, we always encode it inside the function.
We can have a check like this:

if isinstance(images, str): 
    images = [images]

I believe this will keep compatibility with the previous behavior

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc. @maykcaldas for visibility

Copy link
Collaborator

@sidnarayanan sidnarayanan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Dec 13, 2024
.python-version Show resolved Hide resolved
src/aviary/message.py Show resolved Hide resolved
src/aviary/message.py Outdated Show resolved Hide resolved
@@ -124,16 +123,22 @@ def create_message(
cls,
role: str = DEFAULT_ROLE,
text: str | None = None,
image: np.ndarray | None = None,
images: list[np.ndarray | str] | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can have type list[np.ndarray] | np.ndarray | None. Then, we always encode it inside the function.
We can have a check like this:

if isinstance(images, str): 
    images = [images]

I believe this will keep compatibility with the previous behavior

pyproject.toml Outdated
@@ -27,6 +27,7 @@ classifiers = [
dependencies = [
"docstring_parser>=0.16", # Pin for description addition
"httpx",
"numpy",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we can avoid adding deps? Sorry I missed this in the original review

We should only add deps if we actually need them

Copy link
Collaborator

@jamesbraza jamesbraza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thanks for taking care of numpy stuff 🙏

@ludomitch ludomitch merged commit 4654ba0 into main Dec 14, 2024
6 checks passed
@ludomitch ludomitch deleted the support-multiple-images branch December 14, 2024 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants