Skip to main content

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

License

MIT

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

dr_langfuse-0.1.0.tar.gz (52.8 kB view details)

Uploaded Source

Built Distribution

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

dr_langfuse-0.1.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

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

Hashes for dr_langfuse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c5d92acc755d82eefd7846b8a4f94dca8b66d464275593ff5381b995415d15a
MD5 c88ba32f95dd6fea7fb3de8dcfc14057
BLAKE2b-256 ee02163c38c7cfb4c68c0b9f2cda56d29b4cce254004e9c5087c9cf9a6b82473

See more details on using hashes here.

File details

Details for the file dr_langfuse-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dr_langfuse-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 510352fc22dc50f9ada375b1744805763afc40f6857cfa60e81ecb6bf7e7f608
MD5 f16f82c2e626922f91b751de38046507
BLAKE2b-256 a4c1ebb8e85e0bea84129b6ce1d00c6a8b7a205c16f3dbd7d74da94f17090a12

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