Skip to main content

Minimal Python SDK for building and deploying chatbot apps

Project description

custodian_labs

custodian_labs is a minimal Python SDK for building and deploying chatbot apps against a FastAPI backend.

Default backend URL: http://127.0.0.1:8000/v1

Install

pip install custodian-labs

Environment Variables

  • CUSTODIAN_SDK_BASE_URL (optional)
  • CUSTODIAN_SDK_API_KEY (required for all non-health calls)

Legacy compatibility:

  • AI_SDK_BASE_URL still works as fallback
  • AI_SDK_API_KEY still works as fallback

Quickstart: Assistant Class Style

from custodian_labs import Assistant

my_examples = [
    {"user": "What is 2+2?", "assistant": "4"},
    {"user": "Say hi", "assistant": "Hello!"},
]

assistant = Assistant(
    model="gpt-4o",
    system_prompt="You are a helpful assistant"
)
assistant.add_examples(my_examples)
assistant.add_data_source_file("knowledge.txt")  # optional RAG file upload
app = assistant.deploy()

reply = app.chat("Summarize the main topic in my file")
print(reply.response)
print(reply.retrieved_contexts)
print(reply.messages)

Quickstart: Minimal Function Style

from custodian_labs import create_assistant

my_examples = [
    {"user": "What is 2+2?", "assistant": "4"},
]

app = create_assistant(
    model="gpt-4o",
    prompt="You are a helpful assistant",
    examples=my_examples,
)

app.chat()  # interactive CLI mode

Quickstart: Builder Style

from custodian_labs import AssistantBuilder

my_examples = [
    {"user": "Who are you?", "assistant": "I am your assistant."},
]

app = (
    AssistantBuilder()
    .with_model("gpt-4o")
    .with_prompt("You are a helpful assistant")
    .with_examples(my_examples)
    .with_data_source_file("knowledge.txt")
    .deploy()
)

app.chat()

API Notes

  • create_assistant() deploys directly via POST /apps/deploy.
  • Assistant.deploy() deploys via POST /assistants/{assistant_id}/deploy and returns an App.
  • App.chat(message) returns a structured response with:
    • response
    • retrieved_contexts
    • messages
    • raw_payload
  • App.chat() with no message enters interactive CLI mode.

Error Handling

The SDK raises typed exceptions:

  • AuthenticationError for 401/missing API key
  • NotFoundError for 404
  • ValidationError for 422
  • ServerError for 5xx
  • APIConnectionError for network errors

All exceptions include endpoint/status details and the backend payload where available.

Running Tests

pip install -e .[dev]
pytest -q

How to Publish

  1. Build wheel and sdist:
python -m pip install --upgrade build
python -m build
  1. Install locally from built artifacts:
pip install dist/*.whl
  1. Optional: publish to TestPyPI:
python -m pip install --upgrade twine
python -m twine upload --repository testpypi dist/*
  1. Optional: publish to PyPI:
python -m twine upload dist/*

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

custodian_labs-0.1.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

custodian_labs-0.1.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file custodian_labs-0.1.0.tar.gz.

File metadata

  • Download URL: custodian_labs-0.1.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for custodian_labs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fbeb4069936f08c36ddf879e291a6181e151cab4ef6bc5d1b095f9179bdc496a
MD5 c95ea703b04a3a8aaa2f48d50f96e444
BLAKE2b-256 253eb0508463ebb4f6f040907ff33cf541a89cb67e696537c8d0ef7df9dd41be

See more details on using hashes here.

File details

Details for the file custodian_labs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: custodian_labs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for custodian_labs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 087a93f6efa7ec510891b3a18d675376073a4201772662e2f5a3b096e715e823
MD5 531aaec728cda3103784d675ef4a2b61
BLAKE2b-256 04b4e4423d58c04ca8f277f9ed514dbc2b4b7480245c970ea71d94822fb2b8de

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