Skip to main content

Python SDK for the Partython AI brain — embed conversational AI in your app or backend.

Project description

partython-brain

Python SDK for the Partython AI brain — embed conversational, sales-aware AI in your app or backend.

pip install partython-brain

Quick start

from partython_brain import Brain
import os

brain = Brain(api_key=os.environ["PARTYTHON_API_KEY"])

result = brain.respond(
    channel="web",
    channel_user_id="user-abc",
    message_text="I'm planning a 5-year-old's birthday with 12 guests — any unicorn theme ideas?",
)
print(result["response"])
# → "A unicorn theme for a 5-year-old with 12 guests — fun! Let me show you our..."

API

Brain(api_key, base_url=None, timeout=30, session=None)

Param Default Description
api_key (required) Your pk_live_... API key
base_url https://brain.partython.com Override for self-hosted
timeout 30.0 Per-call timeout in seconds
session new requests.Session Custom session for retries / connection pool

brain.respond(...)

Keyword args (all required unless noted):

  • channel: str"web" | "whatsapp" | "sms" | "api" ...
  • channel_user_id: str — stable id for the conversation participant
  • message_text: str — the customer's message
  • metadata: dict | None — optional pass-through metadata
  • dedup_key: str | None — idempotency key (webhook event id)
  • has_image: bool — hint for the smart router

Returns dict with response, assistant_name, request_id, metadata.

Errors

from partython_brain import BrainAuthError, BrainRateLimitError

try:
    brain.respond(...)
except BrainRateLimitError as e:
    # back off — retry-after info is in e.body
    ...
except BrainAuthError as e:
    # key invalid or revoked
    ...
Exception When it fires
BrainAuthError 401 / 403 — key invalid, revoked, or no scope
BrainRateLimitError 429 — per-key per-minute limit hit
BrainNotFoundError 404 — tenant misconfigured
BrainServerError 5xx upstream
BrainNetworkError Network or timeout

License

MIT

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

partython_brain-1.0.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

partython_brain-1.0.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file partython_brain-1.0.0.tar.gz.

File metadata

  • Download URL: partython_brain-1.0.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for partython_brain-1.0.0.tar.gz
Algorithm Hash digest
SHA256 97c6e325011f226c2698388f0987b0f2a51399e04315a744f93b9fa2ec3202fa
MD5 c9bf6ea101f75355c7975dc2165d45ce
BLAKE2b-256 317f84082550678506d7bc85ff1fc9701b1da4d844b74d135124999a06c451f4

See more details on using hashes here.

File details

Details for the file partython_brain-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for partython_brain-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 210e842305a8ed67a3479fee6c53b69dde1deb0768456ad0f4f7561e645fa627
MD5 836754cfbad2e3001fef9bb31136a7d6
BLAKE2b-256 eacf925cf2d1ed8cdbbb506149e7a1031973d463d9d2103e1eef1807512a8609

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