Langfuse prompt and trace primitives
Project description
dr-langfuse
Typed Pydantic models, adapter protocols, and concrete implementations for Langfuse prompt fetching and trace emission.
Install
pip install dr-langfuse
Quick start
from dr_langfuse import LangfusePromptProvider, PromptFetchRequest
provider = LangfusePromptProvider() # reads LANGFUSE_* env vars
payload = provider.fetch_prompt(
PromptFetchRequest(prompt_name="my-prompt", variables={"topic": "recursion"})
)
print(payload.system_content)
print(payload.task_content)
from dr_langfuse import LangfuseTraceEmitter, TraceEventRequest
emitter = LangfuseTraceEmitter()
ack = emitter.emit_trace(
TraceEventRequest(event_name="eval.step", tags=["experiment"], metadata={"run": 1})
)
print(ack.accepted, ack.trace_id)
What's included
| Module | Contents |
|---|---|
dr_langfuse.prompts |
PromptFetchRequest, PromptPayload, LangfusePromptProvider |
dr_langfuse.tracing |
TraceEventRequest, TraceAck, LangfuseTraceEmitter |
dr_langfuse.errors |
ErrorCode, ErrorEnvelope, LangfuseError |
dr_langfuse.client |
LangfuseConfig |
dr_langfuse.protocols |
PromptProvider, TraceEmitter (runtime-checkable protocols) |
All symbols are re-exported from the top-level package.
Configuration
Set standard Langfuse environment variables:
export LANGFUSE_PUBLIC_KEY="pk-..."
export LANGFUSE_SECRET_KEY="sk-..."
export LANGFUSE_BASE_URL="https://cloud.langfuse.com" # optional
# LANGFUSE_HOST is still supported as a deprecated fallback.
Or pass config explicitly:
from dr_langfuse import LangfuseConfig, LangfusePromptProvider
config = LangfuseConfig(public_key="pk-...", secret_key="sk-...", host="https://cloud.langfuse.com")
provider = LangfusePromptProvider(config=config)
Requirements
- Python 3.12+
pydantic2.xlangfuse3.x
License
MIT
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
dr_langfuse-0.1.0.tar.gz
(52.8 kB
view details)
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 dr_langfuse-0.1.0.tar.gz.
File metadata
- Download URL: dr_langfuse-0.1.0.tar.gz
- Upload date:
- Size: 52.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c5d92acc755d82eefd7846b8a4f94dca8b66d464275593ff5381b995415d15a
|
|
| MD5 |
c88ba32f95dd6fea7fb3de8dcfc14057
|
|
| BLAKE2b-256 |
ee02163c38c7cfb4c68c0b9f2cda56d29b4cce254004e9c5087c9cf9a6b82473
|
File details
Details for the file dr_langfuse-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dr_langfuse-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
510352fc22dc50f9ada375b1744805763afc40f6857cfa60e81ecb6bf7e7f608
|
|
| MD5 |
f16f82c2e626922f91b751de38046507
|
|
| BLAKE2b-256 |
a4c1ebb8e85e0bea84129b6ce1d00c6a8b7a205c16f3dbd7d74da94f17090a12
|