Claude3: Image size increase after base64.b64encode().decode('utf-8')
hteeyeoh opened this issue · comments
Checked other resources
- I added a very descriptive title to this issue.
- I searched the LangChain documentation with the integrated search.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangChain rather than my code.
- The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
def image_to_base64(image_data: bytes) -> str:
#image_data is 4804036
base64_image = base64.b64encode(image_data).decode('utf-8')
#base64_image size increase to 6405384
return base64_image
Error Message and Stack Trace (if applicable)
botocore.exceptions.EventStreamError: An error occurred (validationException) when calling the InvokeModelWithResponseStream operation: messages.0.content.1.image.source.base64: image exceeds 5 MB maximum: 6405384 bytes > 5242880 bytes
Description
Im trying to run query with image using Claude3-sonnet model with an input gif file of 4.6MB. I noticed that the size increase after we run base64 operation on the image data as needed for multimodel prompt. Is this expected?
We know that in anthropic claude at max support 5Mb of image file size per file. But now seems like the size will increase during the operation internally this is causing confusion.
System Info
langchain-version: 0.0.12
yes