This sample demonstrates how to build an intelligent agent using TypeScript, LangChain.js, LangGraph, Azure OpenAI, and Azure AI Search to create a Retrieval Augmented Generation (RAG) application.
The sample includes an HR document query system that allows users to ask questions about employee benefits and company policies, with the agent retrieving relevant information from PDF documents.
- TypeScript-based LangChain.js implementation
- LangGraph agent architecture for dynamic orchestration of AI components
- Integration with Azure OpenAI for embeddings and completions
- Vector search with Azure AI Search
- FastAPI server for RESTful API access
- Docker support for containerized deployment
- Environment variable management
- PDF document processing and vector storage
The repository is organized as a monorepo with the following packages:
- langgraph-agent: Core agent implementation using LangGraph
- server-api: FastAPI server exposing the agent functionality
New to Azure, LangChain, monorepos, or cloud deployment? Check out our comprehensive documentation in the docs directory:
- 📚 Getting Started - Quick setup and deployment guide
- 💻 Local Development - Monorepo structure and npm workspaces
- 🏗️ Infrastructure & Deployment - Azure Developer CLI and Bicep
- 🧪 Testing with HTTP Files - API testing in VS Code
- 🔐 Azure Identity Authentication - Passwordless auth
- 🚀 Azure Container Apps - Container deployment and ingress
- 🔍 Azure AI Search Vector Store - Vector database and indexing
See the documentation index for the complete guide.
- Node.js (v18 or later)
- npm
- Azure subscription
- Azure OpenAI service instance with deployed models
- Azure AI Search service instance
git clone https://github.com/Azure-Samples/azure-typescript-langchainjs.git
cd azure-typescript-langchainjsCreate the following resources:
- Azure AI Search
- Azure OpenAI
- LLM model for chat completion
- Embedding model to get embeddings for PDF files
- Azure Container Apps
- Azure Container registry
Use Azure CLI for authentication and let Azure Developer CLI know that.
az login
azd config set auth.useAzCliAuth trueBegin deployment
azd upFor the environment name, keep it short such as 7 lowercase letters: lang-exam.
Process takes up to 15 minutes:
- Build Dockerfile
- Create resources
- Load Azure AI Search index with embeddings
The API server exposes the following endpoints:
POST /answer: Submit a question to the agent
Example request:
curl -X POST http://localhost:3000/answer \
-H "Content-Type: application/json" \
-d '{"question": "What are the standard benefit options?"}' The agent can answer questions about the HR documents, such as:
- "What are the standard benefit options?"
- "Tell me about dental coverage in the Health Plus plan"
- "What does the employee handbook say about vacation time?"
This project is licensed under the ISC License - see the LICENSE.md file for details.
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
