-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(bedrock): Empty responses when enabling Bedrock citations for Anthropic models #9860
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for submitting another great PR to the anthropic provider!
Could you please update tests and add or update an example (in examples/ai-core/generate-text) to cover the new functionality?
Head branch was pushed to by a user without write access
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
|
@gr2m Tests and documentation is now added, went ahead and fixed the streaming version too and refactored to align with the anthropic provider |
|
@gr2m just in case you missed it, this is ready for review and merging |
Background
When using Anthropic models through AWS Bedrock with citations enabled (via
providerOptions.bedrock.citations.enabled), the SDK returns empty responses. This is because Bedrock changes its response format when citations are enabled - instead of returningTextBlockobjects, it returnsCitationsContentBlockobjects. The current implementation only handlesTextBlocktypes, causing the text content within citation blocks to be ignored.Enabling citations significantly improves Anthropic models' ability to work with PDF documents and other source materials in Bedrock, making this an important feature for RAG applications.
Summary
CitationsContentBlockin Bedrock responsesTextBlockresponsesManual Verification
Checklist
pnpm changesetin the project root)Related Issues
Fixes #9823