deven367 commited on
Commit
c87a3c3
·
1 Parent(s): 1281a24

view thinking tokens

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +17 -2
src/streamlit_app.py CHANGED
@@ -47,11 +47,26 @@ def display_message(msg):
47
  with st.chat_message("assistant"):
48
  # Remove <think> tags if present
49
  content = msg['content']
 
 
50
  if '<think>' in content and '</think>' in content:
51
  start = content.find('<think>')
52
  end = content.find('</think>') + len('</think>')
53
- content = content[:start] + content[end:]
54
- st.markdown(content)
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  def main():
57
  st.title("💬 Conversation Viewer")
 
47
  with st.chat_message("assistant"):
48
  # Remove <think> tags if present
49
  content = msg['content']
50
+
51
+ # Handle <think> tags if present
52
  if '<think>' in content and '</think>' in content:
53
  start = content.find('<think>')
54
  end = content.find('</think>') + len('</think>')
55
+
56
+ # Extract thinking content and response content
57
+ thinking_content = content[start + len('<think>'):content.find('</think>')]
58
+ response_content = content[end:].strip()
59
+
60
+ # Display thinking content in a collapsed expander
61
+ with st.expander("🧠 Internal Thinking", expanded=False):
62
+ st.code(thinking_content.strip(), language="text", wrap_lines=True)
63
+
64
+ # Display the actual response
65
+ if response_content:
66
+ st.markdown(response_content)
67
+ else:
68
+ # No thinking tags, display content normally
69
+ st.markdown(content)
70
 
71
  def main():
72
  st.title("💬 Conversation Viewer")