Skip to main content

Trace and explain LangChain agent reasoning step-by-step

Project description

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 and 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/streamlit_viewer.py
  1. Timeline Plot (if added)
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
python-dotenv

License

MIT © Nisaharan Genhatharan

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_reasoning_tracer-0.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_reasoning_tracer-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file llm_reasoning_tracer-0.1.0.tar.gz.

File metadata

  • Download URL: llm_reasoning_tracer-0.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for llm_reasoning_tracer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d7f26ac6896464d51aac022b2ea6be8f20833146769059ff2625147302f6edd1
MD5 904d7b4987906140c31f5f5295d2eac8
BLAKE2b-256 8f188766c57c9551561a2005b28459d65d8f76a1beaa0afdb992771dddc5cf74

See more details on using hashes here.

File details

Details for the file llm_reasoning_tracer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_reasoning_tracer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac40582dbe42d8a615c9b84a8ce8f41c1b78293c24224cd6ad2914185bfd2ea3
MD5 8fb58aff85da792668eaa1835897eb07
BLAKE2b-256 b4ee07184d2371bde0559ada07ded589f316e863ab123adbecc400d6badb8064

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page