Skip to main content

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.
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
Learn more