mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 03:47:49 +01:00
💄 Limit the size and number of uploaded files
💄 Limit the size and number of uploaded files
This commit is contained in:
@@ -95,6 +95,8 @@ from config import (
|
||||
TIKA_SERVER_URL,
|
||||
RAG_TOP_K,
|
||||
RAG_RELEVANCE_THRESHOLD,
|
||||
RAG_MAX_FILE_SIZE,
|
||||
RAG_MAX_FILE_COUNT,
|
||||
RAG_EMBEDDING_ENGINE,
|
||||
RAG_EMBEDDING_MODEL,
|
||||
RAG_EMBEDDING_MODEL_AUTO_UPDATE,
|
||||
@@ -143,6 +145,8 @@ app.state.config = AppConfig()
|
||||
|
||||
app.state.config.TOP_K = RAG_TOP_K
|
||||
app.state.config.RELEVANCE_THRESHOLD = RAG_RELEVANCE_THRESHOLD
|
||||
app.state.config.MAX_FILE_SIZE = RAG_MAX_FILE_SIZE
|
||||
app.state.config.MAX_FILE_COUNT = RAG_MAX_FILE_COUNT
|
||||
|
||||
app.state.config.ENABLE_RAG_HYBRID_SEARCH = ENABLE_RAG_HYBRID_SEARCH
|
||||
app.state.config.ENABLE_RAG_WEB_LOADER_SSL_VERIFICATION = (
|
||||
@@ -567,6 +571,8 @@ async def get_query_settings(user=Depends(get_admin_user)):
|
||||
"template": app.state.config.RAG_TEMPLATE,
|
||||
"k": app.state.config.TOP_K,
|
||||
"r": app.state.config.RELEVANCE_THRESHOLD,
|
||||
"max_file_size": app.state.config.MAX_FILE_SIZE,
|
||||
"max_file_count": app.state.config.MAX_FILE_COUNT,
|
||||
"hybrid": app.state.config.ENABLE_RAG_HYBRID_SEARCH,
|
||||
}
|
||||
|
||||
@@ -574,6 +580,8 @@ async def get_query_settings(user=Depends(get_admin_user)):
|
||||
class QuerySettingsForm(BaseModel):
|
||||
k: Optional[int] = None
|
||||
r: Optional[float] = None
|
||||
max_file_size: Optional[int] = None
|
||||
max_file_count: Optional[int] = None
|
||||
template: Optional[str] = None
|
||||
hybrid: Optional[bool] = None
|
||||
|
||||
@@ -590,11 +598,20 @@ async def update_query_settings(
|
||||
app.state.config.ENABLE_RAG_HYBRID_SEARCH = (
|
||||
form_data.hybrid if form_data.hybrid else False
|
||||
)
|
||||
app.state.config.MAX_FILE_SIZE = (
|
||||
form_data.max_file_size if form_data.max_file_size else 10
|
||||
)
|
||||
app.state.config.MAX_FILE_COUNT = (
|
||||
form_data.max_file_count if form_data.max_file_count else 5
|
||||
)
|
||||
|
||||
return {
|
||||
"status": True,
|
||||
"template": app.state.config.RAG_TEMPLATE,
|
||||
"k": app.state.config.TOP_K,
|
||||
"r": app.state.config.RELEVANCE_THRESHOLD,
|
||||
"max_file_size": app.state.config.MAX_FILE_SIZE,
|
||||
"max_file_count": app.state.config.MAX_FILE_COUNT,
|
||||
"hybrid": app.state.config.ENABLE_RAG_HYBRID_SEARCH,
|
||||
}
|
||||
|
||||
|
||||
@@ -1005,6 +1005,18 @@ ENABLE_RAG_HYBRID_SEARCH = PersistentConfig(
|
||||
os.environ.get("ENABLE_RAG_HYBRID_SEARCH", "").lower() == "true",
|
||||
)
|
||||
|
||||
RAG_MAX_FILE_COUNT = PersistentConfig(
|
||||
"RAG_MAX_FILE_COUNT",
|
||||
"rag.max_file_count",
|
||||
int(os.environ.get("RAG_MAX_FILE_COUNT", "5")),
|
||||
)
|
||||
|
||||
RAG_MAX_FILE_SIZE = PersistentConfig(
|
||||
"RAG_MAX_FILE_SIZE",
|
||||
"rag.max_file_size",
|
||||
int(os.environ.get("RAG_MAX_FILE_SIZE", "10")),
|
||||
)
|
||||
|
||||
ENABLE_RAG_WEB_LOADER_SSL_VERIFICATION = PersistentConfig(
|
||||
"ENABLE_RAG_WEB_LOADER_SSL_VERIFICATION",
|
||||
"rag.enable_web_loader_ssl_verification",
|
||||
|
||||
Reference in New Issue
Block a user