mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 13:40:55 +00:00
feat: include only last images
This commit is contained in:
parent
f70e6caf0e
commit
6c7c35ad12
@ -316,9 +316,7 @@
|
||||
// Scroll down
|
||||
window.scrollTo({ top: document.body.scrollHeight });
|
||||
|
||||
const [res, controller] = await generateChatCompletion(localStorage.token, {
|
||||
model: model,
|
||||
messages: [
|
||||
const messagesBody = [
|
||||
$settings.system
|
||||
? {
|
||||
role: 'system',
|
||||
@ -336,7 +334,27 @@
|
||||
.filter((file) => file.type === 'image')
|
||||
.map((file) => file.url.slice(file.url.indexOf(',') + 1))
|
||||
})
|
||||
})),
|
||||
}));
|
||||
|
||||
let lastImageIndex = -1;
|
||||
|
||||
// Find the index of the last object with images
|
||||
messagesBody.forEach((item, index) => {
|
||||
if (item.images) {
|
||||
lastImageIndex = index;
|
||||
}
|
||||
});
|
||||
|
||||
// Remove images from all but the last one
|
||||
messagesBody.forEach((item, index) => {
|
||||
if (index !== lastImageIndex) {
|
||||
delete item.images;
|
||||
}
|
||||
});
|
||||
|
||||
const [res, controller] = await generateChatCompletion(localStorage.token, {
|
||||
model: model,
|
||||
messages: messagesBody,
|
||||
options: {
|
||||
...($settings.options ?? {})
|
||||
},
|
||||
|
@ -330,9 +330,7 @@
|
||||
// Scroll down
|
||||
window.scrollTo({ top: document.body.scrollHeight });
|
||||
|
||||
const [res, controller] = await generateChatCompletion(localStorage.token, {
|
||||
model: model,
|
||||
messages: [
|
||||
const messagesBody = [
|
||||
$settings.system
|
||||
? {
|
||||
role: 'system',
|
||||
@ -350,7 +348,27 @@
|
||||
.filter((file) => file.type === 'image')
|
||||
.map((file) => file.url.slice(file.url.indexOf(',') + 1))
|
||||
})
|
||||
})),
|
||||
}));
|
||||
|
||||
let lastImageIndex = -1;
|
||||
|
||||
// Find the index of the last object with images
|
||||
messagesBody.forEach((item, index) => {
|
||||
if (item.images) {
|
||||
lastImageIndex = index;
|
||||
}
|
||||
});
|
||||
|
||||
// Remove images from all but the last one
|
||||
messagesBody.forEach((item, index) => {
|
||||
if (index !== lastImageIndex) {
|
||||
delete item.images;
|
||||
}
|
||||
});
|
||||
|
||||
const [res, controller] = await generateChatCompletion(localStorage.token, {
|
||||
model: model,
|
||||
messages: messagesBody,
|
||||
options: {
|
||||
...($settings.options ?? {})
|
||||
},
|
||||
@ -358,6 +376,8 @@
|
||||
});
|
||||
|
||||
if (res && res.ok) {
|
||||
console.log('controller', controller);
|
||||
|
||||
const reader = res.body
|
||||
.pipeThrough(new TextDecoderStream())
|
||||
.pipeThrough(splitStream('\n'))
|
||||
@ -375,6 +395,7 @@
|
||||
}
|
||||
|
||||
currentRequestId = null;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user