From 6c00e8b4fd08cd54d21c5100c45501adf0cfec6f Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Wed, 22 Apr 2026 00:57:54 -0400 Subject: [PATCH] fix: raise Ollama timeout from 20s to 60s for all game generators phi4-mini can queue behind other requests and take >20s under load, causing TimeoutError and silent failures in wyr/riddle/hangman/scramble. Co-Authored-By: Claude Sonnet 4.6 --- matrixbot/commands.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/matrixbot/commands.py b/matrixbot/commands.py index 49410ee..a548e2a 100644 --- a/matrixbot/commands.py +++ b/matrixbot/commands.py @@ -937,7 +937,7 @@ async def _generate_trivia_question(category: str) -> dict | None: "The question should be clear, factual, and have exactly one correct answer." ) try: - timeout = aiohttp.ClientTimeout(total=20) + timeout = aiohttp.ClientTimeout(total=60) async with aiohttp.ClientSession(timeout=timeout) as session: async with session.post( f"{OLLAMA_URL}/api/chat", @@ -1237,7 +1237,7 @@ async def _generate_hangman_word() -> dict | None: ) user_msg = "Pick a common English word between 5 and 8 letters (lowercase letters only, no hyphens or spaces) and give a short hint." try: - timeout = aiohttp.ClientTimeout(total=20) + timeout = aiohttp.ClientTimeout(total=60) async with aiohttp.ClientSession(timeout=timeout) as session: async with session.post( f"{OLLAMA_URL}/api/chat", @@ -1444,7 +1444,7 @@ async def _generate_scramble_word() -> dict | None: ) user_msg = "Pick a common English word between 4 and 8 letters (lowercase letters only, no hyphens or spaces)." try: - timeout = aiohttp.ClientTimeout(total=20) + timeout = aiohttp.ClientTimeout(total=60) async with aiohttp.ClientSession(timeout=timeout) as session: async with session.post( f"{OLLAMA_URL}/api/chat", @@ -1566,7 +1566,7 @@ async def _generate_wyr() -> dict | None: ) user_msg = "Generate a fun, creative Would You Rather question. Keep each option under 10 words." try: - timeout = aiohttp.ClientTimeout(total=20) + timeout = aiohttp.ClientTimeout(total=60) async with aiohttp.ClientSession(timeout=timeout) as session: async with session.post( f"{OLLAMA_URL}/api/chat", @@ -1664,7 +1664,7 @@ async def _generate_riddle() -> dict | None: ) user_msg = "Generate a clever riddle. The answer should be 1-4 words." try: - timeout = aiohttp.ClientTimeout(total=20) + timeout = aiohttp.ClientTimeout(total=60) async with aiohttp.ClientSession(timeout=timeout) as session: async with session.post( f"{OLLAMA_URL}/api/chat", @@ -1876,7 +1876,7 @@ async def _generate_story_opener() -> str | None: "Just the opening sentence, no explanation or title." ) try: - timeout = aiohttp.ClientTimeout(total=20) + timeout = aiohttp.ClientTimeout(total=60) async with aiohttp.ClientSession(timeout=timeout) as session: async with session.post( f"{OLLAMA_URL}/api/generate",