Skip to content

fix(aws): handle image_url object format in block type extraction #8143

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

Merged

Conversation

caro-cc
Copy link
Contributor

@caro-cc caro-cc commented May 8, 2025

It looks like with the current version, a small bug was introduced: after the recent refactoring, the handling of image_url was changed to assume it's always a string. However, image_url can also be an object with a url property, which seems to be causing errors. I'm reintroducing the previous logic to handle both cases properly

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 8, 2025
Copy link

vercel bot commented May 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview May 9, 2025 10:13pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) May 9, 2025 10:13pm

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label May 8, 2025
@caro-cc caro-cc changed the title fix: handle image_url object format in block type extraction fix(aws): handle image_url object format in block type extraction May 8, 2025
@benjamincburns
Copy link
Collaborator

Thanks for flagging this!

@benjamincburns benjamincburns merged commit 588eeff into langchain-ai:main May 9, 2025
24 checks passed
@danny-avila
Copy link

Will there be a release for @langchain/aws to include this change? I believe this is affecting my app:

base64.match is not a function","pregelTaskId":"ade22b10-77dd-5fdb-8cc7-67eedf269664","stack":"TypeError: base64.match is not a function
at extractImageInfo (/node_modules/@langchain/aws/dist/common.cjs:139:32)
at convertLangChainContentBlockToConverseContentBlock (/node_modules/@langchain/aws/dist/common.cjs:176:16)
at /node_modules/@langchain/aws/dist/common.cjs:257:34
at Array.map (<anonymous>)
at convertHumanMessageToConverseMessage (/node_modules/@langchain/aws/dist/common.cjs:257:23)
at /node_modules/@langchain/aws/dist/common.cjs:327:20
at Array.map (<anonymous>)
at convertToConverseMessages (/node_modules/@langchain/aws/dist/common.cjs:322:10)
at ChatBedrockConverse._streamResponseChunks (/node_modules/@langchain/aws/dist/chat_models.cjs:686:96)
at _streamResponseChunks.next (<anonymous>)"

export function extractImageInfo(base64: string): ContentBlock.ImageMember {
// Extract the format from the base64 string
const formatMatch = base64.match(/^data:image\/(\w+);base64,/);
let format: ImageFormat | undefined;

danny-avila/LibreChat#7354

@caro-cc
Copy link
Contributor Author

caro-cc commented May 13, 2025

@danny-avila in the meantime (until the next release), we are using the previous version (0.1.8), which is not affected by this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants