Skip to content

sanjaypatel180621/Azure-RAG-Chat-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure-RAG-Chat-Python - A RAG Chat with Azure-AI Search OpenAI & Python

A sample application demonstrating Retrieval Augmented Generation (RAG) with Azure AI Search and Azure OpenAI Service. This project creates a ChatGPT-like experience over your own documents, combining powerful GPT models with enterprise-grade search for knowledge retrieval.

Features:

  • Multi-turn chat interface with citations and reasoning steps
  • Document indexing and retrieval via Azure AI Search (supports PDFs, docs, cloud data)
  • Configurable UI for experimenting with prompts and behaviors
  • Optional multimodal support for image-heavy documents
  • Speech input/output for accessibility
  • Microsoft Entra integration for secure login and data access
  • Performance monitoring with Application Insights

Chat screen

Architecture Diagram

Architecture Diagram

Azure account requirements

IMPORTANT: In order to deploy and run this example, you'll need:

Cost estimation

Pricing varies per region and usage, so it isn't possible to predict exact costs for your usage. However, you can try the Azure pricing calculator for the resources below.

  • Azure Container Apps: Default host for app deployment as of 10/28/2024. See more details in the ACA deployment guide. Consumption plan with 1 CPU core, 2 GB RAM, minimum of 0 replicas. Pricing with Pay-as-You-Go. Pricing
  • Azure Container Registry: Basic tier. Pricing
  • Azure App Service: Only provisioned if you deploy to Azure App Service following the App Service deployment guide. Basic Tier with 1 CPU core, 1.75 GB RAM. Pricing per hour. Pricing
  • Azure OpenAI: Standard tier, GPT and Ada models. Pricing per 1K tokens used, and at least 1K tokens are used per question. Pricing
  • Azure AI Document Intelligence: SO (Standard) tier using pre-built layout. Pricing per document page, sample documents have 261 pages total. Pricing
  • Azure AI Search: Basic tier, 1 replica, free level of semantic search. Pricing per hour. Pricing
  • Azure Blob Storage: Standard tier with ZRS (Zone-redundant storage). Pricing per storage and read operations. Pricing
  • Azure Cosmos DB: Only provisioned if you enabled chat history with Cosmos DB. Serverless tier. Pricing per request unit and storage. Pricing
  • Azure AI Vision: Only provisioned if you enabled multimodal approach. Pricing per 1K transactions. Pricing
  • Azure AI Content Understanding: Only provisioned if you enabled media description. Pricing per 1K images. Pricing
  • Azure Monitor: Pay-as-you-go tier. Costs based on data ingested. Pricing

🚀 Quickstart

This project demonstrates a Retrieval Augmented Generation (RAG) chat experience using Azure AI Search and Azure OpenAI Service with Python. You can run it in three ways: GitHub Codespaces, VS Code Dev Containers, or your local environment.

1. Run in GitHub Codespaces (Cloud-based)

The fastest way to try this repo without installing anything locally.

  1. Click Open in GitHub Codespaces from the repo.
  2. Wait for the codespace to initialize (may take several minutes).
  3. Once VS Code opens in your browser, open a terminal window.

2. Run in VS Code Dev Containers (Local with Docker)

A reproducible local environment using Docker.

  1. Install Docker Desktop (start it after installation).
  2. Install the Dev Containers extension in VS Code.
  3. Open the project in VS Code → select Open in Dev Container.
  4. Wait for the container to build (may take several minutes).
  5. Once the project files appear, open a terminal window.

3. Run in Local Environment

For full control and direct deployment to Azure.

Prerequisites

  • Azure Developer CLI
  • Python 3.10–3.14 (ensure python --version works)
  • Node.js 20+
  • Git
  • PowerShell 7+ (Windows only, ensure pwsh.exe runs)

Setup

# Create a new folder and switch to it
mkdir my-rag-chat && cd my-rag-chat

# Initialize the project
azd init -t azure-search-openai-demo

4. Deploying to Azure

This provisions resources and deploys the app.

# Login to Azure
azd auth login
# (Codespaces users may need: azd auth login --use-device-code)

# Create a new environment
azd env new

# Deploy resources and app
azd up
  • ⚠️ Note: Resources incur costs immediately (especially AI Search). Run azd down to delete resources when finished.
  • After deployment, a URL will be printed. Open it in your browser to use the app. Deployment may take 5–10 minutes after SUCCESS.

5. Redeploying

  • If only app code changed:
    azd deploy
  • If infra files changed (infra/ or azure.yaml):
    azd up

6. Running Locally

You can run the dev server after a successful azd up.

# Login if needed
azd auth login

# Start the server
# Windows
./app/start.ps1

# Linux/Mac
./app/start.sh

Or run the VS Code Task: Start App. Access locally at: http://127.0.0.1:50505

7. Using the App

  • Ask questions about the sample company data (benefits, policies, roles).
  • Try multi-turn conversations, clarifications, and follow-ups.
  • Explore citations and sources.
  • Use Settings to tweak prompts and behaviors.

8. Clean Up

To delete all Azure resources created: Confirm with y when prompted. This deletes the resource group and all resources.

azd down

About

A sample application demonstrating Retrieval Augmented Generation (RAG) with Azure AI Search and Azure OpenAI Service. This project creates a ChatGPT-like experience over your own documents, combining powerful GPT models with enterprise-grade search for knowledge retrieval.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors