-
Notifications
You must be signed in to change notification settings - Fork 92
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
Add media support to vertex chat_models #227
Conversation
# Handle media type like LangChain.js | ||
# https://github.com/langchain-ai/langchainjs/blob/e536593e2585f1dd7b0afc187de4d07cb40689ba/libs/langchain-google-common/src/utils/gemini.ts#L93-L106 | ||
if part["type"] == "media": | ||
if "mime_type" not in part: |
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.
I went with snake_case for mime_type and file_uri contrary to what's happening in langchain.js as it seemed more pythonic. Do you think that's the right call?
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.
can we construct the proto Part directly? why do we need a VertexPart?
and it's probably a good idea to allow to pass gcs_uri as file_data and video_metadata too.
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.
can we construct the proto Part directly?
Done.
video_metadata
Done.
pass gcs_uri
file_uri expects a GCS uri, e.g. "gs://bucket/some_video.mp4". Do you mean we should also support http uri-s here?
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.
so there's no way to send the video into a base64 uri?, instead of an GCS uri?
llm = ChatVertexAI(model_name="gemini-1.5-pro-preview-0514") | ||
storage_client = storage.Client() | ||
blob = storage.Blob.from_string(file_uri, client=storage_client) | ||
media_base64 = base64.b64encode(blob.download_as_bytes()).decode() |
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.
could you include a test that passes a gcs_uri, please?
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.
See test_multimodal_media_file_uri.
Fixes langchain-ai/langchain#20738.