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
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
.
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.
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.
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.
| 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.
- Use a text editor to add your LLM API key and AWS keys to a plain-text
.env
file, e.g.:
- Change the
bucket
andregion_name
- Start your server.
- 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.