view thinking tokens
Browse files- 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 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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")
|