Skip to content

RAG

Retrieval Augmented Generation using Doc Agent

This guide walks you through setting up a simple Retrieval-Augmented Generation (RAG) flow using Waldiez, with a User and a Doc Agent. The Doc Agent is capable of ingesting external documents and answering questions using context retrieved from them.

Overview Overview

🧠 Goal

Set up a workflow where the User prompts the Doc Agent to ingest a document and extract relevant information (using GPT-4o and Chroma vector store).


🧱 Agent Setup

🧑‍💼 User Agent

  • Drag and drop the User agent from the sidebar.
  • This is the human-like agent that initiates the query.

📄 Doc Agent

  • Drag and drop the Docs Agent to the canvas.
  • Rename it to Doc Agent.
  • Model: gpt-4o
  • Enable RAG settings in the “Documents” tab:

RAG Configuration RAG Configuration

Document Config:

  • Collection Name: financial_report
  • Reset Collection: ✅ (enabled)
  • Enable Query Citations: ✅
  • Database Path: chroma (this is relative to the working directory)

🔗 Connection Setup

Create a connection from User to Doc Agent:

  • Message Type: Text
  • Message:

    Can you ingest "https://raw.githubusercontent.com/ag2ai/ag2/refs/heads/main/test/agentchat/contrib/graph_rag/Toast_financial_report.pdf" and tell me the fiscal year 2024 financial summary?
    

Message Setup Message Setup


▶️ Running the Flow

  1. Click the play button in the top right to run the flow.
  2. The Doc Agent will ingest the document and respond based on retrieved content.

💬 Output Example

Output Output


🗂 Files