|
@@ -671,15 +671,31 @@ export namespace SessionPrompt {
|
|
|
result,
|
|
result,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- const output = result.content
|
|
|
|
|
- .filter((x: any) => x.type === "text")
|
|
|
|
|
- .map((x: any) => x.text)
|
|
|
|
|
- .join("\n\n")
|
|
|
|
|
|
|
+ const textParts: string[] = []
|
|
|
|
|
+ const attachments: MessageV2.FilePart[] = []
|
|
|
|
|
+
|
|
|
|
|
+ for (const item of result.content) {
|
|
|
|
|
+ if (item.type === "text") {
|
|
|
|
|
+ textParts.push(item.text)
|
|
|
|
|
+ } else if (item.type === "image") {
|
|
|
|
|
+ attachments.push({
|
|
|
|
|
+ id: Identifier.ascending("part"),
|
|
|
|
|
+ sessionID: input.sessionID,
|
|
|
|
|
+ messageID: input.processor.message.id,
|
|
|
|
|
+ type: "file",
|
|
|
|
|
+ mime: item.mimeType,
|
|
|
|
|
+ url: `data:${item.mimeType};base64,${item.data}`,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ // Add support for other types if needed
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
title: "",
|
|
title: "",
|
|
|
metadata: result.metadata ?? {},
|
|
metadata: result.metadata ?? {},
|
|
|
- output,
|
|
|
|
|
|
|
+ output: textParts.join("\n\n"),
|
|
|
|
|
+ attachments,
|
|
|
|
|
+ content: result.content, // directly return content to preserve ordering when outputting to model
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
item.toModelOutput = (result) => {
|
|
item.toModelOutput = (result) => {
|