pull/19975/merge
이우진 2026-04-08 05:30:24 +00:00 committed by GitHub
commit f47fa73ad4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 0 deletions

View File

@ -275,9 +275,24 @@ export namespace ProviderTransform {
})
}
function sanitizeBedrockFilenames(msgs: ModelMessage[]): ModelMessage[] {
return msgs.map((msg) => {
if (msg.role !== "user" || !Array.isArray(msg.content)) return msg
const content = msg.content.map((part) => {
if (part.type !== "file" || !part.filename) return part
const sanitized = part.filename.replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9\s\-()[\]]/g, "-")
return { ...part, filename: sanitized || "file" }
})
return { ...msg, content }
})
}
export function message(msgs: ModelMessage[], model: Provider.Model, options: Record<string, unknown>) {
msgs = unsupportedParts(msgs, model)
msgs = normalizeMessages(msgs, model, options)
if (model.providerID.includes("bedrock") || model.api.npm === "@ai-sdk/amazon-bedrock") {
msgs = sanitizeBedrockFilenames(msgs)
}
if (
(model.providerID === "anthropic" ||
model.providerID === "google-vertex-anthropic" ||