Skip to main content

Pillar backend SDK — register server-side tools and handle tool calls from Pillar Cloud

Project description

pillar-ai-server

Python backend SDK for Pillar — register server-side tools and handle tool calls from Pillar Cloud.

Install

pip install pillar-ai-server

Quick start

from pillar import Pillar, ToolContext

pillar = Pillar(secret="plr_...")

@pillar.tool(description="Look up a customer by email")
async def lookup_customer(email: str, ctx: ToolContext) -> dict:
    customer = await db.get_customer(email=email)
    return {"name": customer.name, "plan": customer.plan}

Framework integration

Django

# urls.py
from myapp.pillar_tools import pillar

urlpatterns = [
    path("pillar/", pillar.django_view()),
]

Flask

from myapp.pillar_tools import pillar

app.route("/pillar", methods=["POST"])(pillar.flask_handler())

Standalone

pillar.serve(port=8787)

Confirmation responses

When a tool needs user confirmation before performing an action, return a ConfirmationResponse from your handler. Pillar renders a channel-appropriate confirmation UI and re-calls your handler with ctx.confirmed = True after the user confirms.

from pillar import Pillar, ToolContext, ConfirmationResponse

pillar = Pillar(secret="plr_...")

@pillar.tool(description="Create a new plan")
async def create_plan(name: str, price: float, ctx: ToolContext) -> dict:
    if not ctx.confirmed:
        return ConfirmationResponse(
            confirmation_required=True,
            title="Create plan",
            message=f'Create "{name}" at ${price}/mo?',
            details={"Plan name": name, "Price": f"${price}/mo"},
            confirm_payload={"name": name, "price": price},
        )

    await db.create_plan(name=name, price=price)
    return {"created": True}

ConfirmationResponse fields

Field Required Description
confirmation_required yes Must be True.
title no Short headline. Defaults to the tool name.
message no One-line description shown before the buttons.
details no Key-value pairs rendered as a summary card.
confirm_payload no Opaque data passed back to your handler on confirm. Defaults to the original arguments.

ToolContext

Field Type Description
caller CallerInfo Identity and channel metadata for the user.
conversation_id str Current conversation ID.
call_id str Unique ID for this tool call.
product_id str | None Product ID, if applicable.
confirmed bool True when re-executing after user confirmation.
is_identified bool True when the caller has a resolved external user ID.

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

pillar_ai_server-0.2.4.tar.gz (39.2 kB view details)

Uploaded Source

Built Distribution

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

pillar_ai_server-0.2.4-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file pillar_ai_server-0.2.4.tar.gz.

File metadata

  • Download URL: pillar_ai_server-0.2.4.tar.gz
  • Upload date:
  • Size: 39.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pillar_ai_server-0.2.4.tar.gz
Algorithm Hash digest
SHA256 52fd06c9863cf7ddec40b1194b260c8ead407e1a23ba3eb00058d5bb14466eaf
MD5 9c66f85762f7fb55a6776064c3bd9063
BLAKE2b-256 ae2387577ed94567924cb2d55536e6a1073874f7e948996b64875c4741b2be57

See more details on using hashes here.

File details

Details for the file pillar_ai_server-0.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pillar_ai_server-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 86561715b6bfd7fff797dafe3b92af72383e7d8db7ed242b5719338d8ab57ec7
MD5 6b09881e3ffe224bdd139264392c7c74
BLAKE2b-256 183253a61ea4b28cbd79894dab6798de309d2a702f90e8a3f3a74b648e97dc3d

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