Skip to content

S3 RAG

This recipe shows how a chatbot agent working with a RAG agent can use documents stored in an Amazon S3 bucket to find answers to questions.

Core Concepts

This example highlights the following core concepts:

Prerequisites

Specific to this example, you need:

  • access to an AWS bucket that contains at least one document

If you completed the Quickstart you should be all set with the remaining prerequisites. If not, make sure to:

Agents

This example uses two agents:

| Note: you can name agents as you wish. You can use hyphens (dashes) but not underscores in agent names.

Conversational Agent: the user-facing copilot

Resources of kind Agent can use an LLM to:

  • reason
  • converse with you and other agents
apiVersion: server.eidolonai.com/v1alpha1
kind: Agent
metadata:
name: conversational-agent

The conversational-agent can delegate tasks to the s3-search agent. This relationship is configured through agent_refs, which is a property specified (“spec’d”) by SimpleAgent.

Typically, you would reference elements of an array on separate lines, with each element preceded by a hyphen (dash). In this example, the array has one element: s3-search.

spec:
agent_refs:
- s3-search

Note that the elements in this array are of type string (as opposed to objects). You can use a shorthand mechanism that is built into SimpleAgent for a more compact presentation.

spec:
agent_refs: [s3-search]

S3 Search: the RAG agent that searches documents

The s3-search agent’s job is to load, embed, and re-embed documents that may change frequently.

This agent also translates requests (in this case, from the conversational-agent) into a vector search query and returns the top results.

apiVersion: server.eidolonai.com/v1alpha1
kind: Agent
metadata:primary
name: s3-search
spec:
implementation: RetrieverAgent
name: "agentic-papers"
description: "Search curated papers on building Agentic AI"

RetrieverAgent, upon which the s3-agent is instantiated, uses a default loader that reads files from disk. We can override this default by specifying the built-in S3Loader instead.

document_manager:
loader:
implementation: S3Loader
bucket: agentic-papers
region_name: us-east-2

| Note: See the description for the RetrieverAgent regarding volume processing. To process a large body of data, you will want to set up an ingestion pipeline.

Try it out!

  1. First clone Eidolon’s chatbot repository.
Terminal window
git clone https://github.com/eidolon-ai/eidolon-s3-rag.git
cd eidolon-s3-rag
  1. Use a text editor to add your LLM API key and AWS keys to a plain-text .env file, e.g.:
OPENAI_API_KEY=your_openai_key
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_access_key
  1. Change the bucket and region_name
s3_search.eidolon.yaml
loader:
implementation: S3Loader
bucket: agentic-papers # change to a bucket you can access with your AWS keys
region_name: us-east-2 # change to the region that hosts the s3 bucket
  1. Start your server.
Terminal window
make docker-serve # or sudo make docker serve; launches agent server and webui
  1. Use the online dev tool ui in your browser. As you converse with the chatbot, it can retrieve information from the S3 buckets before responding back to you.