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
8116b043
Unverified
Commit
8116b043
authored
May 21, 2024
by
Aly Mobarak
Browse files
Filter message and don't send over any message that has empty contents to OpenAI's API.
parent
3355577b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
src/routes/(app)/c/[id]/+page.svelte
src/routes/(app)/c/[id]/+page.svelte
+16
-16
No files found.
src/routes/(app)/c/[id]/+page.svelte
View file @
8116b043
<
script
lang
=
"ts"
>
<
script
lang
=
"ts"
>
import
{
v4
as
uuidv4
}
from
'uuid'
;
import
{
toast
}
from
'svelte-sonner'
;
import
{
toast
}
from
'svelte-sonner'
;
import
{
v4
as
uuidv4
}
from
'uuid'
;
import
{
onMount
,
tick
,
getContext
}
from
'svelte'
;
import
{
goto
}
from
'$app/navigation'
;
import
{
goto
}
from
'$app/navigation'
;
import
{
page
}
from
'$app/stores'
;
import
{
page
}
from
'$app/stores'
;
import
{
import
{
models
,
modelfiles
,
user
,
settings
,
chats
,
chatId
,
config
,
WEBUI_NAME
,
WEBUI_NAME
,
tags
as
_tags
,
tags
as
_tags
,
showSidebar
chatId
,
chats
,
config
,
modelfiles
,
models
,
settings
,
showSidebar
,
user
}
from
'$lib/stores'
;
}
from
'$lib/stores'
;
import
{
copyToClipboard
,
splitStream
,
convertMessagesToHistory
}
from
'$lib/utils'
;
import
{
convertMessagesToHistory
,
copyToClipboard
,
splitStream
}
from
'$lib/utils'
;
import
{
getContext
,
onMount
,
tick
}
from
'svelte'
;
import
{
generateChatCompletion
,
cancelOllamaRequest
}
from
'$lib/apis/ollama'
;
import
{
import
{
addTagById
,
addTagById
,
createNewChat
,
createNewChat
,
...
@@ -30,20 +29,21 @@
...
@@ -30,20 +29,21 @@
getTagsById
,
getTagsById
,
updateChatById
updateChatById
}
from
'$lib/apis/chats'
;
}
from
'$lib/apis/chats'
;
import
{
cancelOllamaRequest
,
generateChatCompletion
}
from
'$lib/apis/ollama'
;
import
{
generateOpenAIChatCompletion
,
generateTitle
}
from
'$lib/apis/openai'
;
import
{
generateOpenAIChatCompletion
,
generateTitle
}
from
'$lib/apis/openai'
;
import
MessageInput
from
'$lib/components/chat/MessageInput.svelte'
;
import
MessageInput
from
'$lib/components/chat/MessageInput.svelte'
;
import
Messages
from
'$lib/components/chat/Messages.svelte'
;
import
Messages
from
'$lib/components/chat/Messages.svelte'
;
import
Navbar
from
'$lib/components/layout/Navbar.svelte'
;
import
Navbar
from
'$lib/components/layout/Navbar.svelte'
;
import
{
queryMemory
}
from
'$lib/apis/memories'
;
import
{
createOpenAITextStream
}
from
'$lib/apis/streaming'
;
import
{
import
{
LITELLM_API_BASE_URL
,
LITELLM_API_BASE_URL
,
OPENAI_API_BASE_URL
,
OLLAMA_API_BASE_URL
,
OLLAMA_API_BASE_URL
,
OPENAI_API_BASE_URL
,
WEBUI_BASE_URL
WEBUI_BASE_URL
}
from
'$lib/constants'
;
}
from
'$lib/constants'
;
import
{
createOpenAITextStream
}
from
'$lib/apis/streaming'
;
import
{
queryMemory
}
from
'$lib/apis/memories'
;
const
i18n
=
getContext
(
'i18n'
);
const
i18n
=
getContext
(
'i18n'
);
...
@@ -619,7 +619,7 @@
...
@@ -619,7 +619,7 @@
: undefined,
: undefined,
...messages
...messages
]
]
.filter((message) => message)
.filter((message) => message
.content != ""
)
.map((message, idx, arr) => ({
.map((message, idx, arr) => ({
role: message.role,
role: message.role,
...((message.files?.filter((file) => file.type === 'image').length > 0 ?? false) &&
...((message.files?.filter((file) => file.type === 'image').length > 0 ?? false) &&
...
...
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