Skip to main content

Developer-facing instrumentation SDK for LLM applications

Project description

Mudipu Python SDK

Instrument, analyze, and optimize your AI agents

Python 3.11+ PyPI version License: MIT

Mudipu is a lightweight Python SDK for tracing, analyzing, and improving LLM-powered applications. Add instrumentation in minutes, detect inefficiencies, and measure context healthโ€”all without sending data to external services.

โœจ Key Features

  • ๐ŸŽฏ Zero-friction instrumentation - Add tracing with simple decorators
  • ๐Ÿ“Š Context health metrics - Detect loops, drift, redundancy, and saturation
  • ๐Ÿ’ฐ Cost tracking - Automatic token usage and cost estimation
  • ๐Ÿ” Rich analysis - CLI tools and programmatic APIs
  • ๐Ÿ”’ Privacy-first - Local-first architecture, no data leaves your machine
  • ๐Ÿ“ค Multiple export formats - JSON, HTML, and more

๐Ÿš€ Quick Start

Installation

# Basic installation
pip install mudipu

# With health metrics support
pip install mudipu[health]

# With all features
pip install mudipu[all]

30-Second Example

from mudipu import trace_session, trace_llm
from openai import OpenAI

client = OpenAI()

@trace_session(name="my-agent")
def run_agent(question: str):
    @trace_llm(model="gpt-4")
    def ask_llm(prompt):
        return client.chat.completions.create(
            model="gpt-4",
            messages=[{"role": "user", "content": prompt}]
        )
    
    response = ask_llm(question)
    return response.choices[0].message.content

# Run and automatically trace
result = run_agent("What is the capital of France?")

# Traces saved to .mudipu/traces/

Analyze with CLI

# View health metrics
mudipu health .mudipu/traces/session_xyz.json

# See statistics
mudipu stats .mudipu/traces/session_xyz.json

# Generate visualization
mudipu health .mudipu/traces/session_xyz.json --visualize

๐Ÿ“Š Context Health Metrics

Mudipu's unique health metrics help detect agent inefficiencies:

Metric What it detects Score Range
Relevance Off-topic context 0.0 - 1.0
Duplicate Ratio Repeated information 0.0 - 1.0
Tool Loops Repeated tool calls 0.0 - 1.0
Drift Goal misalignment 0.0 - 1.0
Novelty Progress tracking 0.0 - 1.0
Overall Health Combined score 0.0 - 1.0

Example output:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Session Health: 0.687 ๐ŸŸก MODERATE                 โ”‚
โ”‚                                                   โ”‚
โ”‚ โ”œโ”€ Context Growth: +58.1 tokens/turn              โ”‚
โ”‚ โ”œโ”€ Drift Score: 0.024 โœ“                           |
โ”‚ โ”œโ”€ Loop Score: 0.333 โš ๏ธ                           โ”‚
โ”‚ โ”œโ”€ Progress: 0.333                                โ”‚
โ”‚ โ””โ”€ Effectiveness: 0.700                           โ”‚
โ”‚                                                   โ”‚
โ”‚ โš ๏ธ  Tool loops detected                           โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐Ÿ‘‰ Learn more about health metrics

๐Ÿ“– Documentation

๐ŸŽฏ Use Cases

  • Debug agent loops - Detect when your agent gets stuck
  • Optimize context - Identify redundant information
  • Track costs - Monitor token usage and expenses
  • Improve quality - Measure goal alignment over time
  • Analyze traces - Understand agent behavior patterns

๐Ÿ› ๏ธ Architecture

Mudipu is designed to be:

  1. Local-first: All data stays on your machine
  2. Lightweight: Minimal performance overhead
  3. Framework-agnostic: Works with any LLM library
  4. Extensible: Add custom metrics and exporters
Your Agent Code
    โ†“
[Mudipu Decorators]
    โ†“
[Trace Capture]
    โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ†“             โ†“          โ†“
Local JSON   HTML    Analysis CLI

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

๐Ÿ“ License

MIT License - see LICENSE for details.

๐Ÿ”— Links

โญ Acknowledgments

Built with:


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

mudipu-1.1.0.tar.gz (55.1 kB view details)

Uploaded Source

Built Distribution

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

mudipu-1.1.0-py3-none-any.whl (50.0 kB view details)

Uploaded Python 3

File details

Details for the file mudipu-1.1.0.tar.gz.

File metadata

  • Download URL: mudipu-1.1.0.tar.gz
  • Upload date:
  • Size: 55.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for mudipu-1.1.0.tar.gz
Algorithm Hash digest
SHA256 c2f30745962ba401a6f7731b64ea4d2fd9cb2965094cd11e9919f5333029174d
MD5 ade48a3302a57a69e88a53181cecc88d
BLAKE2b-256 5a1c600904663f8ffb8c0a445e09489d30931cbec08ff9dd94fc6302dfdfdbc3

See more details on using hashes here.

File details

Details for the file mudipu-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: mudipu-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 50.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for mudipu-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be349fed678ea0ae0fbbd9d193a48e85a9f91edcb2b4ac9096b16552beb02481
MD5 36b0e1c3694add878cefcb6a110edcdf
BLAKE2b-256 0c1124c6d8e5b2f61cee273223ad3f4d62201217ee98a93d38685d145383f6d9

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