RAG agent
An agent that answers from your own files.
This example: an HR policy assistant that answers employees' questions from the company handbook and benefits spreadsheet, and says so when the answer isn't there.
Example (replies vary)
You: How many days can I work from home each week?
Agent: You can work remotely up to 2 days a week, agreed in advance with
your manager. Fully remote arrangements need HR approval.
retrieved_contexts:
"4.2 Remote work. Employees may work remotely up to two days per week..."
"4.3 Requests for fully remote arrangements must be approved by HR..."
You: What's the company policy on pets in the office?
Agent: The handbook doesn't cover pets in the office. I'd check with HR.
- Python
- TypeScript
from custodian_labs import Custodian
app = (
Custodian(
model="gpt-6-luna",
system_prompt="You are an HR policy assistant. Answer only from the handbook. "
"If the answer isn't there, say so.",
)
.add_data_source_file("./employee-handbook.pdf")
.add_data_source_file("./benefits.xlsx") # attach as many files as you need
.deploy()
)
reply = app.chat("How many days of remote work are allowed per week?")
print(reply.response)
print(reply.retrieved_contexts) # the chunks the answer used
import { Custodian } from "@custodianlabs/sdk";
const app = await new Custodian({
model: "gpt-6-luna",
systemPrompt:
"You are an HR policy assistant. Answer only from the handbook. If the answer isn't there, say so.",
})
.addDataSourceFile("./employee-handbook.pdf")
.addDataSourceFile("./benefits.xlsx") // attach as many files as you need
.deploy();
const reply = await app.chat("How many days of remote work are allowed per week?");
console.log(reply?.response);
console.log(reply?.retrievedContexts); // the chunks the answer used
In a browser or edge runtime, pass bytes instead of a path:
addDataSourceFile({ data, filename: "handbook.pdf" }).
Learn more
- Data sources and RAG: how file search works, supported files and tips for better answers.
- RAG on sensitive data: masking personal data in files before you attach them.