Skip to main content
This recipe builds a document question-answering agent with SeekrFlow’s Agent framework and the FileSearch tool. You index a set of documents into a vector database, attach that database to an agent through a FileSearch tool, and prompt the agent to answer only from what it retrieves, rate its confidence, and cite its sources. The example uses a new hire onboarding scenario, but the pattern works for any document set. Gather 3 to 5 high-quality documents relevant to your use case before you start.

What you’ll build

An agent that:
  1. Indexes your documents into a vector database.
  2. Searches across those documents to answer questions.
  3. Rates its confidence and explains the rating.
  4. Cites the specific sources behind each answer.

Prerequisites

  • A SeekrFlow API key, set as the SEEKR_API_KEY environment variable
  • Documents in PDF, DOCX, or Markdown format
  • Python 3.8 or later
  • The SeekrFlow SDK: pip install seekrai
This recipe creates billable resources. When you are done, remove them with the cleanup step.

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_k and score_threshold on the FileSearch tool to trade recall against precision for your document set.
  • Swap in your own documents. Point FILE_PATHS at 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.
Last modified on July 16, 2026