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_URLstill works as fallbackAI_SDK_API_KEYstill 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 viaPOST /apps/deploy.Assistant.deploy()deploys viaPOST /assistants/{assistant_id}/deployand returns anApp.App.chat(message)returns a structured response with:responseretrieved_contextsmessagesraw_payload
App.chat()with no message enters interactive CLI mode.
Error Handling
The SDK raises typed exceptions:
AuthenticationErrorfor 401/missing API keyNotFoundErrorfor 404ValidationErrorfor 422ServerErrorfor 5xxAPIConnectionErrorfor 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
- Build wheel and sdist:
python -m pip install --upgrade build
python -m build
- Install locally from built artifacts:
pip install dist/*.whl
- Optional: publish to TestPyPI:
python -m pip install --upgrade twine
python -m twine upload --repository testpypi dist/*
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fb86a260edfa116be6c3f9353430fe3d6c46d81d83c2b2113d79e02e266f4a3
|
|
| MD5 |
810a47ea70b0ee9fb07e69d0f479c7fc
|
|
| BLAKE2b-256 |
f6127531a434c4160c137a13010c0c95bef393c594db67641f014bc6d3f60294
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74ad61f07479a695d58a9b282ce928bd9ce0039b9d5bc6315149ec26a4924a9c
|
|
| MD5 |
1fb181eaf45fad4f1d5de74a408c3dad
|
|
| BLAKE2b-256 |
f06e0f078ad5479da9bf18b124cfa0c4e74f004354a52f65519bebc459c2ed6e
|