# Serverless AI Chat with RAG using LangChain.js

A sample serverless chat application with retrieval-augmented generation, built with LangChain.js, Azure Functions, Azure Static Web Apps and Azure Cosmos DB as the vector store.

This sample shows how to build a serverless AI chat application with retrieval-augmented generation using LangChain.js and Azure. A web app built with Lit and hosted on Azure Static Web Apps talks to a serverless API built with Azure Functions, which uses LangChain.js to ingest documents and generate responses; Azure Cosmos DB for NoSQL stores chat sessions, extracted document text and vectors, and Azure Blob Storage holds the source documents.

The bundled sample data describes a fictitious real-estate company's terms of service, privacy policy and support guide, so the chatbot can answer support questions about them out of the box, and can be replaced with a user's own documents. The application can also be tested locally at no cost using Ollama instead of a hosted model.

Website: https://github.com/Azure-Samples/serverless-chat-langchainjs
