Skip to content

nisaharan/llm_reasoning_tracer

Repository files navigation

Directory Structure:

llm_reasoning_tracer/

├── cognitive_tracer/

│ ├── init.py

│ └── tracer.py

├── examples/

│ ├── use_with_langchain_agent.py

│ ├── multi_agent_chain_example.py

│ ├── rag_pipeline_example.py

│ ├── streamlit_viewer.py

│ ├── math_chain_example.py

│ └── create_db.py

├── traces/

│ ├── trace_math.json

│ ├── trace_simple.json

│ ├── trace_multi.json

│ └── trace_rag.json

├── data/

│ └── solar_energy_notes.txt

├── README.md

├── LICENSE

├── setup.py

├── pyproject.toml

├── MANIFEST.in

├── requirements.txt

README.md

"""

LLM Reasoning Tracer

A modular tracing and explainability toolkit for LangChain agents. Capture step-by-step tool usage, visualize the reasoning process, and analyze how your agent chains behave.

🚀 Features

  • 🔍 Traces agent steps (inputs, tool used, outputs)
  • 📊 Visualizes tool usage and outcomes
  • 🧪 Includes dashboards for Streamlit + Matplotlib
  • 🧠 Supports RAG, search chains, math pipelines, and multi-tool agents

🧱 Installation

pip install .

🔐 Setup

Create a .env file:

OPENAI_API_KEY=your-key-here

📂 Trace Examples

Run one of the provided pipelines:

python examples/use_with_langchain_agent.py
python examples/math_chain_example.py
python examples/multi_agent_chain_example.py
python examples/rag_pipeline_example.py

🧠 Create RAG DB

python examples/create_db.py

It loads data/solar_energy_notes.txt and builds db/ for retrieval.

📺 View Your Trace

1. Streamlit Dashboard

streamlit run examples/trace_dashboard.py

2. Timeline Plot

python examples/visualize_trace.py

📝 Output Example (trace_math.json)

{
  "step_1": {
    "input": "What's 15% tip for $80 dinner, and add it to the bill?",
    "tool_used": "Tip Calculator",
    "output": "Tip is $12.0"
  },
  "step_2": {
    "input": "Add 80 + 12.0",
    "tool_used": "Total Calculator",
    "output": "The total bill including tip is $92.0"
  }
}

📦 Structure

  • cognitive_tracer/ — the Python module
  • examples/ — usage scripts
  • traces/ — generated trace files
  • data/ — text input for vector DB

📌 Dependencies

langchain
langchain-openai
langchain-community
openai
streamlit
matplotlib
dotenv

📄 License

MIT © Nisaharan Genhatharan """

About

LLM Reasoning Tracer is a diagnostic framework designed to trace, visualize, and evaluate the reasoning paths of LLMs during complex problem-solving tasks. It supports multiple prompting strategies—such as CoT, Self-Ask, and Tree-of-Thought—and captures intermediate decision steps to promote deeper understanding of model behavior.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors