Skip to main content

CustodianBuilder Class

Use AssistantBuilder when you want to configure an assistant with a chained style.

The Builder API is an alternative to the Custodian Class. Both approaches create and deploy an App.

When to Use AssistantBuilder

Choose AssistantBuilder when:

  • You prefer a fluent configuration style.
  • You want to keep an assistant configuration together in one block.
  • You are adding examples or knowledge files before deployment.

For the shortest setup, use Create Your First Assistant. For direct control over a Custodian object, use the Custodian Class.

Example

from custodian_labs import AssistantBuilder

app = (
AssistantBuilder()
.with_model("gpt-4o")
.with_prompt("You are a helpful finance assistant.")
.with_examples(
[
{
"user": "When is an invoice overdue?",
"assistant": "An invoice is overdue after the due date passes without payment.",
}
]
)
.deploy()
)

The returned App is ready to receive chat messages:

reply = app.chat("Give me a short overdue invoice policy.")
if reply is not None:
print(reply.response)

Methods

MethodPurpose
.with_model(model)Set the model. Required before deployment.
.with_prompt(prompt)Set the system prompt. Required before deployment.
.with_examples(examples)Add sample conversations with user and assistant fields.
.with_data_source_file(path)Attach a local knowledge file. Call it multiple times to add multiple files.
.deploy()Create and deploy the assistant, then return an App.
.chat()Deploy the assistant and start an interactive terminal chat.

For supported knowledge files and retrieval behavior, see Data Sources and RAG.

Authentication

AssistantBuilder reads CUSTODIAN_SDK_API_KEY and CUSTODIAN_SDK_BASE_URL from your environment.

It does not currently accept api_key or base_url arguments directly. For setup instructions, see Authentication.

Next Steps