Skip to main content

Plott Analytics SDK Core for Python - Event tracking and batching

Project description

Plott SDK Core for Python

The core analytics client for Plott, providing event tracking with batching, retry logic, and async support.

Installation

pip install plott-sdk-core

Quick Start

from plott_analytics import PlottAnalytics

# Initialize the client
client = PlottAnalytics({
    "api_key": "cpk_...",  # or set PLOTT_API_KEY env var
    "environment": "development",
})

# Track events
client.track_message_event(
    role="user",
    content="Hello, world!",
    run_id="run-123",
    session_id="session-456",
)

client.track_message_event(
    role="assistant",
    content="Hi there! How can I help you today?",
    run_id="run-123",
    session_id="session-456",
)

# Flush and shutdown when done
await client.flush()
await client.shutdown()

Event Types

Message Events

Track messages between users and AI assistants:

client.track_message_event(
    role="user",  # or "assistant", "system"
    content="Message content",
    run_id="run-123",
    session_id="session-456",
    token_count=50,  # optional
    model="gpt-4",   # optional
)

Run Events

Track the lifecycle of agent runs:

client.track_run_event(value="start", run_id="run-123")
# ... agent execution ...
client.track_run_event(value="end", run_id="run-123")

Tool Events

Track tool/function calls:

client.track_tool_event(
    tool_call_id="call-123",
    tool_status="started",
    tool_name="search",
    args={"query": "latest news"},
)

client.track_tool_event(
    tool_call_id="call-123",
    tool_status="completed",
    result="Found 10 results...",
)

State Snapshot Events

Track state changes:

client.track_state_snapshot_event(
    snapshot={"messages": [...], "context": {...}},
    run_id="run-123",
)

Error Events

Track errors:

client.track_error_event(
    error={
        "name": "ValidationError",
        "message": "Invalid input",
        "code": "INVALID_INPUT",
    },
    run_id="run-123",
    severity="medium",
)

LLM Call Events

Track LLM API calls with token usage:

client.track_llm_call_event(
    model="gpt-4",
    input_tokens=100,
    output_tokens=50,
    latency_ms=1200,
    provider="openai",
    is_streaming=True,
)

Configuration

client = PlottAnalytics({
    "api_key": "cpk_...",           # Required
    "environment": "production",     # production, staging, development, test
    "retry_attempts": 3,             # Max retry attempts
    "retry_delay": 1.0,              # Initial retry delay (exponential backoff)
    "debug": False,                  # Enable debug logging
})

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

plott_sdk_core-0.0.1a1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

plott_sdk_core-0.0.1a1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file plott_sdk_core-0.0.1a1.tar.gz.

File metadata

  • Download URL: plott_sdk_core-0.0.1a1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.8

File hashes

Hashes for plott_sdk_core-0.0.1a1.tar.gz
Algorithm Hash digest
SHA256 c872174f4552dece010dd5a0d95d1b50233d6544d87a6495ff0b64f48b787f90
MD5 2b4a3aa8572bcc1f7630464405fadbb0
BLAKE2b-256 49bc00f2b869d87ac3b2d6dd30cdb75eada4c27d553f428f78eb7e1d8043e37b

See more details on using hashes here.

File details

Details for the file plott_sdk_core-0.0.1a1-py3-none-any.whl.

File metadata

File hashes

Hashes for plott_sdk_core-0.0.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 99985979f74bb5c4a41c4c577b9d40b1ebc1fef0387e8c69b98556831c374eff
MD5 e3b00dfa199f4fe7e9e219d341eb45fd
BLAKE2b-256 4b2432b13afd75a962b63b80886c8339080a566b3ef9dfd18ff237c914501675

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