mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00
fix: stop duplication of file in chat on end of response stream
This commit is contained in:
parent
800391b264
commit
f211e25aac
1 changed files with 15 additions and 1 deletions
|
@ -245,7 +245,21 @@ class AgentClient extends BaseClient {
|
||||||
this.addImageURLs(message, attachments),
|
this.addImageURLs(message, attachments),
|
||||||
this.addDocuments(message, attachments),
|
this.addDocuments(message, attachments),
|
||||||
]);
|
]);
|
||||||
return [...imageFiles, ...documentFiles];
|
|
||||||
|
const allFiles = [...imageFiles, ...documentFiles];
|
||||||
|
const seenFileIds = new Set();
|
||||||
|
const uniqueFiles = [];
|
||||||
|
|
||||||
|
for (const file of allFiles) {
|
||||||
|
if (file.file_id && !seenFileIds.has(file.file_id)) {
|
||||||
|
seenFileIds.add(file.file_id);
|
||||||
|
uniqueFiles.push(file);
|
||||||
|
} else if (!file.file_id) {
|
||||||
|
uniqueFiles.push(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return uniqueFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
async buildMessages(
|
async buildMessages(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue