fix: message attachment merge (#8498)

This commit is contained in:
DarkSky 2024-10-16 12:57:53 +08:00 committed by GitHub
parent e7dcf63c77
commit 075cedabf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -149,7 +149,17 @@ export class ChatSession implements AsyncDisposable {
normalizedParams, normalizedParams,
this.config.sessionId this.config.sessionId
); );
finished[0].attachments = firstMessage.attachments;
// attachments should be combined with the first user message
const firstUserMessage =
finished.find(m => m.role === 'user') || finished[0];
firstUserMessage.attachments = [
finished[0].attachments || [],
firstMessage.attachments || [],
]
.flat()
.filter(v => !!v?.trim());
return finished; return finished;
} }