Overview
In this notebook, we show the usage of CAMEL Retrieve Module in both customized way and auto way. We will also show how to combineAutoRetriever
with ChatAgent
, and further combine AutoRetriever
with RolePlaying
by using Function Calling
.
4 main parts included:
- Customized RAG
- Auto RAG
- Single Agent with Auto RAG
- Role-playing with Auto RAG
Installation
Ensure you have CAMEL AI installed in your Python environment:Load Data
Let’s first load the CAMEL paper from https://arxiv.org/pdf/2303.17760.pdf. This will be our local example data.1. Customized RAG
In this section we will set our customized RAG pipeline, we will takeVectorRetriever
as an example.
Set embedding model, we will use OpenAIEmbedding
as the embedding model, so we need to set the OPENAI_API_KEY
in below.
Unstructured Module
to splite the content into small chunks, the content will be splited automacitlly with its chunk_by_title
function, the max character for each chunk is 500 characters, which is a suitable length for OpenAIEmbedding
. All the text in the chunks will be embed and stored to the vector storage instance, it will take some time, please wait..
top_k
value and similarity_threshold
value with your needs.
The returned dictionary list includes:
- similarity score
- content path
- metadata
- text
2. Auto RAG
In this section we will run theAutoRetriever
with default settings. It uses OpenAIEmbedding
as default embedding model and Qdrant
as default vector storage.
What you need to do is:
- Set content input paths, which can be local paths or remote urls
- Give a query
3. Single Agent with Auto RAG
In this section we will show how to combine theAutoRetriever
with one ChatAgent
.
Let’s set an agent function, in this function we can get the response by providing a query to this agent.
4. Role-playing with Auto RAG
In this section we will show how to combine theRETRIEVAL_FUNCS
with RolePlaying
by applying Function Calling
.