cmpnd
DSPy observability SDK for cmpnd Obsersve.
Automatically trace your DSPy programs with one line of code.
Installation
pip install cmpnd-observe
Quick Start
import cmpnd
# Configure with your API key
cmpnd.configure(api_key="ct_xxx", project="my-project")
# Enable automatic DSPy instrumentation
cmpnd.auto_instrument()
# Your DSPy code is now automatically traced!
import dspy
lm = dspy.LM("openai/gpt-4o-mini")
dspy.configure(lm=lm)
cot = dspy.ChainOfThought("question -> answer")
result = cot(question="What is DSPy?")
# Trace is automatically sent to cmpnd-track
Configuration
Using environment variables
export CMPND_API_KEY="ct_your_api_key"
export CMPND_ENDPOINT="https://observe.cmpnd.ai" # optional
import cmpnd
cmpnd.configure() # Reads from environment
cmpnd.auto_instrument()
Configuration options
cmpnd.configure(
api_key="ct_xxx", # Required: API key
endpoint="https://observe.cmpnd.ai", # Optional: Backend URL
project="my-project", # Optional: Project name
batch_size=100, # Optional: Batch size for export
flush_interval_seconds=5.0, # Optional: Flush interval
capture_inputs=True, # Optional: Capture function inputs
capture_outputs=True, # Optional: Capture function outputs
default_tags={"env": "prod"}, # Optional: Tags for all traces
)
Custom Spans
Add custom spans to trace non-DSPy code:
Using the decorator
from cmpnd import trace, SpanType
@trace(name="fetch_documents", span_type=SpanType.RETRIEVE)
def fetch_documents(query: str) -> list[str]:
# Your retrieval logic
return documents
Using the context manager
from cmpnd import start_span, SpanType
def run_pipeline(query: str):
with start_span("vector_search", span_type=SpanType.RETRIEVE) as span:
span.set_attribute("index", "my-faiss-index")
docs = search(query)
span.set_outputs({"doc_count": len(docs)})
return generate(query, docs)
What Gets Traced
The SDK automatically captures:
Module Execution
- Module type (Predict, ChainOfThought, ReAct, etc.)
- Signature name and instructions
- Input/output field names
- Demo count
LM Calls
- Model name and provider
- Token usage (prompt, completion, total)
- Request/response content
Adapters
- Format and parse operations
- Input/output transformations
Tools
- Tool name and description
- Invocation inputs/outputs
Evaluations
- Evaluation scores
- Program being evaluated
Span Types
Available span types for categorization:
SpanType.MODULE- Generic DSPy moduleSpanType.PREDICT- Predict moduleSpanType.CHAIN_OF_THOUGHT- ChainOfThought moduleSpanType.REACT- ReAct agentSpanType.RETRIEVE- Retrieval operationsSpanType.LM_CALL- Language model callsSpanType.ADAPTER_FORMAT- Adapter formattingSpanType.ADAPTER_PARSE- Adapter parsingSpanType.TOOL- Tool invocationsSpanType.EVALUATION- Evaluation runs
API Reference
cmpnd.configure()
Initialize the SDK with your API key and options.
cmpnd.auto_instrument()
Automatically register the callback with DSPy.
cmpnd.CmpndCallback
The callback class for manual registration:
import dspy
import cmpnd
cmpnd.configure(api_key="ct_xxx")
dspy.configure(callbacks=[cmpnd.CmpndCallback()])
cmpnd.trace()
Decorator for custom traced functions.
cmpnd.start_span()
Context manager for custom spans.
cmpnd.get_current_trace()
Get the current trace (if any).
cmpnd.get_current_span()
Get the current span (if any).
cmpnd.shutdown_exporter()
Gracefully shutdown the background exporter.
License
MIT
Metadata
Release files for cmpnd-observe 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cmpnd_observe-0.0.4.tar.gz | 141.2 kB | Without provenance | Details for cmpnd_observe-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cmpnd_observe-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for cmpnd_observe-0.0.4-py3-none-any.whl |
Total release size: 204.3 kB
Release files / cmpnd_observe-0.0.4.tar.gz
| Download URL | cmpnd_observe-0.0.4.tar.gz |
|---|---|
| Size | 141.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
200ff4cba39edf0e57cf18945bed11c5511e284ed70abf8e32ccf3685b3c9161
|
|
BLAKE2b-256 checksum How to use checksums |
b2d177cac7c7df48fc561779208a5611b48d0d482f1aa6ca512953b0ca7fdf03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Release files / cmpnd_observe-0.0.4-py3-none-any.whl
| Download URL | cmpnd_observe-0.0.4-py3-none-any.whl |
|---|---|
| Size | 63.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8a0a19ab22c01da747a1b51645eb9938f913b9829d5bd3fdae3bfaf7f5ffd94
|
|
BLAKE2b-256 checksum How to use checksums |
44a397813f8c02a0418ab94b363cae755e567ed0dea9465bf224c0d90f5881cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Security for cmpnd-observe 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.