Skip to content

RAG

Group Chat with Retrieval Augmented GenerationΒΆ

In this example, we configure a group chat environment with multiple agents, each assigned a specific role. A Boss Assistant agent utilizes Retrieval Augmented Generation (RAG) to help solve complex problems by retrieving relevant information and responding accurately. The task involves using Spark for parallel training in FLAML.

Example 7 overview Example 7 overview

OverviewΒΆ

The workflow includes:

  • Boss Assistant Agent: Assists with extra content retrieval power for solving difficult problems.
  • (Group) Manager Agent: Manages the group chat environment.
  • Code Reviewer Agent: Reviews the code.
  • Product Manager Agent: Designs and plans the project.
  • Senior Python Engineer Agent: Writes code to solve problems and answer questions.

Agents setupΒΆ

Boss Assistant AgentΒΆ

Drag and drop a new User Proxy agent to the canvas and configure it as follows:

  • Name: Boss Assistant
  • Description: Assistant with extra content retrieval power for solving difficult problems.
  • Max consecutive auto reply: Set to 3.
  • Agent Default Auto Reply: Reply TERMINATE if the task is done.

Also check Use RAG box and configure the RAG settings as follows:

RAG Agent setup RAG Agent setup

Retrieve Config TabΒΆ
  • Task: Set the task type to Code.
  • Docs Paths: Since the task is about using Spark for parallel training in FLAML, we use the following document path: https://raw.githubusercontent.com/microsoft/FLAML/main/website/docs/Examples/Integrate%20-%20Spark.md
  • Collection Name: groupchat
  • Number of Results: Set to 3.
Vector DB ConfigΒΆ
  • Vector DB: Chroma
  • Embedding Model: all-MiniLM-L6-v2, the default for Chroma.
  • Use Persistent Storage: Checked
  • Storage Path: documents

RAG DB setup RAG DB setup

Note

Feel free to experiment with different settings to optimize the retrieval process.

TerminationΒΆ

On the Termination tab, setup a simple keyword-based termination rule with the keyword TERMINATE and Keyword is the last word as the termination criterion.

ModelΒΆ

Link a model of your choice to the Boss Assistant. In our example, we use the gpt-3.5-turbo model.

Group Manager AgentΒΆ

Drag and drop a new Group agent to the canvas and configure the Group chat settings as follows:

  • Admin Name: boss_assistant
  • Max Rounds to 12.
  • Speakers Configuration: Set the speaker selection method to Round robin and allow speaker repetition.
  • Model: Link a model of your choice to the Group Manager. In our example, we use the gpt-3.5-turbo model.

Group MembersΒΆ

Drag and drop the following agents to the Group Manager agent:

Code Reviewer AgentΒΆ
  • System Message: You are a code reviewer. Reply TERMINATE at the end when everything is done.
  • Add the Termination rule with the keyword TERMINATE.
  • Link a model of your choice to the Code Reviewer agent.
Product Manager AgentΒΆ
  • System Message: You are a product manager. Reply TERMINATE at the end when everything is done.
  • Add the Termination rule with the keyword TERMINATE.
  • Link a model of your choice to the Product Manager agent.
Senior Python Engineer AgentΒΆ
  • System Message: You are a senior python engineer, you provide python code to answer questions. Reply TERMINATE in the end when everything is done.
  • Add the Termination rule with the keyword TERMINATE.
  • Link a model of your choice to the Senior Python Engineer agent.

ConnectionsΒΆ

Add a link between the Boss Assistant and the Group Manager to start the conversation. For the message, this type we use the RAG Message Generator. It uses autogen's sender.message_generator method to generate the message to pass to the Group Manager.

RAG Message RAG Message

WorkflowΒΆ

Before running the flow, open the Edit flow modal as usual, and add the one connection we have to the flow. Run the flow using the play button and inspect the logs to monitor the conversation between the agents.


Files used in this example: