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.2.tar.gz (37.3 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.2-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pillar_ai_server-0.2.2.tar.gz
  • Upload date:
  • Size: 37.3 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.2.tar.gz
Algorithm Hash digest
SHA256 d4898cdd8727d8a31b4c42c1ddd67c9dd8f1af935b0b7d56bd015cab424e0b3c
MD5 e024bb0d58c27b8aa0255a83dccf4c32
BLAKE2b-256 4dd98be68b84ebc861764532c5de55b793de4799024d2859fce97504df984cd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pillar_ai_server-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ba83eb2a8c146d00b64a579a8c0ab802c3af6d5464e2487bd24aa51a8eed1e2c
MD5 83fb63a4774156d492f4c5df8f242df6
BLAKE2b-256 fe2e9480c8dfa8c137fedb2a8d9fe542e33fcf8ecf8be4df6a02d6ee1d86aed2

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