Skip to main content

Official SDK for building and deploying chatbot apps on the CustodianLabs platform (for CustodianLabs customers).

Project description

custodian_labs

custodian_labs is the official Python SDK for building and deploying chatbot apps on the CustodianLabs platform. It is intended for CustodianLabs customers.

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.1.tar.gz (8.0 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.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: custodian_labs-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 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.1.tar.gz
Algorithm Hash digest
SHA256 5fb86a260edfa116be6c3f9353430fe3d6c46d81d83c2b2113d79e02e266f4a3
MD5 810a47ea70b0ee9fb07e69d0f479c7fc
BLAKE2b-256 f6127531a434c4160c137a13010c0c95bef393c594db67641f014bc6d3f60294

See more details on using hashes here.

File details

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

File metadata

  • Download URL: custodian_labs-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 74ad61f07479a695d58a9b282ce928bd9ce0039b9d5bc6315149ec26a4924a9c
MD5 1fb181eaf45fad4f1d5de74a408c3dad
BLAKE2b-256 f06e0f078ad5479da9bf18b124cfa0c4e74f004354a52f65519bebc459c2ed6e

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