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:
-
Dry run / Confirmation mode:
bto-langfuse-cli prompt promote dev uat
This will show a plan of which prompts will be updated (adding the
uatlabel to all prompts that currently have thedevlabel) and ask for confirmation before applying. -
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 betextorchat. If not specified, both types are pulled.
Options:
-o, --output-dir <DIRECTORY>: Directory to save the prompt files to. Defaults todata/prompts.
Output Format (md):
- Text Prompts: Saved as
.mdfiles 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
.mdfiles containing the same YAML frontmatter, followed by the chat messages serialized using XML-like tags (e.g.,<system>,<user>).
Examples:
-
Pull all prompts with a specific label:
bto-langfuse-cli prompt pull production
-
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
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 bto_langfuse_cli-1.0.5.tar.gz.
File metadata
- Download URL: bto_langfuse_cli-1.0.5.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9e0965a099a2907e40c2e5aa17ef702b1af87739caf547c866b932b36f8a642
|
|
| MD5 |
2b6c400ba43df16b0cb9ae96eb411c4c
|
|
| BLAKE2b-256 |
bf2f8542fc7d1c137cbe8933d1365a38b2bfb7b9db55a878011e821b88831b95
|
File details
Details for the file bto_langfuse_cli-1.0.5-py3-none-any.whl.
File metadata
- Download URL: bto_langfuse_cli-1.0.5-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b91c996dd6347bb90b6b5768098230f39e511d9782049c040e078bd6062b314
|
|
| MD5 |
c47090fa12d69e04147c9831e7440c5d
|
|
| BLAKE2b-256 |
622ddc6e19549dfdc11bb16a8feb8544e3206972574d4e9b28273b1ab9026a9e
|