From 6435af58370e23a04766fd9aa54caf2148467382 Mon Sep 17 00:00:00 2001 From: sal Date: Sun, 31 May 2026 23:08:22 +0900 Subject: [PATCH] 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 --- app.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index a2fd99b..b9c4b85 100644 --- a/app.py +++ b/app.py @@ -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