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

refact: make GeminiMultiModal a thin wrapper around Gemini #17501

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

masci
Copy link
Member

@masci masci commented Jan 13, 2025

Blocked on #17509

Description

  • Consolidate the multimodal capabilities for this LLM into the regular llms.gemini.Gemini class.
  • Make the existing GeminiMultiModal class a thin wrapper around Gemini to keep backward compatibility

Part of #15950

Version Bump?

Not releasing the package multimodal llm package, that needs to happen after we release core.

  • Yes
  • No

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jan 13, 2025
self._guess_mimetype(decoded_img)
return self

def _guess_mimetype(self, img_data: bytes) -> None:
Copy link
Member Author

Choose a reason for hiding this comment

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

Adding this function to guess the mimetype not only in the init but also every time we resolve the image

Copy link
Collaborator

Choose a reason for hiding this comment

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

handy!

@@ -26,6 +26,9 @@ class CustomLLM(LLM):
`_stream_complete`, and `metadata` methods.
"""

def __init__(self, *args: Any, **kwargs: Any):
super().__init__(*args, **kwargs)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is to make mypy happy

Copy link
Collaborator

Choose a reason for hiding this comment

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

Mypy never had an issue with this before?

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry it was Pyright not mypy, it's mostly annoying in IDEs

@@ -17,17 +18,21 @@
MessageRole.TOOL: MessageRole.USER,
MessageRole.FUNCTION: MessageRole.USER,
}
ROLES_FROM_GEMINI: Dict[MessageRole, MessageRole] = {
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this worked only brecause MessageRole derives from str but let's be explicit

@masci masci force-pushed the massi/gemini-refact branch from 1b19bcf to af2aab2 Compare January 14, 2025 11:27
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jan 14, 2025
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@masci masci marked this pull request as draft January 14, 2025 11:30
@masci masci force-pushed the massi/gemini-refact branch from 0c0af0d to ac32d8b Compare January 14, 2025 14:04
fix unit test

fix request_options handling

save progress

address review comment

update notebook example

fix completion docs handling
@masci masci force-pushed the massi/gemini-refact branch from 1f2ed00 to a80e2ab Compare January 14, 2025 15:45
@masci masci marked this pull request as ready for review January 14, 2025 15:45
@masci masci requested a review from logan-markewich January 14, 2025 15:46
@masci masci merged commit dec5be6 into main Jan 16, 2025
11 checks passed
@masci masci deleted the massi/gemini-refact branch January 16, 2025 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants