Azure-Samples/serverless-chat-langchainjs
Build your own serverless AI Chat with Retrieval-Augmented-Generation using LangChain.js, TypeScript and Azure
What it solves
This project provides a reference implementation for building a serverless AI chatbot that can answer questions based on specific enterprise documents. It simplifies the process of implementing Retrieval-Augmented Generation (RAG) using JavaScript/TypeScript, allowing developers to create scalable, cost-effective chat experiences without managing servers.
How it works
The application uses a serverless architecture consisting of several integrated components:
- Frontend: A chat web component built with Lit, hosted on Azure Static Web Apps.
- Backend API: A serverless API built with Azure Functions and LangChain.js to handle document ingestion and query generation.
- Vector Database: Azure Cosmos DB for NoSQL stores the extracted text and generated vectors for efficient retrieval.
- Storage: Azure Blob Storage holds the source documents.
- Local Option: The system can be run entirely locally using Ollama for LLM and embedding models to avoid cloud costs during development.
Who it’s for
Developers looking to build RAG-based AI applications using the JavaScript ecosystem and Azure's serverless infrastructure, or those wanting a starting point for creating enterprise-grade chatbots.
Highlights
- Serverless Deployment: Fully serverless stack using Azure Functions and Static Web Apps.
- RAG Implementation: Integrated pipeline for document ingestion and retrieval using LangChain.js.
- Histry Management: Maintains personal chat session history for users.
- Flexible Model Hosting: Supports both Azure OpenAI and local models via Ollama.