fix(classifier): wrap sync generate() in asyncio.to_thread() — remove broken await on non-coroutine

This commit is contained in:
Bernd (Hermes)
2026-06-19 19:53:59 +02:00
parent ac1751e9ce
commit 2599a574e1
+2 -3
View File
@@ -488,8 +488,7 @@ class IntentClassifier:
Intent-Kategorien. Uses ``LLMClient.generate()`` for free-form Intent-Kategorien. Uses ``LLMClient.generate()`` for free-form
output. Used by the router for LLM_ROOM_PROMPT. output. Used by the router for LLM_ROOM_PROMPT.
Uses ``asyncio.to_thread()`` because ``LLMClient.generate()`` is Wraps synchronous OllamaLLMClient.generate() in asyncio.to_thread().
synchronous.
Args: Args:
prompt: The complete prompt to send. prompt: The complete prompt to send.
@@ -497,10 +496,10 @@ class IntentClassifier:
Returns: Returns:
The LLM's response text (stripped), or None on failure. The LLM's response text (stripped), or None on failure.
""" """
import asyncio
try: try:
if not self._llm_client or not self._llm_enabled: if not self._llm_client or not self._llm_enabled:
return None return None
import asyncio
return await asyncio.to_thread(self._llm_client.generate, prompt) return await asyncio.to_thread(self._llm_client.generate, prompt)
except Exception as e: except Exception as e:
logger.warning("LLM raw call failed: %s", e) logger.warning("LLM raw call failed: %s", e)