Langfuse Freeze
Project description
langfuse-freeze
Wraps the Langfuse client to snapshot prompts to disk at startup. If Langfuse is unreachable at runtime, the local backup is used as fallback.
How it works
On import langfuse_freeze, LangfuseBacked.bootstrap() runs automatically:
- Backup file already exists → skip (log and continue)
- Backup file missing → fetch all prompts from Langfuse, write to disk
- Fetch fails → retry with exponential backoff, raise
RuntimeErrorafter max retries
At runtime, LangfuseBacked.get_prompt() injects the backup as fallback so Langfuse SDK handles outages gracefully.
Installation
uv add langfuse-freeze
Usage
from langfuse_freeze.main import LangfuseBacked
client = LangfuseBacked()
prompt = client.get_prompt("my-prompt", type="text", label="production")
Drop-in replacement for Langfuse. Same API.
Bootstrap at container build time
Run before the app starts (e.g. in a Dockerfile or k8s init container):
langfuse-freeze-bootstrap
Same logic as import-time bootstrap — skips if backup already present.
Configuration
| Env var | Default | Description |
|---|---|---|
LANGFUSE_PUBLIC_KEY |
— | Required |
LANGFUSE_SECRET_KEY |
— | Required |
LANGFUSE_HOST |
— | Required |
LANGFUSE_PROMPTS_BACKUP_PATH |
./langfuse-backup/prompts.json |
Backup file location |
LANGFUSE_BOOTSTRAP_MAX_RETRIES |
3 |
Fetch attempts before crash |
LANGFUSE_BOOTSTRAP_RETRY_DELAY |
2 |
Base seconds for exponential backoff |
LANGFUSE_DISABLE_BOOTSTRAP |
— | Set to 1 to skip import-time bootstrap |
Backup format
{
"my-prompt": {
"type": "text",
"labels": {
"production": "You are a helpful assistant.",
"dev": "You are a dev assistant."
}
}
}
To refresh the backup, delete the file and restart (or re-run langfuse-freeze-bootstrap).
Running tests
Unit tests (no network):
uv run pytest tests/ -m "not integration"
Integration tests (requires Langfuse running at http://localhost:10016):
uv run pytest tests/ -m integration
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
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 langfuse_freeze-0.1.1.tar.gz.
File metadata
- Download URL: langfuse_freeze-0.1.1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cd00688df0bfe79bb9ec5b48415ff2c4eef89cfa3c951b3145bde033f1ed682
|
|
| MD5 |
7a7b210a070a4a83aa1f9bd970492512
|
|
| BLAKE2b-256 |
775c64092cb31223fe445bb4411add93ed97f5ad71435807e9a20fbee92bc25c
|
Provenance
The following attestation bundles were made for langfuse_freeze-0.1.1.tar.gz:
Publisher:
publish.yml on SpazioDati/langfuse-freeze
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langfuse_freeze-0.1.1.tar.gz -
Subject digest:
1cd00688df0bfe79bb9ec5b48415ff2c4eef89cfa3c951b3145bde033f1ed682 - Sigstore transparency entry: 1524788543
- Sigstore integration time:
-
Permalink:
SpazioDati/langfuse-freeze@a210d170f5475cbd2d2384f83f71d8858cbfb00a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/SpazioDati
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a210d170f5475cbd2d2384f83f71d8858cbfb00a -
Trigger Event:
push
-
Statement type:
File details
Details for the file langfuse_freeze-0.1.1-py3-none-any.whl.
File metadata
- Download URL: langfuse_freeze-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f366440d90e0b79d9229a1870e90aa4620a816119aab067df0019ae134ff028b
|
|
| MD5 |
d08fdb1f96e9abaab24c4fa76aad6ee5
|
|
| BLAKE2b-256 |
6087f8c9155dcd80ef3367a222a91196ee2770d8cc89fe66c4b1885eaabf4c8d
|
Provenance
The following attestation bundles were made for langfuse_freeze-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on SpazioDati/langfuse-freeze
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langfuse_freeze-0.1.1-py3-none-any.whl -
Subject digest:
f366440d90e0b79d9229a1870e90aa4620a816119aab067df0019ae134ff028b - Sigstore transparency entry: 1524788576
- Sigstore integration time:
-
Permalink:
SpazioDati/langfuse-freeze@a210d170f5475cbd2d2384f83f71d8858cbfb00a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/SpazioDati
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a210d170f5475cbd2d2384f83f71d8858cbfb00a -
Trigger Event:
push
-
Statement type: