AssistantBuilder
A fluent builder for assembling an assistant step by step before deploying. Each method returns self, so calls can be chained.
When to use this
Use AssistantBuilder when you want a readable, declarative configuration — especially when adding multiple data sources or examples. For a one-liner, use create_assistant(). For full programmatic control, use the Assistant class.
Chained example
from custodian_labs import AssistantBuilder
app = (
AssistantBuilder()
.model("gpt-4o")
.prompt("You are a knowledgeable HR assistant.")
.examples([
{
"user": "How many vacation days do I get?",
"assistant": "Full-time employees receive 20 days of PTO per year.",
}
])
.data_source_file("./docs/employee-handbook.pdf")
.data_source_file("./docs/benefits-guide.pdf")
.deploy()
)
response = app.chat("What's the parental leave policy?")
print(response.response)
Methods
.model(model: str)
Set the LLM model.
builder.model("gpt-4o-mini")
.prompt(system_prompt: str)
Set the system prompt.
builder.prompt("You are a helpful assistant.")
.examples(examples: list[dict])
Add few-shot examples. Each dict must have "user" and "assistant" keys. Calling this method multiple times appends to the existing list.
builder.examples([
{"user": "Hello", "assistant": "Hi! How can I help you today?"},
])
.data_source_file(path: str)
Upload a file as a knowledge source for RAG retrieval. Supported formats: TXT, PDF, DOCX, XLS, XLSX. Calling this method multiple times adds each file as a separate data source.
builder.data_source_file("./knowledge-base.pdf")
.deploy()
Create the assistant, upload any data sources, and deploy it as a live App. Returns an App object.
app = builder.deploy()
.deploy() makes network calls. Uploading large files may take a few seconds while the content is parsed and indexed.