Compare commits

..

2 Commits

Author SHA1 Message Date
shinalok 6435af5837 Separate TTS text from metadata tokens in respond()
Filter __meta dict tokens from TTS accumulator so progress messages
([LangGraph], thinking blocks, source references) are displayed in chat
but not read aloud. Answer tokens continue to accumulate in tts_text.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 23:08:22 +09:00
shinalok 7fa45afc7f Fix TTS to use pure response content without meta tokens 2026-05-31 23:05:28 +09:00
2 changed files with 9 additions and 2 deletions
+1
View File
@@ -0,0 +1 @@
/.env
+8 -2
View File
@@ -105,12 +105,18 @@ async def respond(message, history, show_thinking, user_id, use_tts, run_ids):
yield history, "", None, run_ids
collected_run_id: str | None = None
tts_text = "" # 순수 답변만 누적 (메타 토큰 제외)
try:
async for token, run_id in api_client.chat(message, user_id, show_thinking):
if run_id is not None:
collected_run_id = run_id
break
history[-1]["content"] += token
if isinstance(token, dict) and "__meta" in token:
display_token = token["__meta"]
else:
display_token = token
tts_text += display_token
history[-1]["content"] += display_token
yield history, "", None, run_ids
except Exception as e:
history[-1]["content"] += f"\n\n[오류: {e}]"
@@ -120,7 +126,7 @@ async def respond(message, history, show_thinking, user_id, use_tts, run_ids):
run_ids.append(collected_run_id)
if use_tts:
audio_path = await tts_speak(history[-1]["content"])
audio_path = await tts_speak(tts_text)
yield history, "", audio_path, run_ids
else:
yield history, "", None, run_ids