Skip to main content

Python SDK for capturing AI chat issues

Project description

Letterbook AI Chat Python SDK

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

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.

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

letterbook_ai_chat-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

letterbook_ai_chat-0.1.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file letterbook_ai_chat-0.1.1.tar.gz.

File metadata

  • Download URL: letterbook_ai_chat-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for letterbook_ai_chat-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0a3461c856b636ab1de05d8d4beac0831a12105e1e37f0f8c39fc4af84b5812e
MD5 77706e53d950fa5412929f5f41848f25
BLAKE2b-256 0fc3ce75ae06b94754353c0295f82a4741f5346b88cd7a19b827c0c3fcb0dbff

See more details on using hashes here.

File details

Details for the file letterbook_ai_chat-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for letterbook_ai_chat-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 54c31ce44f6f66b5c2fc4512e7f740175a625b635d26de597636d627007a87cc
MD5 42c4f4472f384c569a1073ac361fa9df
BLAKE2b-256 d76ec336a3094e945006f880ee9ffbd94c26b1a1dfc31cda96c01b7ff1bbf9c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page