This script demonstrates how to build a Retrieval-Augmented Generation (RAG) agent with web access using GPT-4o in just 15 lines of Python code. The agent uses a PDF knowledge base and has the ability to search the web using DuckDuckGo.
- Creates a RAG agent using GPT-4o
- Incorporates a PDF-based knowledge base
- Uses LanceDB as the vector database for efficient similarity search
- Includes web search capability through DuckDuckGo
- Provides a playground interface for easy interaction
- Clone the GitHub repository
git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
cd awesome-llm-apps/rag_tutorials/agentic_rag
- Install the required dependencies:
pip install -r requirements.txt
- Get your OpenAI API Key
- Sign up for an OpenAI account (or the LLM provider of your choice) and obtain your API key.
- Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY='your-api-key-here'
- Run the AI RAG Agent
python3 rag_agent.py
- Open your web browser and navigate to the URL provided in the console output to interact with the RAG agent through the playground interface.
- Knowledge Base Creation: The script creates a knowledge base from a PDF file hosted online.
- Vector Database Setup: LanceDB is used as the vector database for efficient similarity search within the knowledge base.
- Agent Configuration: An AI agent is created using GPT-4o as the underlying model, with the PDF knowledge base and DuckDuckGo search tool.
- Playground Setup: A playground interface is set up for easy interaction with the RAG agent.