# raindrop-dspy

Raindrop integration for DSPy. Wraps DSPy modules (Predict, ChainOfThought, etc.) to capture input, output, model name, and token usage.

## Installation

```bash
pip install raindrop-dspy dspy
```

## Usage

```python
import dspy
from raindrop_dspy import create_raindrop_dspy

raindrop = create_raindrop_dspy(api_key="rk_...", user_id="user-123")

lm = dspy.LM("openai/gpt-4o-mini")
dspy.configure(lm=lm)

predict = dspy.Predict("question -> answer")
wrapped = raindrop["wrap"](predict)

result = wrapped(question="What is the capital of France?")
print(result.answer)

raindrop["shutdown"]()
```

## What gets captured

- **Module calls**: input kwargs, output text, configured model name
- **Token usage**: prompt/completion tokens if available
- **Errors**: tracked and re-raised

## Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `api_key` | `str` | required | Raindrop API key |
| `user_id` | `str` | `None` | Associate all events with a user |
| `convo_id` | `str` | `None` | Group events into a conversation |

## Testing

```bash
cd packages/dspy-python
pip install -e .
python -m pytest tests/ -v
```
