Plott Analytics SDK for LangGraph - Automatic analytics tracking for LangGraph
Project description
Plott SDK for LangGraph
Automatic analytics tracking for LangGraph applications. Just wrap your graph and analytics are collected transparently.
Installation
pip install plott-sdk-langgraph
Quick Start
from langgraph.graph import StateGraph
from langchain_core.messages import HumanMessage
from plott_langgraph import PlottTrackedGraph
# Create your graph normally
workflow = StateGraph(AgentState)
workflow.add_node("chat", chat_node)
workflow.add_node("tools", tool_node)
workflow.add_edge("chat", "tools")
# ... add more nodes and edges
graph = workflow.compile(checkpointer=memory)
# Wrap with Plott - that's it!
tracked_graph = PlottTrackedGraph(graph, {
"api_key": "cpk_...", # or set PLOTT_API_KEY env var
"environment": "development",
})
# Use exactly like the original graph - analytics are automatic
async for event in tracked_graph.astream_events(
{"messages": [HumanMessage(content="Hello!")]},
config={"configurable": {"thread_id": "123", "run_id": "run-456"}},
):
# Your normal event handling
if event["event"] == "on_chat_model_stream":
print(event["data"]["chunk"].content, end="", flush=True)
What Gets Tracked
The SDK automatically tracks:
| Event | Description |
|---|---|
| Messages | User input and assistant responses |
| Tool Calls | Tool executions with arguments and results |
| State Snapshots | State changes as the graph executes |
| Run Lifecycle | Start and end of each graph run |
| Errors | Any errors that occur during execution |
How It Works
The SDK wraps your compiled LangGraph graph and intercepts astream_events():
- Zero code changes - Your graph logic stays exactly the same
- Non-blocking - Analytics are tracked in the background
- Error-isolated - Analytics errors never affect your graph execution
- Transparent - Events pass through unchanged
Your Code → TrackedGraph → Original Graph
↓
EventTracker → PlottAnalytics → API
Configuration
tracked_graph = PlottTrackedGraph(graph, {
"api_key": "cpk_...", # Required (or PLOTT_API_KEY env var)
"base_url": "https://...", # Default: https://api.askwise.com
"environment": "production", # production, staging, development, test
"batch_size": 10, # Events per batch
"flush_interval": 1.0, # Seconds between auto-flushes
"debug": False, # Enable debug logging
})
Environment Variables
PLOTT_API_KEY- API key (if not provided in config)ASKWISE_API_PATH- Custom API base URL
Graceful Shutdown
To ensure all events are flushed before your application exits:
# When done
await tracked_graph.shutdown()
Using with Other Methods
The tracked graph proxies all methods to the original graph:
# These work exactly as before
result = await tracked_graph.ainvoke(input)
async for chunk in tracked_graph.astream(input):
...
# Get state
state = await tracked_graph.aget_state(config)
Only astream_events() has analytics tracking. Other methods pass through directly.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plott_sdk_langgraph-0.0.1a0.tar.gz.
File metadata
- Download URL: plott_sdk_langgraph-0.0.1a0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef8f0563eedceb91fef35ff0a95ebd7fb05faa5aba5eced89db5146dd040a554
|
|
| MD5 |
f41a2208a70893f4dc84acc483b41648
|
|
| BLAKE2b-256 |
5c002a7a2faee1789b49a03cebf5cc10780ed4b7343145a3d172f9c6a7f92970
|
File details
Details for the file plott_sdk_langgraph-0.0.1a0-py3-none-any.whl.
File metadata
- Download URL: plott_sdk_langgraph-0.0.1a0-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8607e442bd5f179e9d2946839d28a7461b3af22e95cb3eec5dee05a47779a4c1
|
|
| MD5 |
3206755fb6ac1b5602f5d738152f6576
|
|
| BLAKE2b-256 |
7f7daf91949025825957cc8da80c38783342623716778c36c826bfe81ca924a3
|