Skip to main content

A set of CLI tools to interact with Langfuse, especially for prompt management.

Project description

bto-langfuse-cli

A set of CLI tools to interact with Langfuse, especially for prompt management.

Installation

This project uses uv. You can install the project and its dependencies by running:

uv sync

Or you can install it using pip if you have the package:

pip install .

The CLI command is named bto-langfuse-cli.

Configuration

The CLI uses environment variables for authentication with your Langfuse instance. You can create a .env file in the root directory or set these variables in your shell.

.env Setup

Create a .env file with the following content:

LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_HOST=https://cloud.langfuse.com # Or your self-hosted URL

The CLI uses the standard langfuse Python SDK get_client() method, which automatically reads these environment variables.

Usage

Prompts Management

The prompt command group allows you to manage Langfuse prompts.

Promote Labels

The promote command allows you to copy a label from one version of all prompts to another. This is useful for moving prompts through different environments (e.g., from dev to uat).

Command:

bto-langfuse-cli prompt promote <src_label> <target_label> [--apply]

Options:

  • --apply: Automatically apply the promotion without asking for confirmation.

Examples:

  1. Dry run / Confirmation mode:

    bto-langfuse-cli prompt promote dev uat
    

    This will show a plan of which prompts will be updated (adding the uat label to all prompts that currently have the dev label) and ask for confirmation before applying.

  2. Auto-apply mode:

    bto-langfuse-cli prompt promote dev uat --apply
    

    This will automatically update the labels for all prompts matching the source label.

Pull Prompts

The pull command downloads prompts from Langfuse to your local filesystem based on a specific label.

Command:

bto-langfuse-cli prompt pull <label> [type] [OPTIONS]

Arguments:

  • <label>: The label to pull prompts from (e.g., production, dev). (Required)
  • [type]: The type of prompt to pull. Can be text or chat. If not specified, both types are pulled.

Options:

  • -o, --output-dir <DIRECTORY>: Directory to save the prompt files to. Defaults to data/prompts.

Output Format (md):

  • Text Prompts: Saved as .md files containing a YAML frontmatter (with metadata like name, version, tags, labels, and last updated date) followed by the raw text prompt.
  • Chat Prompts: Saved as .md files containing the same YAML frontmatter, followed by the chat messages serialized using XML-like tags (e.g., <system>, <user>).

Examples:

  1. Pull all prompts with a specific label:

    bto-langfuse-cli prompt pull production
    
  2. Pull only chat prompts to a custom directory:

    bto-langfuse-cli prompt pull dev chat -o ./my-local-prompts
    

Development

To run the CLI during development:

uv run bto-langfuse-cli --help

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

bto_langfuse_cli-1.0.4.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

bto_langfuse_cli-1.0.4-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file bto_langfuse_cli-1.0.4.tar.gz.

File metadata

  • Download URL: bto_langfuse_cli-1.0.4.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bto_langfuse_cli-1.0.4.tar.gz
Algorithm Hash digest
SHA256 417a0a55a4c547c01c1e9aa63349cefa070e38b0832bb61cef595a2ae0d64479
MD5 65eab131688a024d57ddb98d31af395a
BLAKE2b-256 7e02f7dbac8c9108cbb711733c35229c352322c6cc9d53c39faad4f1ce23eacc

See more details on using hashes here.

File details

Details for the file bto_langfuse_cli-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: bto_langfuse_cli-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bto_langfuse_cli-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 25a7442a2d0851e188e674e0a2973f499689a222fcd216429cf24b00dae2943a
MD5 797b87432adc86e578c07ad802de517c
BLAKE2b-256 05ce0f4cd93ce92390f9cba9ba4967283ef9f7bacd91c015311719f670ab7819

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