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
dc705c49
Commit
dc705c49
authored
Feb 21, 2024
by
Timothy J. Baek
Browse files
refac: settings
parent
797ed9ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
18 deletions
+36
-18
backend/apps/images/main.py
backend/apps/images/main.py
+10
-10
src/lib/components/chat/Settings/Images.svelte
src/lib/components/chat/Settings/Images.svelte
+26
-8
No files found.
backend/apps/images/main.py
View file @
dc705c49
...
...
@@ -62,16 +62,16 @@ async def get_openai_url(user=Depends(get_admin_user)):
@
app
.
post
(
"/url/update"
)
async
def
update_openai_url
(
form_data
:
UrlUpdateForm
,
user
=
Depends
(
get_admin_user
)):
try
:
r
=
requests
.
head
(
form_data
.
url
)
if
r
.
ok
:
app
.
state
.
AUTOMATIC1111_BASE_URL
=
form_data
.
url
.
strip
(
"/"
)
return
{
"AUTOMATIC1111_BASE_URL"
:
app
.
state
.
AUTOMATIC1111_BASE_URL
,
"status"
:
True
,
}
except
Exception
as
e
:
raise
HTTPException
(
status_code
=
r
.
status_code
,
detail
=
ERROR_MESSAGES
.
DEFAULT
(
e
))
if
form_data
.
url
==
""
:
app
.
state
.
AUTOMATIC1111_BASE_URL
=
AUTOMATIC1111_BASE_URL
else
:
app
.
state
.
AUTOMATIC1111_BASE_URL
=
form_data
.
url
.
strip
(
"/"
)
return
{
"AUTOMATIC1111_BASE_URL"
:
app
.
state
.
AUTOMATIC1111_BASE_URL
,
"status"
:
True
,
}
@
app
.
get
(
"/models"
)
...
...
src/lib/components/chat/Settings/Images.svelte
View file @
dc705c49
...
...
@@ -25,6 +25,14 @@
let selectedModel = '';
let models = [];
const getModels = async () => {
models = await getDiffusionModels(localStorage.token).catch((error) => {
toast.error(error);
return null;
});
selectedModel = await getDefaultDiffusionModel(localStorage.token);
};
const updateAUTOMATIC1111UrlHandler = async () => {
const res = await updateAUTOMATIC1111Url(localStorage.token, AUTOMATIC1111_BASE_URL).catch(
(error) => {
...
...
@@ -34,11 +42,13 @@
);
if (res) {
toast.success('Server connection verified');
AUTOMATIC1111_BASE_URL = res;
models = await getDiffusionModels(localStorage.token);
selectedModel = await getDefaultDiffusionModel(localStorage.token);
await getModels();
if (models) {
toast.success('Server connection verified');
}
} else {
AUTOMATIC1111_BASE_URL = await getAUTOMATIC1111Url(localStorage.token);
}
...
...
@@ -46,8 +56,17 @@
const toggleImageGeneration = async () => {
if (AUTOMATIC1111_BASE_URL) {
enableImageGeneration = await toggleImageGenerationEnabledStatus(localStorage.token);
config.set(await getBackendConfig(localStorage.token));
enableImageGeneration = await toggleImageGenerationEnabledStatus(localStorage.token).catch(
(error) => {
toast.error(error);
return false;
}
);
if (enableImageGeneration) {
config.set(await getBackendConfig(localStorage.token));
getModels();
}
} else {
enableImageGeneration = false;
toast.error('AUTOMATIC1111_BASE_URL not provided');
...
...
@@ -59,9 +78,8 @@
enableImageGeneration = await getImageGenerationEnabledStatus(localStorage.token);
AUTOMATIC1111_BASE_URL = await getAUTOMATIC1111Url(localStorage.token);
if (AUTOMATIC1111_BASE_URL) {
models = await getDiffusionModels(localStorage.token);
selectedModel = await getDefaultDiffusionModel(localStorage.token);
if (enableImageGeneration && AUTOMATIC1111_BASE_URL) {
getModels();
}
}
});
...
...
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