This commit is contained in:
Timothy Jaeryang Baek
2025-02-11 23:12:00 -08:00
parent 153413dc54
commit 8daa549146
11 changed files with 306 additions and 40 deletions

View File

@@ -685,13 +685,13 @@ Path(CACHE_DIR).mkdir(parents=True, exist_ok=True)
####################################
# DIRECT API
# DIRECT CONNECTIONS
####################################
ENABLE_DIRECT_API = PersistentConfig(
"ENABLE_DIRECT_API",
ENABLE_DIRECT_CONNECTIONS = PersistentConfig(
"ENABLE_DIRECT_CONNECTIONS",
"direct.enable",
os.environ.get("ENABLE_DIRECT_API", "True").lower() == "true",
os.environ.get("ENABLE_DIRECT_CONNECTIONS", "True").lower() == "true",
)
####################################

View File

@@ -97,8 +97,8 @@ from open_webui.config import (
OPENAI_API_BASE_URLS,
OPENAI_API_KEYS,
OPENAI_API_CONFIGS,
# Direct API
ENABLE_DIRECT_API,
# Direct Connections
ENABLE_DIRECT_CONNECTIONS,
# Code Interpreter
ENABLE_CODE_INTERPRETER,
CODE_INTERPRETER_ENGINE,
@@ -407,11 +407,11 @@ app.state.OPENAI_MODELS = {}
########################################
#
# DIRECT API
# DIRECT CONNECTIONS
#
########################################
app.state.config.ENABLE_DIRECT_API = ENABLE_DIRECT_API
app.state.config.ENABLE_DIRECT_CONNECTIONS = ENABLE_DIRECT_CONNECTIONS
########################################
#
@@ -1056,7 +1056,7 @@ async def get_app_config(request: Request):
"enable_websocket": ENABLE_WEBSOCKET_SUPPORT,
**(
{
"enable_direct_api": app.state.config.ENABLE_DIRECT_API,
"enable_direct_connections": app.state.config.ENABLE_DIRECT_CONNECTIONS,
"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,

View File

@@ -37,28 +37,30 @@ async def export_config(user=Depends(get_admin_user)):
############################
# Direct API Config
# Direct Connections Config
############################
class DirectAPIConfigForm(BaseModel):
ENABLE_DIRECT_API: bool
ENABLE_DIRECT_CONNECTIONS: bool
@router.get("/direct_api", response_model=DirectAPIConfigForm)
async def get_direct_api_config(request: Request, user=Depends(get_admin_user)):
@router.get("/direct_connections", response_model=DirectAPIConfigForm)
async def get_direct_connections_config(request: Request, user=Depends(get_admin_user)):
return {
"ENABLE_DIRECT_API": request.app.state.config.ENABLE_DIRECT_API,
"ENABLE_DIRECT_CONNECTIONS": request.app.state.config.ENABLE_DIRECT_CONNECTIONS,
}
@router.post("/direct_api", response_model=DirectAPIConfigForm)
async def set_direct_api_config(
@router.post("/direct_connections", response_model=DirectAPIConfigForm)
async def set_direct_connections_config(
request: Request, form_data: DirectAPIConfigForm, user=Depends(get_admin_user)
):
request.app.state.config.ENABLE_DIRECT_API = form_data.ENABLE_DIRECT_API
request.app.state.config.ENABLE_DIRECT_CONNECTIONS = (
form_data.ENABLE_DIRECT_CONNECTIONS
)
return {
"ENABLE_DIRECT_API": request.app.state.config.ENABLE_DIRECT_API,
"ENABLE_DIRECT_CONNECTIONS": request.app.state.config.ENABLE_DIRECT_CONNECTIONS,
}