fix: 修复阿里生图模型图片解析问题
- AI SDK convertToModelMessages 将 url 转换为 data 字段 - 同时支持 url 和 data 字段以兼容不同格式
This commit is contained in:
parent
da207f654e
commit
4008e958a3
@ -333,14 +333,17 @@ export function createAlibabaImage({ apiKey, baseURL }: AlibabaImageConfig) {
|
||||
} else {
|
||||
imageUrls.push(imageUrl);
|
||||
}
|
||||
} else if (part.type === "file" && (part as any).url) {
|
||||
// 格式3: { type: "file", url: string } - 来自 ChatMessage 的原始格式
|
||||
const fileUrl = (part as any).url;
|
||||
if (fileUrl.startsWith("data:")) {
|
||||
const url = await uploadBase64ToS3(fileUrl);
|
||||
imageUrls.push(url);
|
||||
} else {
|
||||
imageUrls.push(fileUrl);
|
||||
} else if (part.type === "file") {
|
||||
// 格式3: { type: "file", url/data: string } - 来自 ChatMessage 的原始格式
|
||||
// AI SDK convertToModelMessages 会将 url 转换为 data 字段
|
||||
const fileUrl = (part as any).url || (part as any).data;
|
||||
if (fileUrl) {
|
||||
if (fileUrl.startsWith("data:")) {
|
||||
const url = await uploadBase64ToS3(fileUrl);
|
||||
imageUrls.push(url);
|
||||
} else {
|
||||
imageUrls.push(fileUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user