Metadata-Version: 2.4
Name: dr-langfuse
Version: 0.1.0
Summary: Langfuse prompt and trace primitives
Project-URL: Repository, https://github.com/drothermel/dr-langfuse
Project-URL: Issues, https://github.com/drothermel/dr-langfuse/issues
Author-email: Danielle Rothermel <danielle.rothermel@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: langfuse<4.0.0,>=3.0.0
Requires-Dist: pydantic<3.0,>=2.0
Description-Content-Type: text/markdown

# dr-langfuse

Typed Pydantic models, adapter protocols, and concrete implementations for Langfuse prompt fetching and trace emission.

## Install

```bash
pip install dr-langfuse
```

## Quick start

```python
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)
```

```python
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:

```bash
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:

```python
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
