fix(archivar): correct Coroutine-Bug root cause — _llm_raw_sync→async _llm_raw, direct await
OllamaLLMClient.generate() is async def — run_in_executor cannot correctly execute async functions. The coroutine was never awaited. Also fix Move-Request parser: native button '1️⃣ Rüber' was not matched against '1️⃣' — fell through to 'stay' instead of 'move'. - classifier.py: _llm_raw_sync → async _llm_raw, await generate() - router.py: remove run_in_executor, direct await _llm_raw() - adapter.py: normalize MOVE_REQ choice (extract leading digit/emoji)
This commit is contained in:
@@ -743,6 +743,11 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
if choice.startswith("MOVE_REQ:") and "::" in choice:
|
if choice.startswith("MOVE_REQ:") and "::" in choice:
|
||||||
_, choice = choice.split("::", 1)
|
_, choice = choice.split("::", 1)
|
||||||
choice = choice.strip()
|
choice = choice.strip()
|
||||||
|
# Normalisiere: "1️⃣ Rüber" → "1️⃣", "2 Hier" → "2"
|
||||||
|
if choice and choice[0] in "123":
|
||||||
|
choice = choice[0]
|
||||||
|
elif choice and choice[:2] in ("1️⃣", "2️⃣", "3️⃣"):
|
||||||
|
choice = choice[:2]
|
||||||
# Altes Format: "1"/"2"/"3" = numerische Antwort
|
# Altes Format: "1"/"2"/"3" = numerische Antwort
|
||||||
# Neues Format: "1️⃣", "2️⃣", "3️⃣" = Emoji-Nummern
|
# Neues Format: "1️⃣", "2️⃣", "3️⃣" = Emoji-Nummern
|
||||||
elif choice in ("1", "2", "3") or choice in ("1️⃣", "2️⃣", "3️⃣"):
|
elif choice in ("1", "2", "3") or choice in ("1️⃣", "2️⃣", "3️⃣"):
|
||||||
|
|||||||
@@ -481,13 +481,15 @@ class IntentClassifier:
|
|||||||
logger.warning("LLM classification failed: %s", e)
|
logger.warning("LLM classification failed: %s", e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _llm_raw_sync(self, prompt: str) -> Optional[str]:
|
async def _llm_raw(self, prompt: str) -> Optional[str]:
|
||||||
"""Send a raw prompt to the LLM and return its response.
|
"""Send a raw prompt to the LLM and return its response.
|
||||||
|
|
||||||
Unlike ``_llm_classify_sync``, this does NOT validate against
|
Unlike ``_llm_classify_sync``, this does NOT validate against
|
||||||
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.
|
||||||
|
|
||||||
|
Async because OllamaLLMClient.generate() is async.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
prompt: The complete prompt to send.
|
prompt: The complete prompt to send.
|
||||||
|
|
||||||
@@ -497,7 +499,7 @@ class IntentClassifier:
|
|||||||
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
|
||||||
return self._llm_client.generate(prompt)
|
return await 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)
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -598,10 +598,7 @@ class BidirectionalRouter:
|
|||||||
# Try LLM — expects room ID directly
|
# Try LLM — expects room ID directly
|
||||||
# Semaphore schützt vor parallelen Ollama-Aufrufen (qwen2.5:7b = single-request)
|
# Semaphore schützt vor parallelen Ollama-Aufrufen (qwen2.5:7b = single-request)
|
||||||
async with self._llm_semaphore:
|
async with self._llm_semaphore:
|
||||||
loop = asyncio.get_running_loop()
|
llm_result = await self._classifier._llm_raw(prompt)
|
||||||
llm_result = await loop.run_in_executor(
|
|
||||||
None, self._classifier._llm_raw_sync, prompt
|
|
||||||
)
|
|
||||||
if llm_result is None:
|
if llm_result is None:
|
||||||
return None, True # LLM-Aufruf fehlgeschlagen
|
return None, True # LLM-Aufruf fehlgeschlagen
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user