Skip to main content

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+
  • pydantic 2.x
  • langfuse 3.x

License

MIT

Metadata

Release files for dr-langfuse 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dr-langfuse 0.1.0
File Size Uploaded
dr_langfuse-0.1.0.tar.gz 52.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dr-langfuse 0.1.0
File Interpreter ABI Platform
dr_langfuse-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 68.3 kB

Release files / dr_langfuse-0.1.0.tar.gz

Download URL dr_langfuse-0.1.0.tar.gz
Size 52.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8c5d92acc755d82eefd7846b8a4f94dca8b66d464275593ff5381b995415d15a
BLAKE2b-256 checksum
How to use checksums
ee02163c38c7cfb4c68c0b9f2cda56d29b4cce254004e9c5087c9cf9a6b82473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.0

Release files / dr_langfuse-0.1.0-py3-none-any.whl

Download URL dr_langfuse-0.1.0-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
510352fc22dc50f9ada375b1744805763afc40f6857cfa60e81ecb6bf7e7f608
BLAKE2b-256 checksum
How to use checksums
a4c1ebb8e85e0bea84129b6ce1d00c6a8b7a205c16f3dbd7d74da94f17090a12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page