fix: extract content from ASR JSON before sending to Antaf
ASR wraps user speech as JSON {"content":"...", "language":"zh", "emotion":"..."},
extract only the content field instead of sending raw JSON to Antaf bridge.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cb9d430cfc
commit
12b4994ac0
|
|
@ -1,3 +1,4 @@
|
||||||
|
import json
|
||||||
import requests
|
import requests
|
||||||
from config.logger import setup_logging
|
from config.logger import setup_logging
|
||||||
from core.providers.llm.base import LLMProviderBase
|
from core.providers.llm.base import LLMProviderBase
|
||||||
|
|
@ -61,7 +62,15 @@ class LLMProvider(LLMProviderBase):
|
||||||
if msg.get("role") == "user":
|
if msg.get("role") == "user":
|
||||||
content = msg.get("content", "")
|
content = msg.get("content", "")
|
||||||
if not self._is_system_injected(content):
|
if not self._is_system_injected(content):
|
||||||
query = content
|
# ASR 结果可能是 JSON: {"content":"...", "language":"zh", "emotion":"..."}
|
||||||
|
try:
|
||||||
|
parsed = json.loads(content)
|
||||||
|
if isinstance(parsed, dict) and "content" in parsed:
|
||||||
|
query = parsed["content"]
|
||||||
|
else:
|
||||||
|
query = content
|
||||||
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
query = content
|
||||||
break
|
break
|
||||||
|
|
||||||
if not query:
|
if not query:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue