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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user