What you’ll build
An agent that:- Indexes your documents into a vector database.
- Searches across those documents to answer questions.
- Rates its confidence and explains the rating.
- Cites the specific sources behind each answer.
Prerequisites
- A SeekrFlow API key, set as the
SEEKR_API_KEYenvironment variable - Documents in PDF, DOCX, or Markdown format
- Python 3.8 or later
- The SeekrFlow SDK:
pip install seekrai
Build it
1
Set up the client
Create
onboarding_agent.py and start with the imports, configuration, and
client. The paths in FILE_PATHS should point at your own documents.2
Create a vector database
Create an empty vector database. Documents you ingest are embedded with the
model you name here and stored for retrieval.
3
Upload your documents
Upload each document to SeekrFlow’s AI-Ready Data Engine with
purpose="alignment"
and collect the file IDs.4
Ingest the documents
Start an ingestion job to chunk, embed, and store the uploaded files, then poll
until it completes. Accuracy-optimized ingestion can take a few minutes.
5
Create the agent
Create an agent and attach a FileSearch tool pointed at your vector database. The
instructions tell it to answer only from search results, rate its confidence,
and cite sources. Then poll until the agent is
Active.6
Ask a question
Create a thread, send a question, wait for the run to finish, and read the
agent’s reply. The
parse_response helper splits the answer, the confidence
rating, and any cited sources out of the reply.7
Run the script
Run the finished script:The agent searches your documents, answers from what it retrieves, and appends a
confidence rating and its sources.
Clean up resources (optional)
Remove the resources this recipe created when you are done.Next steps
- Tune retrieval. Adjust
top_kandscore_thresholdon the FileSearch tool to trade recall against precision for your document set. - Swap in your own documents. Point
FILE_PATHSat any PDF, DOCX, or Markdown files to build an assistant for a different domain. - Add metadata. Attach metadata at ingestion so you can filter retrieval by fields like document type or date.