Skip to content

amazon bedrock package incorrectly extracting mimetype from files #5606

Open
@jmmander

Description

@jmmander

Description

When I send a XLXS file to amazon bedrock (using model claude 3.7) using the amazon-bedrock package, i get the following error:

validation errors detected: Value at 'messages.3.member.content.3.member.document.format' failed to satisfy constraint: 
Member must satisfy enum value set: [docx, csv, html, txt, pdf, md, doc, xlsx, xls]; 

I think this happens here where you are extracting the mimetype:

     bedrockContent.push({
                      document: {
                        format: part.mimeType?.split(
                          '/',
                        )?.[1] as BedrockDocumentFormat,
                        name: generateFileId(),
                        source: {
                          bytes: part.data,
                        },
                      },
                    });

Additionally i think the BedrockDocumentFormat type is overly strict with only 3 file types supported. These are the supported types from amazon bedrocks api reference: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_DocumentBlock.html

Code example

No response

AI provider

@ai-sdk/amazon-bedrock 2.2.4

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions