Added timeout setting for ollama streaming response

This commit is contained in:
Mikael Turøy
2024-06-12 22:37:35 +02:00
parent bdd2ac0015
commit e130ad74d1
3 changed files with 7 additions and 1 deletions

View File

@@ -46,6 +46,7 @@ from config import (
SRC_LOG_LEVELS,
OLLAMA_BASE_URLS,
ENABLE_OLLAMA_API,
OLLAMA_GENERATE_TIMEOUT,
ENABLE_MODEL_FILTER,
MODEL_FILTER_LIST,
UPLOAD_DIR,
@@ -154,7 +155,7 @@ async def cleanup_response(
async def post_streaming_url(url: str, payload: str):
r = None
try:
session = aiohttp.ClientSession(trust_env=True)
session = aiohttp.ClientSession(trust_env=True, timeout=aiohttp.ClientTimeout(total=OLLAMA_GENERATE_TIMEOUT))
r = await session.post(url, data=payload)
r.raise_for_status()