Skip to main content

AI Agent Observability Platform SDK

Project description

Prela SDK

PyPI version Python Support License Tests

Open-source Python SDK for AI agent observability, testing, and debugging.

Prela provides comprehensive instrumentation, evaluation frameworks, and replay capabilities for AI agents built with OpenAI, Anthropic, LangChain, LlamaIndex, CrewAI, AutoGen, LangGraph, and more.

Features

  • 🔍 Auto-instrumentation - Zero-code observability for 10+ AI frameworks
  • 📊 Evaluation Framework - 17+ assertion types for testing agent behavior
  • 🔄 Replay Engine - Deterministic replay for debugging and testing
  • 📤 Multiple Exporters - Console, file, HTTP, and ClickHouse outputs
  • 🎯 Multi-Agent Support - Track complex agent interactions and delegations
  • 🛠️ CLI Tools - Command-line interface for trace management
  • 🧪 Production Ready - 836+ tests with comprehensive coverage

Installation

pip install prela

With Optional Integrations

# Install specific integrations
pip install prela[openai]       # OpenAI SDK
pip install prela[anthropic]    # Anthropic/Claude SDK
pip install prela[langchain]    # LangChain
pip install prela[llamaindex]   # LlamaIndex

# Install all integrations
pip install prela[all]

# Install with development tools
pip install prela[dev]

# Install with CLI tools
pip install prela[cli]

Quick Start

Basic Usage

import prela

# Initialize with console output
prela.init(service_name="my-agent", exporter="console")

# Your AI agent code here
from openai import OpenAI

client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}]
)

# Prela automatically traces the OpenAI call

Auto-Instrumentation

Prela automatically instruments supported frameworks:

import prela

# One-line initialization
prela.init(service_name="my-app", exporter="console")

# All these frameworks are automatically traced:
# - OpenAI API calls
# - Anthropic/Claude API calls
# - LangChain chains and agents
# - LlamaIndex queries
# - CrewAI tasks
# - AutoGen conversations
# - LangGraph workflows
# - OpenAI Swarm agents

Manual Instrumentation

from prela import trace

@trace
def my_agent_function(user_input: str):
    # Your agent logic here
    return process_input(user_input)

# Or use context managers
from prela import tracer

with tracer.start_span("complex-operation") as span:
    result = do_something()
    span.set_attribute("result_count", len(result))

Evaluation Framework

from prela.evals import EvalRunner, TestCase, Assertion

# Define test cases
test_cases = [
    TestCase(
        name="greeting-test",
        input={"message": "Hello"},
        assertions=[
            Assertion.contains("hello", case_sensitive=False),
            Assertion.max_length(100)
        ]
    )
]

# Run evaluations
runner = EvalRunner()
results = runner.run(my_agent_function, test_cases)
results.print_summary()

Replay Engine

from prela.replay import ReplayEngine

# Load a trace
engine = ReplayEngine()
trace = engine.load_trace("trace_id_123")

# Replay with comparison
replay_result = engine.replay(trace)
comparison = engine.compare(trace, replay_result)

print(f"Similarity: {comparison.similarity_score}")

Supported Frameworks

Framework Auto-Instrumentation Manual Tracing Version Support
OpenAI >=1.0.0
Anthropic >=0.18.0
LangChain >=0.1.0
LlamaIndex >=0.9.0
CrewAI >=0.1.0
AutoGen >=0.2.0
LangGraph >=0.0.20
OpenAI Swarm >=0.1.0
N8N All versions

Exporters

Console Exporter

prela.init(exporter="console")

File Exporter

prela.init(
    exporter="file",
    file_path="traces.jsonl"
)

HTTP Exporter

prela.init(
    exporter="http",
    endpoint="https://api.prela.io",
    api_key="your-api-key"
)

ClickHouse Exporter

prela.init(
    exporter="clickhouse",
    clickhouse_host="localhost",
    clickhouse_port=8123
)

CLI Tools

# List traces
prela list

# Show trace details
prela show <trace-id>

# Show most recent trace
prela last

# Search traces
prela search "error"

# Show failed traces
prela errors

# Interactive explorer
prela explore

Evaluation Assertions

Prela includes 17+ assertion types:

Structural Assertions:

  • contains() - Check for substring
  • regex() - Pattern matching
  • json_schema() - Validate JSON structure
  • length() - Check output length

Semantic Assertions:

  • similarity() - Embedding-based similarity

Tool Assertions:

  • tool_called() - Verify tool usage
  • tool_args() - Validate tool arguments
  • tool_sequence() - Check tool call order

Multi-Agent Assertions:

  • agent_used() - Verify agent participation
  • task_completed() - Check task completion
  • delegation_pattern() - Validate delegation
  • no_circular_delegation() - Prevent cycles
  • collaboration_count() - Track interactions

Advanced Features

Sampling

from prela.core import AlwaysOnSampler, ProbabilitySampler, RateLimitSampler

# Always sample
prela.init(sampler=AlwaysOnSampler())

# Sample 10% of traces
prela.init(sampler=ProbabilitySampler(0.1))

# Sample max 100 traces/second
prela.init(sampler=RateLimitSampler(100))

Context Propagation

from prela import get_current_span

def my_function():
    span = get_current_span()
    span.set_attribute("custom_field", "value")
    span.add_event("checkpoint reached")

Custom Exporters

from prela.exporters import SpanExporter

class MyExporter(SpanExporter):
    def export(self, spans):
        for span in spans:
            # Custom export logic
            pass

prela.init(exporter=MyExporter())

Examples

See the examples/ directory for complete working examples:

Documentation

Full documentation is available at docs.prela.dev

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

# Clone the repository
git clone https://github.com/garrettw2200/prela-sdk.git
cd prela-sdk

# Install development dependencies
pip install -e ".[dev,all]"

# Run tests
pytest

# Run linters
ruff check .
black .
mypy prela

Community

License

Apache License 2.0 - see LICENSE for details.

Acknowledgments

Built with ❤️ by the Prela team and contributors.


Star this repo if you find it useful! ⭐

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

prela-0.1.0.tar.gz (334.8 kB view details)

Uploaded Source

Built Distribution

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

prela-0.1.0-py3-none-any.whl (197.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prela-0.1.0.tar.gz
  • Upload date:
  • Size: 334.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for prela-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dfc3e2b9dc8ff8d796b478165e04d5311d78f4fdcb7bf7b39a17e1cdfafaaafb
MD5 f32fb92d954f0e253d52f4a2dbbdb6cc
BLAKE2b-256 c50ffb8dcffd7067613f07a4942ef31cbec9c813ee9233a69cf4d410aaa4e9d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for prela-0.1.0.tar.gz:

Publisher: publish-pypi.yml on garrettw2200/prela-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: prela-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 197.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for prela-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45ed32a5a0048c32aa5840748fd8d45b384e073f9fd919a8bb6a9952ebcbe5c2
MD5 943a2934aa13c4369610ecb0de77b142
BLAKE2b-256 5007be40cb7f3f21f49629cabedd610fd7a516d9c80a620d084486bddc81331f

See more details on using hashes here.

Provenance

The following attestation bundles were made for prela-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on garrettw2200/prela-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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