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:
- confirm
make
andpoetry
are installed - you have a funded OpenAI account
Agents
This example uses two agents:
- conversational-agent: a user-facing copilot that is instantiated from the built-in SimpleAgent, which is the default agent if none is specified
- s3-search: a RAG agent that is instantiated from the built-in RetrieverAgent
| 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/v1alpha1kind: Agentmetadata: 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/v1alpha1kind: Agentmetadata: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!
- First clone Eidolon’s chatbot repository.
git clone https://github.com/eidolon-ai/eidolon-s3-rag.gitcd eidolon-s3-rag
- 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_keyAWS_ACCESS_KEY_ID=your_access_keyAWS_SECRET_ACCESS_KEY=your_secret_access_key
- Change the
bucket
andregion_name
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
- Start your server.
make docker-serve # or sudo make docker serve; launches agent server and webui
- 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.