Metadata-Version: 2.4
Name: letterbook-ai-chat
Version: 0.1.0
Summary: Python SDK for capturing AI chat issues in Letterbook.
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
Description-Content-Type: text/markdown

# Letterbook AI Chat Python SDK

Capture AI chat turns. Letterbook queues each conversation in Redis, waits 5 minutes after the last message by default, evaluates the full transcript server-side with an LLM, and dedupes by `convo_id` so one AI conversation does not create multiple tickets.

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