Skip to main content

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 Trajectory objects 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 request
  • steps — cumulative message sequences up to each decision point
  • reward — aggregated reward value and components
  • metrics — step count, token usage, tool call/failure counts
  • execution_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trajectory_sdk-0.1.1.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

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

trajectory_sdk-0.1.1-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

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

Hashes for trajectory_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 37b8df8a14c29cb4092477108c0fd208728914c3c78634c5dc190fb70565067f
MD5 bcf1a776c74bfd88e5c8b1a5bf1503de
BLAKE2b-256 4334299169a28f1fe245010f9b834fa524c76d5300bb205343516064ded2ac18

See more details on using hashes here.

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

Hashes for trajectory_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 32147cbfc8751f7945427abeadffc5e92978db0e14760d8fe4f20d895ee5b648
MD5 11927c18724990bebf9d46c2b9c5f531
BLAKE2b-256 94a7b01748e7a794801b20acac1ced3913378288a1960a2b4c5990e8552db5d7

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