Skip to main content

SDK for importing and transforming agent traces into Trajectory format

Project description

trajectory-sdk

Import and transform agent traces from LangSmith (and other providers) into a standardized Trajectory format.

Install

pip install trajectory-sdk

Quick Start

import trajectory_sdk as tj

tj.init(provider="langsmith", api_key="lsv2_pt_...", project_id="...")

# List available conversations
conversations = tj.list_conversations()

# Import and save all conversations
trajectories = tj.import_conversations(conversations)
tj.save(trajectories, "./exports")

API

tj.init(*, provider, api_key, project_id, storage_dir, debug)

Configure the SDK. Call once before other functions.

tj.init(
    provider="langsmith",       # trace provider (default: "langsmith")
    api_key="lsv2_pt_...",      # provider API key
    project_id="...",           # provider project ID
    storage_dir="~/.trajectory", # local staging directory (default)
    debug=False,                 # enable debug logging (default: False)
)

tj.list_conversations(*, limit) -> list[ConversationSummary]

List available conversations from the configured provider.

conversations = tj.list_conversations(limit=100)
for c in conversations:
    print(c.conversation_id, c.num_turns)

tj.import_conversations(conversations, *, stage, redactor) -> list[Trajectory]

Import conversations and return one Trajectory per conversation. Accepts a list of conversation ID strings or ConversationSummary objects.

# By ID
trajectories = tj.import_conversations(["cc_abc123", "cc_def456"])

# By ConversationSummary (from list_conversations)
conversations = tj.list_conversations()
trajectories = tj.import_conversations(conversations)

# With optional PII redaction
trajectories = tj.import_conversations(["cc_abc123"], redactor=my_redactor)

# Without local staging
trajectories = tj.import_conversations(["cc_abc123"], stage=False)

tj.save(trajectories, output_dir)

Save trajectories to JSON files. Each trajectory is written to {output_dir}/{conversation_id}.json.

# Save all
tj.save(trajectories, "./exports")

# Save a single trajectory
tj.save(trajectories[0], "./exports")

tj.transform(raw_data, *, provider, api_key, project_id, redactor) -> Trajectory

Transform raw conversation data without fetching from a provider. For custom pipelines.

trajectory = tj.transform(raw_data, provider="langsmith")

Full Example

import trajectory_sdk as tj

tj.init(provider="langsmith", api_key="lsv2_pt_...", project_id="...")

# List, import, and save everything
conversations = tj.list_conversations(limit=200)
trajectories = tj.import_conversations(conversations)
tj.save(trajectories, "./exports")

print(f"Exported {len(trajectories)} trajectories")
for t in trajectories:
    print(f"  {t.task.conversation_id}: {t.task.num_turns} turns, {len(t.steps)} steps")

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.2.tar.gz (2.1 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.2-py3-none-any.whl (2.0 kB view details)

Uploaded Python 3

File details

Details for the file trajectory_sdk-0.1.2.tar.gz.

File metadata

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

File hashes

Hashes for trajectory_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 34160b91e3be62baf6e7301fa3ab6ad845a6a5722ce2a12b9940054d6ba16f55
MD5 495e9d6bb8eb4e1d7d55e160940213f8
BLAKE2b-256 3bb5b1388f3eb655663579d2c915007f5f0ea79de85b6f3e2d3ca817832ac6d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for trajectory_sdk-0.1.2.tar.gz:

Publisher: publish-sdk.yml on Trajectorylabs/trajectory-platform

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

File details

Details for the file trajectory_sdk-0.1.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for trajectory_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9a54542fbb7c358100c53e3251de263547db3069b968b7e8da5ebce5ed913199
MD5 2d66edb6a81259993c6991c5d16bfbdd
BLAKE2b-256 db54e98d4182f55672c45e291f220d35f4120b21ad6d73e85b58af4f489ea58f

See more details on using hashes here.

Provenance

The following attestation bundles were made for trajectory_sdk-0.1.2-py3-none-any.whl:

Publisher: publish-sdk.yml on Trajectorylabs/trajectory-platform

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