Skip to main content

Track LLM usage across DSPy program runs

Project description

Nanomon

LLM observability for DSPy applications.

What is Nanomon?

Nanomon is an observability platform for LLM applications built with DSPy. It automatically tracks token usage, costs, and tool calls across your DSPy program runs, giving you full visibility into your AI workflows.

Features

  • Automatic LLM token usage tracking
  • Cost calculation and analytics
  • Tool call tracking with the @nanomon decorator
  • DSPy integration (Predict, ReAct, ChainOfThought)
  • Run context management for grouping related calls
  • Multiple storage backends (API, SQLite)

Quick Start

import dspy
from nanomon import NanomonRunContext, configure_nanomon

# 1. Create context and configure tool tracking
context = NanomonRunContext(default_tags=["production"])
configure_nanomon(context._sink)

# 2. Instrument your LM
lm = dspy.LM(model="openai/gpt-4o-mini")
lm = context.instrument_lm(lm)
dspy.configure(lm=lm)

# 3. Track runs - DSPy callbacks are auto-configured
with context.run(tags=["my-task"], metadata={"version": "1.0"}):
    predictor = dspy.Predict(MySignature)
    result = await predictor.acall(input="Hello")
    # Each DSPy module call is automatically tracked as a separate run

Note: Use .acall() for async DSPy module calls to ensure proper callback integration.

Tool Discovery

Nanomon can automatically discover and sync all @nanomon decorated functions in your codebase:

with context.run(discover_tools=True, tags=["my-task"]):
    # Prints discovered tools and syncs them to nanomon API
    result = await predictor.acall(input="Hello")

Output:

🔍 Discovered @nanomon tools:
  - tools.filesystem.read_file
  - tools.filesystem.write_file
  - tools.web.search_web
✓ Synced 3 tools to nanomon

Tool Tracking

Use the @nanomon decorator to track tool calls within your workflows:

from nanomon import nanomon

@nanomon(name="search_web")
def search_web(query: str) -> str:
    """Search the web for information."""
    # Your implementation
    return results

@nanomon(name="read_file")
async def read_file(path: str) -> str:
    """Read a file from disk."""
    # Your implementation
    return content

Tool calls are automatically recorded with timing and success/error status when executed within a context.run() scope.

Links

License

MIT

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

nanomon-0.3.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

nanomon-0.3.0-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file nanomon-0.3.0.tar.gz.

File metadata

  • Download URL: nanomon-0.3.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for nanomon-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e7c1fda182dafd4ffb92a7998e605fc080ccc9b19c6c8988484442bba10497fe
MD5 acfae88249f49629e7b57538784b37fe
BLAKE2b-256 d40a0c7a24226c90e56a0ff2e46f0026791542bf13106a130ab1d41f4b78ec29

See more details on using hashes here.

File details

Details for the file nanomon-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nanomon-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for nanomon-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f703bf219fb8baf1875f96d33b860ba03d1165bcb873955e518162523eb5a7f
MD5 44ee769e1dd05493e100346da267d907
BLAKE2b-256 646fc82572449db01925f50d3aefc21a70f66538ad96e1e55045ef2d7bea0b70

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