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
2eb15ea1
Commit
2eb15ea1
authored
Jun 23, 2024
by
Timothy J. Baek
Browse files
feat: SAFE_MODE
parent
ab700a16
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletion
+25
-1
backend/apps/webui/models/functions.py
backend/apps/webui/models/functions.py
+13
-0
backend/config.py
backend/config.py
+6
-0
backend/main.py
backend/main.py
+6
-1
No files found.
backend/apps/webui/models/functions.py
View file @
2eb15ea1
...
@@ -221,6 +221,19 @@ class FunctionsTable:
...
@@ -221,6 +221,19 @@ class FunctionsTable:
except
:
except
:
return
None
return
None
def
deactivate_all_functions
(
self
)
->
Optional
[
bool
]:
try
:
query
=
Function
.
update
(
**
{
"is_active"
:
False
},
updated_at
=
int
(
time
.
time
()),
)
query
.
execute
()
return
True
except
:
return
None
def
delete_function_by_id
(
self
,
id
:
str
)
->
bool
:
def
delete_function_by_id
(
self
,
id
:
str
)
->
bool
:
try
:
try
:
query
=
Function
.
delete
().
where
((
Function
.
id
==
id
))
query
=
Function
.
delete
().
where
((
Function
.
id
==
id
))
...
...
backend/config.py
View file @
2eb15ea1
...
@@ -167,6 +167,12 @@ for version in soup.find_all("h2"):
...
@@ -167,6 +167,12 @@ for version in soup.find_all("h2"):
CHANGELOG
=
changelog_json
CHANGELOG
=
changelog_json
####################################
# SAFE_MODE
####################################
SAFE_MODE
=
os
.
environ
.
get
(
"SAFE_MODE"
,
"false"
).
lower
()
==
"true"
####################################
####################################
# WEBUI_BUILD_HASH
# WEBUI_BUILD_HASH
####################################
####################################
...
...
backend/main.py
View file @
2eb15ea1
...
@@ -55,7 +55,6 @@ from apps.webui.models.functions import Functions
...
@@ -55,7 +55,6 @@ from apps.webui.models.functions import Functions
from
apps.webui.utils
import
load_toolkit_module_by_id
,
load_function_module_by_id
from
apps.webui.utils
import
load_toolkit_module_by_id
,
load_function_module_by_id
from
utils.utils
import
(
from
utils.utils
import
(
get_admin_user
,
get_admin_user
,
get_verified_user
,
get_verified_user
,
...
@@ -102,10 +101,16 @@ from config import (
...
@@ -102,10 +101,16 @@ from config import (
SEARCH_QUERY_GENERATION_PROMPT_TEMPLATE
,
SEARCH_QUERY_GENERATION_PROMPT_TEMPLATE
,
SEARCH_QUERY_PROMPT_LENGTH_THRESHOLD
,
SEARCH_QUERY_PROMPT_LENGTH_THRESHOLD
,
TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE
,
TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE
,
SAFE_MODE
,
AppConfig
,
AppConfig
,
)
)
from
constants
import
ERROR_MESSAGES
from
constants
import
ERROR_MESSAGES
if
SAFE_MODE
:
print
(
"SAFE MODE ENABLED"
)
Functions
.
deactivate_all_functions
()
logging
.
basicConfig
(
stream
=
sys
.
stdout
,
level
=
GLOBAL_LOG_LEVEL
)
logging
.
basicConfig
(
stream
=
sys
.
stdout
,
level
=
GLOBAL_LOG_LEVEL
)
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
log
.
setLevel
(
SRC_LOG_LEVELS
[
"MAIN"
])
log
.
setLevel
(
SRC_LOG_LEVELS
[
"MAIN"
])
...
...
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