Python SDK for capturing AI chat issues in Letterbook.
Project description
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.
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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file letterbook_ai_chat-0.1.0.tar.gz.
File metadata
- Download URL: letterbook_ai_chat-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8a864e9e660730144c0e8f0443d1eaf0e2ff01d082d148cf8188087309eef9c
|
|
| MD5 |
06089ac01ca1e56c980930aaa0b2b089
|
|
| BLAKE2b-256 |
36df8d590a335e32f4b20650dcec919e99ccafe3080d053e0aeaebcd092e2e6e
|
File details
Details for the file letterbook_ai_chat-0.1.0-py3-none-any.whl.
File metadata
- Download URL: letterbook_ai_chat-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd28aeff2423550aa143c68dd219a39129e489aa1cb32ce5b14d6b76b84be69c
|
|
| MD5 |
73c9ddfa9c41d71f82a4db80f128dd7c
|
|
| BLAKE2b-256 |
7eac6dd8f54998961420de4bd7c46fc078f0d1fe48958d19d6c0e49bea31deae
|