diff --git a/backend/open_webui/env.py b/backend/open_webui/env.py index 1dad54568..4ec2e2d8e 100644 --- a/backend/open_webui/env.py +++ b/backend/open_webui/env.py @@ -783,6 +783,17 @@ AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL = ( ) +RAG_EMBEDDING_TIMEOUT = os.environ.get("RAG_EMBEDDING_TIMEOUT", "") + +if RAG_EMBEDDING_TIMEOUT == "": + RAG_EMBEDDING_TIMEOUT = None +else: + try: + RAG_EMBEDDING_TIMEOUT = int(RAG_EMBEDDING_TIMEOUT) + except Exception: + RAG_EMBEDDING_TIMEOUT = None + + #################################### # SENTENCE TRANSFORMERS #################################### diff --git a/backend/open_webui/routers/retrieval.py b/backend/open_webui/routers/retrieval.py index fe0ac652c..0d513c9ae 100644 --- a/backend/open_webui/routers/retrieval.py +++ b/backend/open_webui/routers/retrieval.py @@ -110,6 +110,7 @@ from open_webui.config import ( from open_webui.env import ( DEVICE_TYPE, DOCKER, + RAG_EMBEDDING_TIMEOUT, SENTENCE_TRANSFORMERS_BACKEND, SENTENCE_TRANSFORMERS_MODEL_KWARGS, SENTENCE_TRANSFORMERS_CROSS_ENCODER_BACKEND, @@ -1592,8 +1593,7 @@ def save_docs_to_vector_db( # Run async embedding in sync context using the main event loop # This allows the main loop to stay responsive to health checks during long operations - embedding_timeout_str = os.environ.get("RAG_EMBEDDING_TIMEOUT") - embedding_timeout = int(embedding_timeout_str) if embedding_timeout_str else None + embedding_timeout = RAG_EMBEDDING_TIMEOUT future = asyncio.run_coroutine_threadsafe( embedding_function(