Metadata-Version: 2.4
Name: letterbook-ai-chat
Version: 0.1.1
Summary: Python SDK for capturing AI chat issues
Author: Letterbook
License: MIT
Keywords: ai,chat,helpdesk,letterbook,support
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Python: >=3.10
Provides-Extra: otel
Requires-Dist: opentelemetry-api<2.0,>=1.0; extra == 'otel'
Description-Content-Type: text/markdown

# Letterbook AI Chat Python SDK

Capture AI chat turns from your application so conversations can appear in the Letterbook platform when customers need help.

```python
import letterbook

result = letterbook.capture(
    user_id="user123",
    event="user_message",
    model="gpt_4",
    input="The checkout page is broken and I was charged twice.",
    output="I am sorry, I cannot fix billing issues from here.",
    convo_id="conv789",
    customer_email="customer@example.com",
    debounce_seconds=300,
    properties={
        "system_prompt": "you are a helpful assistant",
        "experiment": "experiment_a",
    },
    attachments=[
        {
            "type": "text",
            "name": "Additional Info",
            "value": "A very long document",
            "role": "input",
        }
    ],
)

print(result.queued, result.evaluation_after_seconds)
```

Set `LETTERBOOK_API_KEY`, or instantiate `letterbook.Letterbook(api_key=...)` for explicit configuration.
Set `debounce_seconds` to control how long Letterbook waits after the last message before evaluating the conversation.
If OpenTelemetry is configured in your app, the SDK automatically propagates the active trace context with each capture request. You can install `letterbook-ai-chat[otel]` if your app does not already include OpenTelemetry.

If `customer_email` is omitted, the SDK looks for `properties["customer_email"]`, `properties["email"]`, or an email-shaped `user_id`.
Email is only required if Letterbook promotes the capture to a ticket.
