A demonstration project showcasing Retrieval-Augmented Generation (RAG) architecture using Azure OpenAI, Azure AI Search, and Microsoft's Semantic Kernel framework. This project provides a template for building AI applications that combine the power of large language models with your own data.
- Overview
- Architecture
- Key Components
- Features
- Getting Started
- Project Structure
- Technical Highlights
- Future Enhancements
- License
The AI RAG Chat Bot is a demonstration project that illustrates how to implement Retrieval-Augmented Generation (RAG) architecture using Azure services. RAG combines the capabilities of large language models with custom knowledge bases, allowing the AI to reference specific information when generating responses.
This solution is designed as a reference implementation and teaching tool for developers looking to build similar AI applications.
The solution follows a modular, multi-layered architecture:
- Knowledge Base Layer: Azure AI Search index with vector embeddings
- AI Services Layer: Reusable services for embeddings, search, and AI orchestration
- API Layer: Azure Functions exposing chat endpoints
- Data Preparation: Utilities for preparing and uploading documents to the knowledge base
The solution consists of three main projects:
1. AIServices
A reusable library providing core RAG functionality:
- Vector embedding generation via Azure OpenAI
- Hybrid search (keyword + vector) with Azure AI Search
- Context retrieval and citation tracking
- AI orchestration via Semantic Kernel
2. ChatBotApi
An Azure Functions API exposing:
- Standard chat completion endpoint
- RAG-enhanced chat completion with citations
- Health check endpoint
A utility for:
- Processing and embedding documents
- Creating the knowledge base in Azure AI Search
- Maintaining the vector index
- Hybrid Search: Combines traditional keyword search with vector similarity for improved accuracy
- Context-Aware Responses: Enhances AI responses with relevant information from your data
- Citation Tracking: Provides references to the source documents used in responses
- Generic Design: The core library supports custom document types for various use cases
- Modular Architecture: Easily adaptable components for integration into other applications
- Azure subscription
- Azure OpenAI service
- Azure AI Search service with vector search capability
- .NET 8 SDK
All projects share a similar configuration structure in local.settings.json:
{
"Values": {
"OPENAI_ENDPOINT": "https://your-openai-service.openai.azure.com/",
"OPENAI_API_KEY": "your-openai-api-key",
"OPENAI_EMBEDDING_DEPLOYMENT": "text-embedding-ada-002",
"OPENAI_CHAT_DEPLOYMENT": "gpt-4",
"AZURE_SEARCH_ENDPOINT": "https://your-search-service.search.windows.net",
"AZURE_SEARCH_INDEX": "your-index-name",
"AZURE_SEARCH_API_KEY": "your-search-api-key"
}
}-
Clone the repository
git clone https://github.com/yourusername/AI_RAG_Chat_Bot.git cd AI_RAG_Chat_Bot -
Update the configuration in each project's
local.settings.json -
Prepare your knowledge base
cd backend/UploadProjects dotnet run -
Start the API
cd ../ChatBotApi func start -
Test the API using the examples provided in the ChatBotApi README
backend/
├── AIRAGChatBot.sln # Solution file
├── AIServices/ # Core RAG library
│ ├── Model/ # Document models
│ └── Service/ # Service implementations
│ └── Interface/ # Service interfaces
├── ChatBotApi/ # Azure Functions API
│ ├── Functions/ # API endpoints
│ └── Model/ # API models
└── UploadProjects/ # Knowledge base utility
├── Model/ # Document models
└── Service/ # Service implementations
The solution leverages Microsoft's Semantic Kernel framework to orchestrate AI interactions:
- Simplified AI Orchestration: Semantic Kernel abstracts the complexity of working with multiple Azure AI services
- Prompt Management: Consistent handling of system and user prompts
- Context Awareness: Seamless integration of retrieved context into the AI's conversation flow
- Extensibility: The Kernel-based design allows for easy addition of plugins and skills
- Hybrid Search: Combines BM25 text search with vector similarity for more accurate retrieval
- Citation Management: Tracks and returns source documents for verification and transparency
- Generic Document Support: Core services use generics to support different document types
- Serverless Design: Azure Functions provides scalable, cost-effective API hosting
- Azure AI Services: Leverages Azure OpenAI and Azure AI Search capabilities
- Configuration Management: Consistent environment variable approach across components
This demo project can be extended with:
- Conversation History: Managing context across multiple messages
- Streaming Responses: Real-time token streaming for a more interactive experience
- Advanced Search Features: Multi-vector search, reranking, and metadata filtering
- User Feedback Loop: Collecting feedback to improve future responses
- Web UI: A frontend interface for interacting with the chatbot
See the individual component READMEs for more detailed enhancement ideas.
This project is licensed under the MIT License - see the LICENSE file for details.
