From 454a386612d2a6d53e7b5f053ab2a7234d4db6b9 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 14 Jun 2024 00:10:52 -0700 Subject: [PATCH] refac --- TROUBLESHOOTING.md | 2 +- backend/apps/ollama/main.py | 6 ++++-- backend/config.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md index d1a6dba28..a126eafbc 100644 --- a/TROUBLESHOOTING.md +++ b/TROUBLESHOOTING.md @@ -20,7 +20,7 @@ docker run -d --network=host -v open-webui:/app/backend/data -e OLLAMA_BASE_URL= ### Error on Slow Reponses for Ollama -Open WebUI has a default timeout of 15 minutes for Ollama to finish generating the response. If needed, this can be adjusted via the environment variable OLLAMA_GENERATE_TIMEOUT, which sets the timeout in seconds. +Open WebUI has a default timeout of 15 minutes for Ollama to finish generating the response. If needed, this can be adjusted via the environment variable AIOHTTP_CLIENT_TIMEOUT, which sets the timeout in seconds. ### General Connection Errors diff --git a/backend/apps/ollama/main.py b/backend/apps/ollama/main.py index f9a906986..9a60146c2 100644 --- a/backend/apps/ollama/main.py +++ b/backend/apps/ollama/main.py @@ -46,7 +46,7 @@ from config import ( SRC_LOG_LEVELS, OLLAMA_BASE_URLS, ENABLE_OLLAMA_API, - OLLAMA_GENERATE_TIMEOUT, + AIOHTTP_CLIENT_TIMEOUT, ENABLE_MODEL_FILTER, MODEL_FILTER_LIST, UPLOAD_DIR, @@ -155,7 +155,9 @@ async def cleanup_response( async def post_streaming_url(url: str, payload: str): r = None try: - session = aiohttp.ClientSession(trust_env=True, timeout=aiohttp.ClientTimeout(total=OLLAMA_GENERATE_TIMEOUT)) + session = aiohttp.ClientSession( + trust_env=True, timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT) + ) r = await session.post(url, data=payload) r.raise_for_status() diff --git a/backend/config.py b/backend/config.py index 995a48a01..215c6f849 100644 --- a/backend/config.py +++ b/backend/config.py @@ -425,7 +425,7 @@ OLLAMA_API_BASE_URL = os.environ.get( ) OLLAMA_BASE_URL = os.environ.get("OLLAMA_BASE_URL", "") -OLLAMA_GENERATE_TIMEOUT = int(os.environ.get("OLLAMA_GENERATE_TIMEOUT", "900")) +AIOHTTP_CLIENT_TIMEOUT = int(os.environ.get("AIOHTTP_CLIENT_TIMEOUT", "900")) K8S_FLAG = os.environ.get("K8S_FLAG", "") USE_OLLAMA_DOCKER = os.environ.get("USE_OLLAMA_DOCKER", "false")