What you’ll build
An agent that:- Indexes a document into a vector database.
- Searches that database through a FileSearch tool.
- Answers questions grounded in what it retrieves.
Prerequisites
- A SeekrFlow API key, set as the
SEEKR_API_KEYenvironment variable - Python 3.8 or later
- The SeekrFlow SDK:
pip install seekrai
Build it
1
Set up the client
Create
rag_agent.py with the imports, configuration, and client. RUN_ID adds
a short unique suffix to the resource names so repeat runs don’t collide.2
Create and upload a document
Write a short Markdown document to a temporary file and upload it with
purpose=FilePurpose.Alignment, which marks it for data-engine ingestion.Upload several files at once
Upload several files at once
To index several documents, upload them with
client.files.bulk_upload, collect
the returned IDs, and include them all in a single create_ingestion_job call.3
Create a vector database
Create a vector database. Documents you ingest are embedded with the model you
name here and stored for retrieval.
4
Ingest the document
Start an ingestion job to chunk, embed, and store the file, then poll until it
completes.
5
Create a FileSearch tool
Wrap the vector database in a FileSearch tool. The
file_search_index points the
tool at your database, and the description tells the agent when to use it.6
Create the agent
Create an agent, attach the tool by ID, and instruct it to answer from what the
tool retrieves.
7
Promote the agent
Promote the agent to deploy it, then wait for it to become
Active.8
Ask a question
Create a thread, send a question, wait for the run to finish, and print the
agent’s reply.
9
Run the script
Run the finished script:The agent searches the indexed document and answers that Seekr Technologies is
headquartered in Reston, Virginia, and builds SeekrFlow.
Clean up resources (optional)
This shuts down the agent and removes the tool, vector database, and file the recipe created.Next steps
- Use your own documents. Replace the inline document with real files (PDF, DOCX, or Markdown) to build a knowledge base for your own domain.
- Add citations and confidence. See New hire onboarding agent with citations for a version that rates its confidence and cites sources.
- Tune retrieval. Set
top_kandscore_thresholdonFileSearchConfigto control how much context the tool returns.