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
4e1b52e9
"...composable_kernel.git" did not exist on "95479e6767b3d254fbc9b030bae28d4863ea48eb"
Commit
4e1b52e9
authored
Jan 22, 2024
by
Timothy J. Baek
Browse files
feat: custom interface support
parent
b246c62d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
5 deletions
+60
-5
backend/apps/web/main.py
backend/apps/web/main.py
+4
-2
backend/apps/web/routers/configs.py
backend/apps/web/routers/configs.py
+28
-3
backend/config.py
backend/config.py
+28
-0
No files found.
backend/apps/web/main.py
View file @
4e1b52e9
...
@@ -11,14 +11,15 @@ from apps.web.routers import (
...
@@ -11,14 +11,15 @@ from apps.web.routers import (
configs
,
configs
,
utils
,
utils
,
)
)
from
config
import
WEBUI_VERSION
,
WEBUI_AUTH
from
config
import
WEBUI_VERSION
,
WEBUI_AUTH
,
DEFAULT_MODELS
,
DEFAULT_PROMPT_SUGGESTIONS
app
=
FastAPI
()
app
=
FastAPI
()
origins
=
[
"*"
]
origins
=
[
"*"
]
app
.
state
.
ENABLE_SIGNUP
=
True
app
.
state
.
ENABLE_SIGNUP
=
True
app
.
state
.
DEFAULT_MODELS
=
None
app
.
state
.
DEFAULT_MODELS
=
DEFAULT_MODELS
app
.
state
.
DEFAULT_PROMPT_SUGGESTIONS
=
DEFAULT_PROMPT_SUGGESTIONS
app
.
add_middleware
(
app
.
add_middleware
(
CORSMiddleware
,
CORSMiddleware
,
...
@@ -46,4 +47,5 @@ async def get_status():
...
@@ -46,4 +47,5 @@ async def get_status():
"version"
:
WEBUI_VERSION
,
"version"
:
WEBUI_VERSION
,
"auth"
:
WEBUI_AUTH
,
"auth"
:
WEBUI_AUTH
,
"default_models"
:
app
.
state
.
DEFAULT_MODELS
,
"default_models"
:
app
.
state
.
DEFAULT_MODELS
,
"default_prompt_suggestions"
:
app
.
state
.
DEFAULT_PROMPT_SUGGESTIONS
,
}
}
backend/apps/web/routers/configs.py
View file @
4e1b52e9
...
@@ -21,15 +21,24 @@ class SetDefaultModelsForm(BaseModel):
...
@@ -21,15 +21,24 @@ class SetDefaultModelsForm(BaseModel):
models
:
str
models
:
str
class
PromptSuggestion
(
BaseModel
):
title
:
List
[
str
]
content
:
str
class
SetDefaultSuggestionsForm
(
BaseModel
):
suggestions
:
List
[
PromptSuggestion
]
############################
############################
# SetDefaultModels
# SetDefaultModels
############################
############################
@
router
.
post
(
"/default/models"
,
response_model
=
str
)
@
router
.
post
(
"/default/models"
,
response_model
=
str
)
async
def
set_global_default_models
(
request
:
Request
,
async
def
set_global_default_models
(
form_data
:
SetDefaultModelsForm
,
request
:
Request
,
form_data
:
SetDefaultModelsForm
,
user
=
Depends
(
get_current_user
)
user
=
Depends
(
get_current_user
)
):
):
if
user
.
role
==
"admin"
:
if
user
.
role
==
"admin"
:
request
.
app
.
state
.
DEFAULT_MODELS
=
form_data
.
models
request
.
app
.
state
.
DEFAULT_MODELS
=
form_data
.
models
return
request
.
app
.
state
.
DEFAULT_MODELS
return
request
.
app
.
state
.
DEFAULT_MODELS
...
@@ -38,3 +47,19 @@ async def set_global_default_models(request: Request,
...
@@ -38,3 +47,19 @@ async def set_global_default_models(request: Request,
status_code
=
status
.
HTTP_403_FORBIDDEN
,
status_code
=
status
.
HTTP_403_FORBIDDEN
,
detail
=
ERROR_MESSAGES
.
ACCESS_PROHIBITED
,
detail
=
ERROR_MESSAGES
.
ACCESS_PROHIBITED
,
)
)
@
router
.
post
(
"/default/suggestions"
,
response_model
=
str
)
async
def
set_global_default_suggestions
(
request
:
Request
,
form_data
:
SetDefaultSuggestionsForm
,
user
=
Depends
(
get_current_user
),
):
if
user
.
role
==
"admin"
:
request
.
app
.
state
.
DEFAULT_PROMPT_SUGGESTIONS
=
form_data
.
suggestions
return
request
.
app
.
state
.
DEFAULT_PROMPT_SUGGESTIONS
else
:
raise
HTTPException
(
status_code
=
status
.
HTTP_403_FORBIDDEN
,
detail
=
ERROR_MESSAGES
.
ACCESS_PROHIBITED
,
)
backend/config.py
View file @
4e1b52e9
...
@@ -54,6 +54,34 @@ OPENAI_API_BASE_URL = os.environ.get("OPENAI_API_BASE_URL", "")
...
@@ -54,6 +54,34 @@ OPENAI_API_BASE_URL = os.environ.get("OPENAI_API_BASE_URL", "")
if
OPENAI_API_BASE_URL
==
""
:
if
OPENAI_API_BASE_URL
==
""
:
OPENAI_API_BASE_URL
=
"https://api.openai.com/v1"
OPENAI_API_BASE_URL
=
"https://api.openai.com/v1"
####################################
# WEBUI
####################################
DEFAULT_MODELS
=
os
.
environ
.
get
(
"DEFAULT_MODELS"
,
None
)
DEFAULT_PROMPT_SUGGESTIONS
=
os
.
environ
.
get
(
"DEFAULT_PROMPT_SUGGESTIONS"
,
[
{
"title"
:
[
"Help me study"
,
"vocabulary for a college entrance exam"
],
"content"
:
"Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option."
,
},
{
"title"
:
[
"Give me ideas"
,
"for what to do with my kids' art"
],
"content"
:
"What are 5 creative things I could do with my kids' art? I don't want to throw them away, but it's also so much clutter."
,
},
{
"title"
:
[
"Tell me a fun fact"
,
"about the Roman Empire"
],
"content"
:
"Tell me a random fun fact about the Roman Empire"
,
},
{
"title"
:
[
"Show me a code snippet"
,
"of a website's sticky header"
],
"content"
:
"Show me a code snippet of a website's sticky header in CSS and JavaScript."
,
},
],
)
####################################
####################################
# WEBUI_VERSION
# WEBUI_VERSION
####################################
####################################
...
...
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