A Streamlit component to visualize LLM reasoning processes with collapsible thought sections and rich markdown/LaTeX rendering
Project description
Streamlit Reasoning Visualizer
A beautiful, interactive Streamlit component for visualizing LLM reasoning processes with collapsible thought sections and rich markdown/LaTeX rendering.
✨ Features
- 🧠 Collapsible Reasoning Section - Hide/show the model's chain-of-thought with smooth animations
- 📝 Rich Markdown Rendering - Full markdown support including code blocks, tables, and formatting
- 🔢 LaTeX Math Support - Beautiful equation rendering with KaTeX, including
\boxed{}expressions - 🏷️ Multi-format Tag Parsing - Supports various reasoning tag formats used by different LLMs
- 🎨 Modern UI - Clean, minimalist design with smooth animations using Framer Motion
📦 Installation
pip install streamlit-reasoning-visualizer
🚀 Quick Start
import streamlit as st
from reasoning_visualizer import visualizer
st.title("Reasoning Visualizer Demo")
# Sample response with reasoning tags
response = """<think>
Let me work through this step by step.
1. First, I need to understand the problem
2. Then, I'll apply the relevant formula
3. Finally, I'll calculate the result
Using the quadratic formula: $x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}$
</think>
The answer is **42**.
$$\\boxed{x = 42}$$
"""
visualizer(text=response)
🏷️ Supported Reasoning Tag Formats
The component automatically detects and parses these tag formats:
| Format | Example |
|---|---|
<think> |
<think>reasoning...</think> |
[THOUGHT] |
[THOUGHT]reasoning...[/THOUGHT] |
<reasoning> |
<reasoning>reasoning...</reasoning> |
<chain_of_thought> |
<chain_of_thought>reasoning...</chain_of_thought> |
If no tags are found, the entire text is displayed as the final answer.
📖 API Reference
visualizer(text, key=None)
Render the Reasoning Visualizer component.
Parameters:
| Parameter | Type | Description |
|---|---|---|
text |
str |
The raw text containing reasoning tags and the answer |
key |
str, optional |
Unique key for multiple visualizer instances |
Example with multiple visualizers:
visualizer(text=response1, key="viz1")
visualizer(text=response2, key="viz2")
🔧 Development
Prerequisites
- Python 3.8+
- Node.js 16+
- npm
Setup
- Clone the repository:
git clone https://github.com/ketanmahandule/streamlit-reasoning-visualizer.git
cd streamlit-reasoning-visualizer
- Install Python dependencies:
pip install -e ".[dev]"
- Install frontend dependencies:
cd reasoning_visualizer/frontend
npm install
- Start development mode:
In reasoning_visualizer/__init__.py, set _RELEASE = False, then:
# Terminal 1: Start the React dev server
cd reasoning_visualizer/frontend
npm start
# Terminal 2: Run the example app
streamlit run example.py
Building the Frontend
cd reasoning_visualizer/frontend
npm run build
Running Tests
pytest tests/ -v
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
🙏 Acknowledgments
- Built with Streamlit
- Animations powered by Framer Motion
- Math rendering by KaTeX
- Icons from Lucide React
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_reasoning_visualizer-0.1.0.tar.gz.
File metadata
- Download URL: streamlit_reasoning_visualizer-0.1.0.tar.gz
- Upload date:
- Size: 2.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb3c5addcbcf340ed6e9b59403f8f7cf4e946bc47a23f024b714089dd3bd7c32
|
|
| MD5 |
4d32cf33cf4358305b3eb8f2b6762ffe
|
|
| BLAKE2b-256 |
9aee06a779aebcd06565533951a96aeb794817a2a41a23d484b347a0862b0387
|
File details
Details for the file streamlit_reasoning_visualizer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: streamlit_reasoning_visualizer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b2bff885892c8aa54fad39d41b311046cbf949bfb2c16e877365800c5fb3901
|
|
| MD5 |
fd9ba7e6e9b70b6a5f700165b66212f7
|
|
| BLAKE2b-256 |
b6a2084f906ab277c9f3c9f978bb9663c1a155c29d8aa40c96345ed15a80c713
|