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
c2759a11
Unverified
Commit
c2759a11
authored
Feb 19, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Feb 19, 2024
Browse files
Merge pull request #810 from open-webui/config
feat: config.json support
parents
76a78893
3d10f21b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
4 deletions
+54
-4
backend/.gitignore
backend/.gitignore
+1
-0
backend/config.py
backend/config.py
+19
-4
backend/data/config.json
backend/data/config.json
+34
-0
No files found.
backend/.gitignore
View file @
c2759a11
...
@@ -7,4 +7,5 @@ uploads
...
@@ -7,4 +7,5 @@ uploads
_test
_test
Pipfile
Pipfile
data/*
data/*
!data/config.json
.webui_secret_key
.webui_secret_key
\ No newline at end of file
backend/config.py
View file @
c2759a11
...
@@ -5,6 +5,8 @@ from secrets import token_bytes
...
@@ -5,6 +5,8 @@ from secrets import token_bytes
from
base64
import
b64encode
from
base64
import
b64encode
from
constants
import
ERROR_MESSAGES
from
constants
import
ERROR_MESSAGES
from
pathlib
import
Path
from
pathlib
import
Path
import
json
try
:
try
:
from
dotenv
import
load_dotenv
,
find_dotenv
from
dotenv
import
load_dotenv
,
find_dotenv
...
@@ -28,6 +30,12 @@ ENV = os.environ.get("ENV", "dev")
...
@@ -28,6 +30,12 @@ ENV = os.environ.get("ENV", "dev")
DATA_DIR
=
str
(
Path
(
os
.
getenv
(
"DATA_DIR"
,
"./data"
)).
resolve
())
DATA_DIR
=
str
(
Path
(
os
.
getenv
(
"DATA_DIR"
,
"./data"
)).
resolve
())
FRONTEND_BUILD_DIR
=
str
(
Path
(
os
.
getenv
(
"FRONTEND_BUILD_DIR"
,
"../build"
)))
FRONTEND_BUILD_DIR
=
str
(
Path
(
os
.
getenv
(
"FRONTEND_BUILD_DIR"
,
"../build"
)))
try
:
with
open
(
f
"
{
DATA_DIR
}
/config.json"
,
"r"
)
as
f
:
CONFIG_DATA
=
json
.
load
(
f
)
except
:
CONFIG_DATA
=
{}
####################################
####################################
# File Upload DIR
# File Upload DIR
####################################
####################################
...
@@ -80,9 +88,14 @@ if OPENAI_API_BASE_URL == "":
...
@@ -80,9 +88,14 @@ if OPENAI_API_BASE_URL == "":
ENABLE_SIGNUP
=
os
.
environ
.
get
(
"ENABLE_SIGNUP"
,
True
)
ENABLE_SIGNUP
=
os
.
environ
.
get
(
"ENABLE_SIGNUP"
,
True
)
DEFAULT_MODELS
=
os
.
environ
.
get
(
"DEFAULT_MODELS"
,
None
)
DEFAULT_MODELS
=
os
.
environ
.
get
(
"DEFAULT_MODELS"
,
None
)
DEFAULT_PROMPT_SUGGESTIONS
=
os
.
environ
.
get
(
"DEFAULT_PROMPT_SUGGESTIONS"
,
[
DEFAULT_PROMPT_SUGGESTIONS
=
(
CONFIG_DATA
[
"ui"
][
"prompt_suggestions"
]
if
"ui"
in
CONFIG_DATA
and
"prompt_suggestions"
in
CONFIG_DATA
[
"ui"
]
and
type
(
CONFIG_DATA
[
"ui"
][
"prompt_suggestions"
])
is
list
else
[
{
{
"title"
:
[
"Help me study"
,
"vocabulary for a college entrance exam"
],
"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."
,
"content"
:
"Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option."
,
...
@@ -99,8 +112,10 @@ DEFAULT_PROMPT_SUGGESTIONS = os.environ.get(
...
@@ -99,8 +112,10 @@ DEFAULT_PROMPT_SUGGESTIONS = os.environ.get(
"title"
:
[
"Show me a code snippet"
,
"of a website's sticky header"
],
"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."
,
"content"
:
"Show me a code snippet of a website's sticky header in CSS and JavaScript."
,
},
},
]
,
]
)
)
DEFAULT_USER_ROLE
=
"pending"
DEFAULT_USER_ROLE
=
"pending"
USER_PERMISSIONS
=
{
"chat"
:
{
"deletion"
:
True
}}
USER_PERMISSIONS
=
{
"chat"
:
{
"deletion"
:
True
}}
...
...
backend/data/config.json
0 → 100644
View file @
c2759a11
{
"ui"
:
{
"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."
},
]
}
}
\ No newline at end of file
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