A sophisticated HR assistant powered by LangChain, LangGraph, and multiple LLM models. This project demonstrates the implementation of a conversational AI system that can help with HR-related queries and team building recommendations.
This project implements an intelligent HR assistant that can:
- Process natural language queries about employees and team building
- Access and search through employee records
- Provide recommendations for team composition
- Maintain conversation context across multiple interactions
- TypeScript/Node.js - Main development language and runtime
- Express.js - Web server framework
- MongoDB Atlas - Database with vector search capabilities
- LangChain - LLM framework for building AI applications
- LangGraph - Framework for building stateful AI agent workflows
- Claude 3 Sonnet (Anthropic) - Primary model for agent reasoning and responses
- Mistral 7B Instruct - Used via OpenRouter for synthetic data generation
- OpenAI - Used for embeddings in vector search
@langchain/langgraph
- For building stateful agent workflows@langchain/anthropic
- Claude integration@langchain/openai
- OpenAI integration@langchain/mongodb
- MongoDB vector store integration@langchain/langgraph-checkpoint-mongodb
- State persistence for conversationsmongodb
- MongoDB clientzod
- Runtime type validationexpress
- Web serverdotenv
- Environment variable management
langraph-agent/
├── index.ts # Main Express server setup
├── agent.ts # LangGraph agent implementation
├── seed-database.ts # Database seeding script
├── .env # Environment variables
└── package.json # Project dependencies
- index.ts: Entry point that sets up the Express server and API endpoints for chat interactions
- agent.ts: Implements the LangGraph agent with tool definitions and conversation workflow
- seed-database.ts: Generates synthetic employee data using Mistral AI and seeds the MongoDB database
- Stateful Conversations: Uses LangGraph and MongoDB to maintain conversation context
- Vector Search: Implements semantic search over employee records using MongoDB Atlas Vector Search
- Rate Limiting: Implements intelligent rate limiting with exponential backoff
- Tool-based Architecture: Modular design with specialized tools for different operations
- Type Safety: Comprehensive TypeScript types and Zod schemas for runtime validation
This system is designed to assist HR professionals and team leaders with:
- Team building and composition
- Employee information retrieval
- Talent gap analysis
- Resource allocation
- Employee data management
The combination of multiple LLM models allows for:
- Cost-effective synthetic data generation (Mistral)
- High-quality reasoning and responses (Claude)
- Efficient semantic search capabilities (OpenAI embeddings)
The project requires several API keys and configuration values:
-
OPENAI_API_KEY
- For embeddings -
OPENROUTER_API_KEY
- For accessing Mistral AI -
ANTHROPIC_API_KEY
- For Claude access -
MONGODB_ATLAS_URI
- MongoDB connection string -
LANGSMITH_API_KEY
- For LangSmith tracing (optional) -
Start a new conversation:
curl -X POST -H "Content-Type: application/json" -d '{"message": "Your message here"}' http://localhost:3000/chat
- Continue Conversation:
curl -X POST -H "Content-Type: application/json" -d '{"message": "Your follow-up message"}' http://localhost:3000/chat/{threadId}
GET /
- Health check endpointPOST /chat
- Start a new conversationPOST /chat/:threadId
- Continue an existing conversation
- Clone the repository
- Install dependencies:
npm install
- Set up environment variables in
.env
- Seed the database:
ts-node seed-database.ts
- Start the server:
ts-node index.ts
The server will start on port 3000 by default.