Use the Trajectory SDK to instrument your codebase for continual learning
Project description
Trajectory SDK
Use the Trajectory SDK to instrument your codebase for continual learning.
Installation
pip install trajectory-sdk
Quick Start
import trajectory_sdk as tj
# Initialize with LangSmith credentials
tj.init(provider="langsmith", api_key="lsv2_pt_...", project_id="...")
# List available conversations
conversations = tj.list_conversations()
# Import a single conversation
trajectories = tj.import_conversation("cc_0t9n9qfgH4qayTPXAdg")
# Import multiple conversations
result = tj.import_conversations(["cc_...", "cc_..."])
print(f"Imported: {result.imported}, Failed: {result.failed}")
Features
- Provider-agnostic — pluggable provider system (LangSmith supported, extensible to others)
- Structured output — converts raw traces into typed
Trajectoryobjects with steps, messages, tool calls, and metrics - Deduplication — content hashing and idempotency keys prevent duplicate imports
- Local staging — optional SQLite + gzip storage for offline processing
- PII redaction — pluggable redactor interface for scrubbing sensitive data
Usage
Transform raw data without fetching
trajectories = tj.transform(raw_conversation_dict, provider="langsmith")
Custom PII redaction
from trajectory_sdk import BasePiiRedactor, Trajectory
class MyRedactor(BasePiiRedactor):
def redact(self, trajectory: Trajectory) -> Trajectory:
# your redaction logic
...
def preview(self, trajectories):
# preview what would be redacted
...
trajectories = tj.import_conversation("cc_...", redactor=MyRedactor())
Implement a custom provider
from trajectory_sdk import BaseProvider
class MyProvider(BaseProvider):
def fetch_conversation(self, conversation_id):
...
def parse_conversation(self, raw_data):
...
def list_conversations(self, query=None, limit=50):
...
Output Schema
Each Trajectory contains:
task— the initial user requeststeps— cumulative message sequences up to each decision pointreward— aggregated reward value and componentsmetrics— step count, token usage, tool call/failure countsexecution_metrics— timing (LLM time, env time, total) and termination reason
Messages within steps have a role (system, user, assistant, tool) and may include tool_calls or tool_response objects.
Requirements
- Python 3.11+
langsmith>=0.1.0
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 trajectory_sdk-0.1.1.tar.gz.
File metadata
- Download URL: trajectory_sdk-0.1.1.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37b8df8a14c29cb4092477108c0fd208728914c3c78634c5dc190fb70565067f
|
|
| MD5 |
bcf1a776c74bfd88e5c8b1a5bf1503de
|
|
| BLAKE2b-256 |
4334299169a28f1fe245010f9b834fa524c76d5300bb205343516064ded2ac18
|
File details
Details for the file trajectory_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: trajectory_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 2.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32147cbfc8751f7945427abeadffc5e92978db0e14760d8fe4f20d895ee5b648
|
|
| MD5 |
11927c18724990bebf9d46c2b9c5f531
|
|
| BLAKE2b-256 |
94a7b01748e7a794801b20acac1ced3913378288a1960a2b4c5990e8552db5d7
|