-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Description
I noticed that when using the FilePart
type to send files to the Bedrock provider, there's currently no support for passing through the filename
field — even though it's part of the interface.
In the current implementation, the document name is always auto-generated:
let documentCounter = 0;
const generateDocumentName = () => `document-${++documentCounter}`;
bedrockContent.push({
document: {
format: getBedrockDocumentFormat(part.mediaType),
name: generateDocumentName(), // filename is ignored
source: { bytes: convertToBase64(part.data) },
...(enableCitations && {
citations: { enabled: true },
}),
},
});
Since the FilePart
interface already includes an optional filename
:
interface FilePart {
...
filename?: string;
...
}
It would be great if the Bedrock provider used the filename
value (when provided) instead of always generating a default name.
Suggested change:
Something like this would be ideal:
name: part.filename ?? generateDocumentName(),
This allows users to provide meaningful filenames when needed, while still falling back to the generated one if no filename
is supplied.
Our team noticed that when we reference documents by filename in the chat message the LLM doesn't recognize them as it only has the sanitized name. This was also confusing to us as we provided the filenames to the LLM but they were getting silently sanitized.
AI SDK Version
@ai-sdk/amazon-bedrock: latest
Code of Conduct
- I agree to follow this project's Code of Conduct