refactor: Update rag_reasoning_agent to use Google Gemini and enhance knowledge management

- Replaced Claude model with Gemini for improved language processing.
- Updated knowledge management by replacing UrlKnowledge with Knowledge class.
- Enhanced session state handling to prevent duplicate URL loading.
- Adjusted README to reflect changes in API key requirements and default knowledge sources.
- Updated requirements.txt to specify a minimum version for the 'agno' package.
This commit is contained in:
Shubhamsaboo
2025-11-09 12:06:51 -08:00
parent 5685c508fc
commit 7c532cd8d6
3 changed files with 90 additions and 64 deletions

View File

@@ -1,13 +1,14 @@
# 🧐 Agentic RAG with Reasoning
A sophisticated RAG system that demonstrates an AI agent's step-by-step reasoning process using Agno, Claude and OpenAI. This implementation allows users to upload documents, add web sources, ask questions, and observe the agent's thought process in real-time.
A sophisticated RAG system that demonstrates an AI agent's step-by-step reasoning process using Agno, Gemini and OpenAI. This implementation allows users to add web sources, ask questions, and observe the agent's thought process in real-time with reasoning capabilities.
## Features
1. Interactive Knowledge Base Management
- Upload documents to expand the knowledge base
- Add URLs dynamically for web content
- Default knowledge source: MCP vs A2A Protocol article
- Persistent vector database storage using LanceDB
- Session state tracking prevents duplicate URL loading
2. Transparent Reasoning Process
@@ -23,24 +24,25 @@ A sophisticated RAG system that demonstrates an AI agent's step-by-step reasonin
## Agent Configuration
- Claude 3.5 Sonnet for language processing
- Gemini 2.5 Flash for language processing
- OpenAI embedding model for vector search
- ReasoningTools for step-by-step analysis
- Customizable agent instructions
- Default knowledge source: MCP vs A2A Protocol article
## Prerequisites
You'll need the following API keys:
1. Anthropic API Key
1. Google API Key
- Sign up at console.anthropic.com
- Sign up at [aistudio.google.com](https://aistudio.google.com/apikey)
- Navigate to API Keys section
- Create a new API key
2. OpenAI API Key
- Sign up at platform.openai.com
- Sign up at [platform.openai.com](https://platform.openai.com/)
- Navigate to API Keys section
- Generate a new API key
@@ -64,35 +66,40 @@ You'll need the following API keys:
4. **Configure API Keys:**
- Enter your Anthropic API key in the first field
- Enter your Google API key in the first field
- Enter your OpenAI API key in the second field
- Both keys are required for the app to function
5. **Use the Application:**
- Default Knowledge Source: The app comes pre-loaded with the MCP vs A2A Protocol article
- Add Knowledge Sources: Use the sidebar to add URLs to your knowledge base
- Suggested Prompts: Click the prompt buttons (What is MCP?, MCP vs A2A, Agent Communication) for quick questions
- Ask Questions: Enter queries in the main input field
- View Reasoning: Watch the agent's thought process unfold in real-time
- Get Answers: Receive comprehensive responses with source citations
- View Reasoning: Watch the agent's thought process unfold in real-time in the left panel
- Get Answers: Receive comprehensive responses with source citations in the right panel
## How It Works
The application uses a sophisticated RAG pipeline:
The application uses a sophisticated RAG pipeline with Agno v2.0:
### Knowledge Base Setup
- Documents are loaded from URLs using WebBaseLoader
- Text is chunked and embedded using OpenAI's embedding model
- Documents are loaded from URLs using Agno's Knowledge class
- Text is automatically chunked and embedded using OpenAI's embedding model
- Vectors are stored in LanceDB for efficient retrieval
- Vector search enables semantic matching for relevant information
- URLs are tracked in session state to prevent duplicate loading
### Agent Processing
- User queries trigger the agent's reasoning process
- ReasoningTools help the agent think step-by-step
- The agent searches the knowledge base for relevant information
- Claude 4 Sonnet generates comprehensive answers with citations
- Gemini 2.5 Flash generates comprehensive answers with citations
- Streaming events provide real-time updates on reasoning and content
### UI Flow
- Enter API keys → Add knowledge sources → Ask questions
- Reasoning process and answer generation displayed side-by-side
- Sources cited for transparency and verification
- Enter API keys → Knowledge base loads with default MCP vs A2A article → Use suggested prompts or ask custom questions
- Reasoning process displayed in left panel, answer generation in right panel
- Sources cited for transparency and verification
- All events streamed in real-time for better user experience