| name | Multimodal RAG Application | |||||||
|---|---|---|---|---|---|---|---|---|
| description | Multimodal Retrieval-Augmented Generation over PDFs, audio, and web notes, with a verifier-gated multi-agent chat loop deployed on Azure Container Apps. | |||||||
| languages |
|
|||||||
| products |
|
|||||||
| page_type | sample | |||||||
| urlFragment | multimodal-rag-application |
A Retrieval-Augmented Generation system for asking verifiable questions over private multimodal corpora - PDFs, audio, and web notes. An async Quart backend ingests source material into vector, graph, and citation stores, then answers questions through a streaming multi-agent loop (Router -> Retriever -> Answerer -> Verifier) in which a Verifier agent checks each claim against the retrieved evidence. Two UIs sit on top: a React 19 single-page app and a Chainlit tutor chat. Infrastructure is Bicep deployed with the Azure Developer CLI.
This README is updated at the end of each working session and verified by the automated Monday documentation workflow.
Use it as a reference for building grounded chat over your own documents when you need answers traceable to a source page or timestamp, a per-claim verification gate instead of raw LLM output, or a working example of multi-agent orchestration (flat and hierarchical LangGraph variants) on Azure.
- Document ingestion pipeline -
app/backend/prepdocs.py(run viascripts/prepdocs.sh) drivesprepdocslib/: parses PDFs with Azure Document Intelligence (PyPDF fallback), plus text and YouTube transcripts; splits sentence-aware; embeds with Azure OpenAI. Output: chunk + embedding records in an Azure AI Search index, or in a Cosmos DB NoSQL vector container whenDOCUMENT_RETRIEVER=cosmos; source files pushed to an OpenAIfile_searchvector store for citations; raw files uploaded to Blob Storage. - Microsoft Learn ingestion -
prepdocs.py --source learnwithprepdocslib/learnstrategy.pyandscripts/fetch_learn.pypulls Learn pages listed underdata/learn/into the same index. - GraphRAG knowledge graph -
app/backend/graphrag/extracts entities, writes nodes and edges to Cosmos DB for Apache Gremlin, and maintains community summaries; seeded byscripts/seed_graph.py. Output: a queryable knowledge graph used by the Retriever'sgraph_search. - Multi-agent chat -
POST /chatstreams SSE fromapproaches/multiagent_approach.py: Router classifies the question, Retriever runs vector and graph search in parallel, Answerer streams tokens with citations, Verifier grades each claim, FollowUps suggests next questions. Output: SSE eventstoken,citation,claim,verdict,followups,cost. - Hierarchical agent teams (opt-in) -
approaches/hierarchical_multiagent_approach.py+agents/hierarchical_graph.pyrun a LangGraph coordinator over retrieval, answer/verify, and SQL teams behindUSE_HIERARCHICAL_AGENTS=true, emitting the same SSE schema and falling back to the flat loop if LangGraph is unavailable. - SchemaFlow SQL planner -
POST /sql/planruns Parse -> Impact -> Plan -> SQL agents (approaches/sql_schemaflow_approach.py, prompts inapproaches/prompts/sql/). Output: a typed change-plan JSON. - Voice transcription - the
/voice/streamWebSocket (voice/voice_live.py) bridges browser PCM16 audio to the Azure AI Speech Voice Live API in transcription-only mode;/voice/clean(voice/transcript_cleaner.py) does best-effort LLM cleanup. Output: interim and final transcript JSON, plus a cleaned transcript. - Chainlit tutor UI -
app/backend/chainlit_app.pyis a chat UI over the ingested notes withsearch_notes/get_documenttools (agents/tutor_agent.py,agents/notes_search_tool.py) and Redis-backed conversation memory. Output: answers with a per-turn Sources block. - React frontend - React 19 + Vite + Fluent UI (
app/frontend/), with pages for chat, papers, voice, SQL, and portfolio, and components for citations, verifier badges, graph view, PDF viewer, and voice recording. Built into the backend container image and served by Quart. - Safety and cost controls - content-safety screening and PII redaction modules (
safety/), a Redis semantic cache, per-IP rate limiting, and a per-session token cost meter surfaced in thecostSSE event. - Tracing - OpenTelemetry to Application Insights (
tracing/otel.py) and LangSmith spans (tracing/langsmith.py). - Evals and tests -
evals/(answer eval, ground-truth generation, Verifier eval oververifier_golden.jsonl, adversarial safety eval) writing toevals/results/; agent eval inapp/backend/agents/run_eval.py; pytest suite intests/plus a Playwright e2e test.
Documented in the prep docs but not working today:
- Azure Functions cloud-ingestion service: skill code exists under
app/functions/, but the service is deferred (seeazure.yaml) andprepdocslib/cloudingestionstrategy.py/integratedvectorizerstrategy.pyare log-only stubs. - PostgreSQL Flexible Server (pgvector) secondary analytics tier: no code yet.
- The
docs/guide set referenced by older docs:docs/currently holds a notebook and images only. - Frontend locales beyond English.
Knowledge workers (clinicians, researchers, analysts) who consume long PDFs and recorded discussions and need answers traceable to a page or utterance; and engineers studying RAG, GraphRAG, and multi-agent patterns on Azure.
Portfolio / reference implementation. The demos cover scientific-paper Q&A, voice transcription, a mixed-corpus chatbot, and SQL change planning over a sample clinical-style warehouse.
React SPA (Vite) Chainlit tutor UI
| HTTPS / SSE / WebSocket |
v v
+---------------------------------------------------------+
| Quart backend (Gunicorn, Azure Container Apps) |
| /chat, /chat/nonstream multi-agent SSE loop |
| /sql/plan SchemaFlow agents |
| /voice/stream (WS) Voice Live transcription |
| /voice/clean LLM transcript cleanup |
| /papers/upload /content /feedback /config |
+---------------------------------------------------------+
| | | |
v v v v
Azure OpenAI Cosmos DB Azure AI Blob
/ Foundry (NoSQL vectors Search Storage
(chat, embed) + chat history (index) (raw files)
+ Gremlin graph)
| |
Redis (notes index, semantic OpenAI file_search
cache, conversation memory) vector store (citations)
Observability: Application Insights (OpenTelemetry) + LangSmith
Ingestion path:
scripts/prepdocs.sh -> prepdocs.py -> prepdocslib
parse (Document Intelligence / PyPDF / YouTube / Learn)
-> sentence-aware split -> embed
-> AI Search index OR Cosmos vector container
-> OpenAI file_search vector store
-> raw files to Blob Storage
graphrag/ -> Cosmos Gremlin nodes/edges + community summaries
A question posted to /chat is safety-screened, routed, answered from parallel vector + graph retrieval, and verified claim by claim before follow-ups and cost are emitted on the same SSE stream. Ingestion is a separate offline path run from the CLI (and automatically as the azd postprovision hook).
| Artifact | Where it lands |
|---|---|
| Chunk + embedding records | Azure AI Search index (AZURE_SEARCH_INDEX) or Cosmos NoSQL documents container |
| Citation store files | OpenAI file_search vector store |
| Knowledge graph nodes/edges + community summaries | Cosmos DB for Apache Gremlin |
| Raw PDFs / audio / uploads | Azure Blob Storage |
| Chat responses | SSE events (token, citation, claim, verdict, followups, cost) from /chat |
| Transcripts | JSON over the /voice/stream WebSocket; cleaned text from /voice/clean |
| SQL change plans | JSON from /sql/plan |
| Eval results | evals/results/ |
| Frontend build | app/frontend/build/, copied to /app/static in the container image |
- Azure subscription with access to Azure OpenAI / AI Foundry
- Azure Developer CLI (
azd) and Azure CLI (az) - Python 3.11+, Node.js, and (for image builds) Docker
Azure OpenAI / AI Foundry, Azure AI Search, Azure Document Intelligence, Azure AI Speech (Voice Live API), Azure Cosmos DB (NoSQL + Gremlin), Azure Blob Storage, Azure Container Apps, Azure Container Registry, Application Insights / Log Analytics, Azure Key Vault. External: OpenAI Responses file_search, LangSmith, Redis.
None beyond an Azure subscription. Optional external services (OpenAI API for file_search, LangSmith) need their own API keys.
Deployed resources bill immediately: Azure OpenAI tokens, AI Search, Cosmos DB RU/s (Gremlin throughput especially during bulk graph indexing), Container Apps, storage, and Application Insights ingestion. Tear down with azd down when finished.
Note: infra/main.bicep is a Stage 1 deployment that provisions compute and observability (Log Analytics, Application Insights, ACR, Container Apps environment, backend app, RBAC) and references pre-existing Foundry, Cosmos DB, Storage, and Key Vault resources by name via parameters. Adjust those parameters to point at your own resources before deploying.
# Azure
azd auth login
azd env new <env-name>
azd up # preprovision: scripts/auth_init.sh; postprovision: scripts/prepdocs.sh
# Ingestion (also runs as the postprovision hook)
./scripts/prepdocs.sh # data/papers/ into the vector store
./scripts/prepdocs.sh --removeall
./scripts/prepdocs.sh --source learn # Microsoft Learn pages
python scripts/seed_graph.py # seed the Gremlin graph
# Local dev (backend :50505 + frontend :5173)
./app/start.sh
# Chainlit tutor UI
cd app/backend && chainlit run chainlit_app.py --host 0.0.0.0 --port 8000pytest # unit + integration (mocked Azure clients)
npm run test:e2e # frontend build + Playwright e2e
ruff check . && ruff format . # lint
cd app/frontend && npm run lint
locust -f locustfile.py --host http://localhost:50505 # load test
# Evals (separate venv; deps conflict with the backend)
python -m venv .evalenv && source .evalenv/bin/activate
pip install -r evals/requirements.txt
python evals/evaluate.py
python evals/verifier_eval.py
python evals/safety_evaluation.py --target_url http://localhost:50505/chatFor a deployed app, open the Container App URL and ask a question on the chat page; verify SSE events arrive and citations resolve.
This repository keeps its own documentation current on a fixed loop:
- End of every working session: CLAUDE.md, this README, the requirements manifests (
app/backend/requirements.inand.txt,evals/requirements.txt,app/functions/requirements.txt), and any affected prep docs are updated to match reality. - Every Monday at 09:00 UTC: the GitHub Actions workflow
update-claude-md.ymlruns Claude Code with the prompt inclaude-md-review-prompt.md. It verifies CLAUDE.md and this README against the code, checks the requirements manifests (app/backend/requirements.inand.txt,evals/requirements.txt,app/functions/requirements.txt) against actual imports, regenerates the prioritized TODO.md, and opens a pull request with any corrections. It can also be triggered manually from the Actions tab. - The workflow requires the
CLAUDE_CODE_OAUTH_TOKENrepository secret (generate withclaude setup-token).
- PRODUCT.md - what the product does and why
- ARCHITECTURE.md - components and data flow in detail
- CONTRIBUTING.md - dev setup and conventions
- CLAUDE.md - operating manual for coding agents
- AGENTS.md - agent roster and specs
- TODO.md - machine-refreshed weekly backlog
- Azure-Samples/azure-search-openai-demo - the upstream pattern this app extends
MIT. See LICENSE.
This is sample / portfolio code provided as-is, without warranty of any kind. You are responsible for the cost of any Azure or third-party resources you deploy. The repository contains no PHI or sensitive data; sample corpora under data/ are public material. Do not commit secrets or .env files.