refac
This commit is contained in:
1 parent
67a7b23b85
commit
396d9ac181
8 files changed
+75
-35
No files matched your search
@@ -118,6 +118,7 @@ from open_webui.storage.provider import Storage
|
||||
from open_webui.utils.access_control import has_permission
|
||||
from open_webui.utils.access_control.files import has_access_to_file
|
||||
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||
from open_webui.utils.errors import error_detail
|
||||
from open_webui.utils.misc import (
|
||||
calculate_sha256_string,
|
||||
sanitize_text_for_db,
|
||||
@@ -182,7 +183,7 @@ def get_rf(
|
||||
|
||||
except Exception as e:
|
||||
log.error(f'ColBERT: {e}')
|
||||
raise Exception(ERROR_MESSAGES.DEFAULT(e))
|
||||
raise Exception(error_detail(e, 'Error loading reranking model'))
|
||||
else:
|
||||
if engine == 'external':
|
||||
try:
|
||||
@@ -196,7 +197,7 @@ def get_rf(
|
||||
)
|
||||
except Exception as e:
|
||||
log.error(f'ExternalReranking: {e}')
|
||||
raise Exception(ERROR_MESSAGES.DEFAULT(e))
|
||||
raise Exception(error_detail(e, 'Error loading reranking model'))
|
||||
else:
|
||||
import sentence_transformers
|
||||
import torch
|
||||
@@ -605,7 +606,7 @@ async def update_embedding_config(request: Request, form_data: EmbeddingModelUpd
|
||||
log.exception(f'Problem updating embedding model: {e}')
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=ERROR_MESSAGES.DEFAULT(e),
|
||||
detail=error_detail(e, 'Error updating embedding configuration'),
|
||||
)
|
||||
|
||||
|
||||
@@ -1207,7 +1208,7 @@ async def update_rag_config(request: Request, form_data: ConfigForm, user=Depend
|
||||
log.exception(f'Problem updating reranking model: {e}')
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=ERROR_MESSAGES.DEFAULT(e),
|
||||
detail=error_detail(e, 'Error updating reranking configuration'),
|
||||
)
|
||||
|
||||
# Chunking settings
|
||||
@@ -2149,7 +2150,7 @@ async def process_web(
|
||||
log.exception(e)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=ERROR_MESSAGES.DEFAULT(e),
|
||||
detail=error_detail(e, 'Error querying knowledge base'),
|
||||
)
|
||||
|
||||
|
||||
@@ -2654,7 +2655,10 @@ async def process_web_search(request: Request, form_data: SearchForm, user=Depen
|
||||
}
|
||||
except Exception as e:
|
||||
log.exception('Web search content loading failed')
|
||||
raise HTTPException(status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.DEFAULT(e))
|
||||
raise HTTPException(
|
||||
status.HTTP_400_BAD_REQUEST,
|
||||
detail=error_detail(e, ERROR_MESSAGES.WEB_SEARCH_ERROR()),
|
||||
)
|
||||
|
||||
|
||||
async def _validate_collection_access(collection_names: list[str], user, access_type: str = 'read') -> None:
|
||||
@@ -2732,7 +2736,7 @@ async def query_doc_handler(
|
||||
log.exception(e)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=ERROR_MESSAGES.DEFAULT(e),
|
||||
detail=error_detail(e, 'Error querying knowledge base'),
|
||||
)
|
||||
|
||||
|
||||
@@ -2798,7 +2802,7 @@ async def query_collection_handler(
|
||||
log.exception(e)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=ERROR_MESSAGES.DEFAULT(e),
|
||||
detail=error_detail(e, 'Error querying knowledge base'),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user