Skip to main content

TrainLoop LLM Logging SDK for data collection

Project description

TrainLoop Evals SDK (Python)

Automatically capture LLM calls from Python apps so they can be graded later.

Install

pip install trainloop-llm-logging

Quick example

from trainloop_llm_logging import collect, trainloop_tag
collect()  # patch HTTP clients
openai.chat.completions.create(..., trainloop_tag("my-tag"))

Set TRAINLOOP_DATA_FOLDER to choose where event files are written or set data_folder in your trainloop.config.yaml file.

Buffering and Flushing

By default, the SDK buffers LLM calls and flushes them every 10 seconds or when 5+ calls are buffered. This is efficient for long-running applications.

Immediate Flushing

For testing or scripts that may exit quickly, use flush_immediately=True:

from trainloop_llm_logging import collect
collect(flush_immediately=True)  # Flush after each LLM call

Manual Flushing

For more control, use the default buffering and flush manually when needed:

from trainloop_llm_logging import collect, flush

collect()  # Default buffering (10s or 5+ calls)
# ... your LLM calls ...
flush()  # Manually flush buffered calls

This is particularly useful for:

  • Testing scenarios where you need immediate data
  • Scripts that may terminate before the buffer flushes
  • Debugging or development workflows

See the project README for more details.

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

trainloop_llm_logging-0.8.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

trainloop_llm_logging-0.8.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file trainloop_llm_logging-0.8.0.tar.gz.

File metadata

  • Download URL: trainloop_llm_logging-0.8.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.13 Linux/6.11.0-1015-azure

File hashes

Hashes for trainloop_llm_logging-0.8.0.tar.gz
Algorithm Hash digest
SHA256 47a574464274f639df9583e63f8b15e708d9964afa98079708dc0bbe250ee9f8
MD5 dce0b1fab61111fd483e94fb237ee310
BLAKE2b-256 c2a848a824d5f2631709a202fc71ab70c0b45db6f09815c847d29bba8abed316

See more details on using hashes here.

File details

Details for the file trainloop_llm_logging-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for trainloop_llm_logging-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f53538dfba6e335b5ba6dfd4b83c176ed9b291d1dc1e847a47ddc47e3a1c68a
MD5 b6e9d65339a62fee816560355e0a1535
BLAKE2b-256 8dd02faed57027c283bcaac7708b128bcc11baf17247730e3a13e4c678359782

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