Move progress logs into thinking box alongside LLM reasoning
Both __meta (LangGraph/search progress) and __thinking (LLM reasoning) tokens now stream into the thinking box instead of the chatbot. Chatbot shows only the final answer. Thinking box shows the full analysis pipeline: [LangGraph → ...], 문서 검색 중, thinking content. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -105,9 +105,9 @@ async def respond(message, history, show_thinking, user_id, use_tts, run_ids):
|
||||
yield history, "", None, run_ids, gr.update(value="", visible=False)
|
||||
|
||||
collected_run_id: str | None = None
|
||||
tts_text = "" # 순수 답변만 누적 (TTS용)
|
||||
thinking_acc = "" # 사고 과정 누적
|
||||
thinking_active = False
|
||||
tts_text = "" # 순수 답변만 누적 (TTS용)
|
||||
thinking_acc = "" # 사고 과정 + 진행 로그 누적
|
||||
thinking_finalized = False # 첫 답변 토큰 도착 시 박스 완료 처리
|
||||
|
||||
try:
|
||||
async for token, run_id in api_client.chat(message, user_id, show_thinking):
|
||||
@@ -115,26 +115,31 @@ async def respond(message, history, show_thinking, user_id, use_tts, run_ids):
|
||||
collected_run_id = run_id
|
||||
break
|
||||
|
||||
# 사고 과정(LLM thinking) — 박스에 추가
|
||||
if isinstance(token, dict) and "__thinking" in token:
|
||||
thinking_active = True
|
||||
thinking_acc += token["__thinking"]
|
||||
thinking_md = f"🤔 **사고 중...**\n\n{thinking_acc}▌"
|
||||
yield history, "", None, run_ids, gr.update(value=thinking_md, visible=True)
|
||||
yield history, "", None, run_ids, gr.update(
|
||||
value=f"🤔 **분석 중...**\n\n{thinking_acc}▌", visible=True
|
||||
)
|
||||
continue
|
||||
|
||||
if thinking_active:
|
||||
# 첫 답변 토큰 도착 — 사고 완료 표시
|
||||
thinking_active = False
|
||||
# 진행 로그(LangGraph, 검색 등) — 박스에 추가 (챗봇에는 표시 안 함)
|
||||
if isinstance(token, dict) and "__meta" in token:
|
||||
thinking_acc += token["__meta"]
|
||||
yield history, "", None, run_ids, gr.update(
|
||||
value=f"💭 **사고 완료**\n\n{thinking_acc}", visible=True
|
||||
value=f"🤔 **분석 중...**\n\n{thinking_acc}▌", visible=True
|
||||
)
|
||||
continue
|
||||
|
||||
# 첫 답변 토큰 도착 — 박스를 완료 상태로 전환
|
||||
if thinking_acc and not thinking_finalized:
|
||||
thinking_finalized = True
|
||||
yield history, "", None, run_ids, gr.update(
|
||||
value=f"💭 **분석 완료**\n\n{thinking_acc}", visible=True
|
||||
)
|
||||
|
||||
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
|
||||
tts_text += token
|
||||
history[-1]["content"] += token
|
||||
yield history, "", None, run_ids, gr.update()
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user