feat(*): add multiple image support
This commit is contained in:
@@ -35,6 +35,8 @@ export const create = mutation({
|
||||
source: v.union(v.literal('telegram'), v.literal('web')),
|
||||
imageBase64: v.optional(v.string()),
|
||||
imageMediaType: v.optional(v.string()),
|
||||
imagesBase64: v.optional(v.array(v.string())),
|
||||
imagesMediaTypes: v.optional(v.array(v.string())),
|
||||
followUpOptions: v.optional(v.array(v.string())),
|
||||
isStreaming: v.optional(v.boolean())
|
||||
},
|
||||
@@ -47,6 +49,8 @@ export const create = mutation({
|
||||
source: args.source,
|
||||
imageBase64: args.imageBase64,
|
||||
imageMediaType: args.imageMediaType,
|
||||
imagesBase64: args.imagesBase64,
|
||||
imagesMediaTypes: args.imagesMediaTypes,
|
||||
followUpOptions: args.followUpOptions,
|
||||
createdAt: Date.now(),
|
||||
isStreaming: args.isStreaming
|
||||
@@ -166,11 +170,24 @@ export const getChatImages = query({
|
||||
.withIndex('by_chat_id', (q) => q.eq('chatId', args.chatId))
|
||||
.collect();
|
||||
|
||||
return messages
|
||||
.filter((m) => m.imageBase64 && m.imageMediaType)
|
||||
.map((m) => ({
|
||||
base64: m.imageBase64!,
|
||||
mediaType: m.imageMediaType!
|
||||
}));
|
||||
const images: Array<{ base64: string; mediaType: string }> = [];
|
||||
|
||||
for (const m of messages) {
|
||||
if (m.imagesBase64 && m.imagesMediaTypes) {
|
||||
for (let i = 0; i < m.imagesBase64.length; i++) {
|
||||
images.push({
|
||||
base64: m.imagesBase64[i],
|
||||
mediaType: m.imagesMediaTypes[i]
|
||||
});
|
||||
}
|
||||
} else if (m.imageBase64 && m.imageMediaType) {
|
||||
images.push({
|
||||
base64: m.imageBase64,
|
||||
mediaType: m.imageMediaType
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return images;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user