Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
c4ca4663
Unverified
Commit
c4ca4663
authored
Feb 04, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Feb 04, 2024
Browse files
Merge pull request #642 from ollama-webui/multimodal-fix
feat: include only last images
parents
f70e6caf
6c7c35ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
38 deletions
+77
-38
src/routes/(app)/+page.svelte
src/routes/(app)/+page.svelte
+37
-19
src/routes/(app)/c/[id]/+page.svelte
src/routes/(app)/c/[id]/+page.svelte
+40
-19
No files found.
src/routes/(app)/+page.svelte
View file @
c4ca4663
...
...
@@ -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 ?? {})
},
...
...
src/routes/(app)/c/[id]/+page.svelte
View file @
c4ca4663
...
...
@@ -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;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment