mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 03:47:49 +01:00
feat: direct api settings backend
This commit is contained in:
@@ -683,6 +683,17 @@ Path(UPLOAD_DIR).mkdir(parents=True, exist_ok=True)
|
||||
CACHE_DIR = f"{DATA_DIR}/cache"
|
||||
Path(CACHE_DIR).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
####################################
|
||||
# DIRECT API
|
||||
####################################
|
||||
|
||||
ENABLE_DIRECT_API = PersistentConfig(
|
||||
"ENABLE_DIRECT_API",
|
||||
"direct.enable",
|
||||
os.environ.get("ENABLE_DIRECT_API", "True").lower() == "true",
|
||||
)
|
||||
|
||||
####################################
|
||||
# OLLAMA_BASE_URL
|
||||
####################################
|
||||
|
||||
@@ -97,6 +97,8 @@ from open_webui.config import (
|
||||
OPENAI_API_BASE_URLS,
|
||||
OPENAI_API_KEYS,
|
||||
OPENAI_API_CONFIGS,
|
||||
# Direct API
|
||||
ENABLE_DIRECT_API,
|
||||
# Code Interpreter
|
||||
ENABLE_CODE_INTERPRETER,
|
||||
CODE_INTERPRETER_ENGINE,
|
||||
@@ -403,6 +405,14 @@ app.state.config.OPENAI_API_CONFIGS = OPENAI_API_CONFIGS
|
||||
|
||||
app.state.OPENAI_MODELS = {}
|
||||
|
||||
########################################
|
||||
#
|
||||
# DIRECT API
|
||||
#
|
||||
########################################
|
||||
|
||||
app.state.config.ENABLE_DIRECT_API = ENABLE_DIRECT_API
|
||||
|
||||
########################################
|
||||
#
|
||||
# WEBUI
|
||||
@@ -1046,6 +1056,7 @@ async def get_app_config(request: Request):
|
||||
"enable_websocket": ENABLE_WEBSOCKET_SUPPORT,
|
||||
**(
|
||||
{
|
||||
"enable_direct_api": app.state.config.ENABLE_DIRECT_API,
|
||||
"enable_channels": app.state.config.ENABLE_CHANNELS,
|
||||
"enable_web_search": app.state.config.ENABLE_RAG_WEB_SEARCH,
|
||||
"enable_code_interpreter": app.state.config.ENABLE_CODE_INTERPRETER,
|
||||
|
||||
@@ -36,6 +36,32 @@ async def export_config(user=Depends(get_admin_user)):
|
||||
return get_config()
|
||||
|
||||
|
||||
############################
|
||||
# Direct API Config
|
||||
############################
|
||||
|
||||
|
||||
class DirectAPIConfigForm(BaseModel):
|
||||
ENABLE_DIRECT_API: bool
|
||||
|
||||
|
||||
@router.get("/direct_api", response_model=DirectAPIConfigForm)
|
||||
async def get_direct_api_config(request: Request, user=Depends(get_admin_user)):
|
||||
return {
|
||||
"ENABLE_DIRECT_API": request.app.state.config.ENABLE_DIRECT_API,
|
||||
}
|
||||
|
||||
|
||||
@router.post("/direct_api", response_model=DirectAPIConfigForm)
|
||||
async def set_direct_api_config(
|
||||
request: Request, form_data: DirectAPIConfigForm, user=Depends(get_admin_user)
|
||||
):
|
||||
request.app.state.config.ENABLE_DIRECT_API = form_data.ENABLE_DIRECT_API
|
||||
return {
|
||||
"ENABLE_DIRECT_API": request.app.state.config.ENABLE_DIRECT_API,
|
||||
}
|
||||
|
||||
|
||||
############################
|
||||
# CodeInterpreterConfig
|
||||
############################
|
||||
|
||||
Reference in New Issue
Block a user