Refactor mime type#254
Open
Prashidha Kharel (cool8137) wants to merge 4 commits intolangchain-ai:mainfrom
Open
Refactor mime type#254Prashidha Kharel (cool8137) wants to merge 4 commits intolangchain-ai:mainfrom
Prashidha Kharel (cool8137) wants to merge 4 commits intolangchain-ai:mainfrom
Conversation
|
Prashidha Kharel (@cool8137) is attempting to deploy a commit to the LangChain Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR refactors the mime type definition to make it easy to extend mime type in the future.
Problem
The image and file mime types were originally hard coded strings defined at different places. Extending supported filetype would require changes to be made at many places.
Solution
This PR centralises the definition of mime type by doing the following:
src/lib/multimodal-utils.tsas an enum like objectMIME_TYPE.Testing
Two Unit test files have been added for the multimodal-utils and multipodal preview fiels.
Here is a screen shot of local usage of image upload which is working as expected.
I was inspired for this refactor when I was trying to add a new mime type for my personal project.
Although this PR is not linked to any existing issue, I hope it is small and useful enough to merge.
Let me know if you have any comments.