AssistantAgent and
RetrieveUserProxyAgent, which is similar to the usage of
AssistantAgent and UserProxyAgent in other notebooks (e.g.,
Automated Task Solving with Code Generation, Execution &
Debugging).
Essentially, RetrieveUserProxyAgent implement a different auto-reply
mechanism corresponding to the RetrieveChat prompts.
Table of Contents
We’ll demonstrate six examples of using RetrieveChat for code generation and question answering:Some extra dependencies are needed for this notebook, which can be installed via pip:For more information, please refer to the installation guide.
Setup Couchbase Capella Cluster
Before we proceed with the notebook. We will require a Couchbase Capella Database Cluster Running.- To setup a free operational cluster, Head over Couchbase Cloud and create an account. Over there create a free cluster. For more details on creating a cluster, refer here.
-
After creating the cluster, We will create our required bucket,
scope, collections. Head over to Data Tools. On the left hand
side panel, you will get an option to create a bucket. Give
appropriate Bucket Name, Scope Name, Collection Name. For this
tutorial, set
- Bucket Name : test_db
- Scope Name: test_scope
- Collection Name: demo_collection
- Now, we will connect to the cluster. Refer this page for connection
- Next, let’s create user to connect. Head over to settings tab. Click [Create Cluster Access]. Specify a username and password and give read/write all buckets access. You may create more users with less than admin access. For more information, refer here
- Add IP Address to allowed IPs. in settings, click on [Networking]. Add allowed IP based on your requirements.
-
Let’s fill our environment variables. First get the connection
string from the [Connect] Tab. Now we will have 3 envs for
Couchbase cluster and one for open AI
- CB_CONN_STR : Couchbase Cluster Connection string
- CB_USERNAME : Username of the user, created above
- CB_PASSWORD : Password of the user, created above
- OPENAI_API_KEY : OpenAI API Key which agents will require.
Set your API Endpoint
Construct agents for RetrieveChat
We start by initializing theAssistantAgent and
RetrieveUserProxyAgent. The system message needs to be set to “You are
a helpful assistant.” for AssistantAgent. The detailed instructions are
given in the user message. Later we will use the
RetrieveUserProxyAgent.message_generator to combine the instructions
and a retrieval augmented generation task for an initial prompt to be
sent to the LLM assistant.