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
db801aee
Unverified
Commit
db801aee
authored
Apr 22, 2024
by
Steven Kreitzer
Committed by
GitHub
Apr 22, 2024
Browse files
Merge branch 'dev' into buroa/hybrid-search
parents
4e0b32b5
2d7d6cff
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
132 additions
and
59 deletions
+132
-59
src/lib/i18n/locales/en-US/translation.json
src/lib/i18n/locales/en-US/translation.json
+1
-0
src/lib/stores/index.ts
src/lib/stores/index.ts
+109
-6
src/lib/utils/index.ts
src/lib/utils/index.ts
+0
-1
src/routes/(app)/+page.svelte
src/routes/(app)/+page.svelte
+11
-26
src/routes/(app)/c/[id]/+page.svelte
src/routes/(app)/c/[id]/+page.svelte
+11
-26
No files found.
src/lib/i18n/locales/en-US/translation.json
View file @
db801aee
...
...
@@ -152,6 +152,7 @@
"File Mode"
:
""
,
"File not found."
:
""
,
"Fingerprint spoofing detected: Unable to use initials as avatar. Defaulting to default profile image."
:
""
,
"Fluidly stream large external response chunks"
:
""
,
"Focus chat input"
:
""
,
"Format your variables using square brackets like this:"
:
""
,
"From (Base Model)"
:
""
,
...
...
src/lib/stores/index.ts
View file @
db801aee
import
{
APP_NAME
}
from
'
$lib/constants
'
;
import
{
writable
}
from
'
svelte/store
'
;
import
{
type
Writable
,
writable
}
from
'
svelte/store
'
;
// Backend
export
const
WEBUI_NAME
=
writable
(
APP_NAME
);
export
const
config
=
writable
(
undefined
);
export
const
user
=
writable
(
undefined
);
export
const
config
:
Writable
<
Config
|
undefined
>
=
writable
(
undefined
);
export
const
user
:
Writable
<
SessionUser
|
undefined
>
=
writable
(
undefined
);
// Frontend
export
const
MODEL_DOWNLOAD_POOL
=
writable
({});
...
...
@@ -14,10 +14,10 @@ export const chatId = writable('');
export
const
chats
=
writable
([]);
export
const
tags
=
writable
([]);
export
const
models
=
writable
([]);
export
const
models
:
Writable
<
Model
[]
>
=
writable
([]);
export
const
modelfiles
=
writable
([]);
export
const
prompts
=
writable
([]);
export
const
prompts
:
Writable
<
Prompt
[]
>
=
writable
([]);
export
const
documents
=
writable
([
{
collection_name
:
'
collection_name
'
,
...
...
@@ -33,6 +33,109 @@ export const documents = writable([
}
]);
export
const
settings
=
writable
({});
export
const
settings
:
Writable
<
Settings
>
=
writable
({});
export
const
showSettings
=
writable
(
false
);
export
const
showChangelog
=
writable
(
false
);
type
Model
=
OpenAIModel
|
OllamaModel
;
type
OpenAIModel
=
{
id
:
string
;
name
:
string
;
external
:
boolean
;
source
?:
string
;
};
type
OllamaModel
=
{
id
:
string
;
name
:
string
;
// Ollama specific fields
details
:
OllamaModelDetails
;
size
:
number
;
description
:
string
;
model
:
string
;
modified_at
:
string
;
digest
:
string
;
};
type
OllamaModelDetails
=
{
parent_model
:
string
;
format
:
string
;
family
:
string
;
families
:
string
[]
|
null
;
parameter_size
:
string
;
quantization_level
:
string
;
};
type
Settings
=
{
models
?:
string
[];
conversationMode
?:
boolean
;
speechAutoSend
?:
boolean
;
responseAutoPlayback
?:
boolean
;
audio
?:
AudioSettings
;
showUsername
?:
boolean
;
saveChatHistory
?:
boolean
;
notificationEnabled
?:
boolean
;
title
?:
TitleSettings
;
system
?:
string
;
requestFormat
?:
string
;
keepAlive
?:
string
;
seed
?:
number
;
temperature
?:
string
;
repeat_penalty
?:
string
;
top_k
?:
string
;
top_p
?:
string
;
num_ctx
?:
string
;
options
?:
ModelOptions
;
};
type
ModelOptions
=
{
stop
?:
boolean
;
};
type
AudioSettings
=
{
STTEngine
?:
string
;
TTSEngine
?:
string
;
speaker
?:
string
;
};
type
TitleSettings
=
{
auto
?:
boolean
;
model
?:
string
;
modelExternal
?:
string
;
prompt
?:
string
;
};
type
Prompt
=
{
command
:
string
;
user_id
:
string
;
title
:
string
;
content
:
string
;
timestamp
:
number
;
};
type
Config
=
{
status
?:
boolean
;
name
?:
string
;
version
?:
string
;
default_locale
?:
string
;
images
?:
boolean
;
default_models
?:
string
[];
default_prompt_suggestions
?:
PromptSuggestion
[];
trusted_header_auth
?:
boolean
;
};
type
PromptSuggestion
=
{
content
:
string
;
title
:
[
string
,
string
];
};
type
SessionUser
=
{
id
:
string
;
email
:
string
;
name
:
string
;
role
:
string
;
profile_image_url
:
string
;
};
src/lib/utils/index.ts
View file @
db801aee
...
...
@@ -35,7 +35,6 @@ export const sanitizeResponseContent = (content: string) => {
.
replace
(
/<
\|[
a-z
]
+
\|
$/
,
''
)
.
replace
(
/<$/
,
''
)
.
replaceAll
(
/<
\|[
a-z
]
+
\|
>/g
,
'
'
)
.
replaceAll
(
/<br
\s?\/?
>/gi
,
'
\n
'
)
.
replaceAll
(
'
<
'
,
'
<
'
)
.
trim
();
};
...
...
src/routes/(app)/+page.svelte
View file @
db801aee
...
...
@@ -39,6 +39,7 @@
import
{
RAGTemplate
}
from
'$lib/utils/rag'
;
import
{
LITELLM_API_BASE_URL
,
OLLAMA_API_BASE_URL
,
OPENAI_API_BASE_URL
}
from
'$lib/constants'
;
import
{
WEBUI_BASE_URL
}
from
'$lib/constants'
;
import
{
createOpenAITextStream
}
from
'$lib/apis/streaming'
;
const
i18n
=
getContext
(
'i18n'
);
...
...
@@ -599,38 +600,22 @@
.
pipeThrough
(
splitStream
(
'\n'
))
.
getReader
();
while
(
true
)
{
const
{
value
,
done
}
=
await
reader
.
read
();
const
textStream
=
await
createOpenAITextStream
(
reader
,
$
settings
.
splitLargeChunks
);
console
.
log
(
textStream
);
for
await
(
const
update
of
textStream
)
{
const
{
value
,
done
}
=
update
;
if
(
done
||
stopResponseFlag
||
_chatId
!== $chatId) {
responseMessage
.
done
=
true
;
messages
=
messages
;
break
;
}
try
{
let
lines
=
value
.
split
(
'\n'
);
for
(
const
line
of
lines
)
{
if
(
line
!== '') {
console
.
log
(
line
);
if
(
line
===
'data: [DONE]'
)
{
responseMessage
.
done
=
true
;
messages
=
messages
;
}
else
{
let
data
=
JSON
.
parse
(
line
.
replace
(/^
data
:
/,
''
));
console
.
log
(
data
);
if
(
responseMessage
.
content
==
''
&&
data
.
choices
[
0
].
delta
.
content
==
'\n'
)
{
continue
;
}
else
{
responseMessage
.
content
+=
data
.
choices
[
0
].
delta
.
content
??
''
;
messages
=
messages
;
}
}
}
}
}
catch
(
error
)
{
console
.
log
(
error
);
if
(
responseMessage
.
content
==
''
&&
value
==
'\n'
)
{
continue
;
}
else
{
responseMessage
.
content
+=
value
;
messages
=
messages
;
}
if
($
settings
.
notificationEnabled
&&
!document.hasFocus()) {
...
...
src/routes/(app)/c/[id]/+page.svelte
View file @
db801aee
...
...
@@ -42,6 +42,7 @@
OLLAMA_API_BASE_URL
,
WEBUI_BASE_URL
}
from
'$lib/constants'
;
import
{
createOpenAITextStream
}
from
'$lib/apis/streaming'
;
const
i18n
=
getContext
(
'i18n'
);
...
...
@@ -611,38 +612,22 @@
.
pipeThrough
(
splitStream
(
'\n'
))
.
getReader
();
while
(
true
)
{
const
{
value
,
done
}
=
await
reader
.
read
();
const
textStream
=
await
createOpenAITextStream
(
reader
,
$
settings
.
splitLargeChunks
);
console
.
log
(
textStream
);
for
await
(
const
update
of
textStream
)
{
const
{
value
,
done
}
=
update
;
if
(
done
||
stopResponseFlag
||
_chatId
!== $chatId) {
responseMessage
.
done
=
true
;
messages
=
messages
;
break
;
}
try
{
let
lines
=
value
.
split
(
'\n'
);
for
(
const
line
of
lines
)
{
if
(
line
!== '') {
console
.
log
(
line
);
if
(
line
===
'data: [DONE]'
)
{
responseMessage
.
done
=
true
;
messages
=
messages
;
}
else
{
let
data
=
JSON
.
parse
(
line
.
replace
(/^
data
:
/,
''
));
console
.
log
(
data
);
if
(
responseMessage
.
content
==
''
&&
data
.
choices
[
0
].
delta
.
content
==
'\n'
)
{
continue
;
}
else
{
responseMessage
.
content
+=
data
.
choices
[
0
].
delta
.
content
??
''
;
messages
=
messages
;
}
}
}
}
}
catch
(
error
)
{
console
.
log
(
error
);
if
(
responseMessage
.
content
==
''
&&
value
==
'\n'
)
{
continue
;
}
else
{
responseMessage
.
content
+=
value
;
messages
=
messages
;
}
if
($
settings
.
notificationEnabled
&&
!document.hasFocus()) {
...
...
Prev
1
2
Next
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