Skip to content

Bhuvanakalaga/chatbot

Repository files navigation

HR Policy Assistant

A conversational HR chatbot built with Python, Streamlit, LangChain, FAISS, HuggingFace Embeddings, and Groq that answers employee HR questions using a company policy document via Retrieval-Augmented Generation (RAG).


Features

Feature Details
RAG Pipeline Chunks policy.txt → embeds with all-MiniLM-L6-v2 → stores in FAISS → retrieves top-k chunks
Native Tool Calling LLM automatically picks the right tool — no hardcoded routing
5 LangChain Tools search_policy, summarize_policy, list_policy_sections, create_hr_request, hr_contact
LLM llama-3.3-70b-versatile via Groq API
UI Clean Streamlit chat with chat history, tool badges, and a Clear Chat button

Project Structure

hr_assistant/
├── app.py                  # Streamlit chat UI
├── agent.py                # LangChain tool-calling agent (Groq LLM)
├── tools.py                # All 5 LangChain tools
├── retriever.py            # FAISS vector store loader and search function
├── prompts.py              # System prompt for the HR Assistant
├── create_vector_db.py     # One-time script to build the FAISS index
├── requirements.txt
├── .env                    # Your Groq API key goes here
│
└── data/
    ├── policy.txt          # HR policy document
    └── faiss_index/        # Generated by create_vector_db.py

Setup Instructions

1. Clone / copy the project

cd hr_assistant

2. Create and activate a virtual environment

python -m venv venv
source venv/bin/activate        # Mac/Linux
venv\Scripts\activate           # Windows

3. Install dependencies

pip install -r requirements.txt

4. Add your Groq API key

Open .env and replace the placeholder:

GROQ_API_KEY=your_actual_groq_api_key_here

Get a free key at https://console.groq.com.

5. Build the FAISS vector database

Run this once before starting the app:

python create_vector_db.py

This reads data/policy.txt, creates text chunks, generates embeddings, and saves the FAISS index to data/faiss_index/.

6. Start the Streamlit app

streamlit run app.py

Open http://localhost:8501 in your browser.


How It Works

User message
     │
     ▼
Streamlit UI (app.py)
     │
     ▼
Agent (agent.py)  ──  Groq LLM (llama-3.3-70b-versatile)
     │                        │
     │                 Decides which tool to call
     │
     ├── search_policy        →  FAISS similarity search (retriever.py)
     ├── summarize_policy     →  FAISS search + LLM summary
     ├── list_policy_sections →  Returns static list of HR topics
     ├── create_hr_request    →  Generates a support ticket
     └── hr_contact           →  Returns HR contact details
     │
     ▼
Final answer displayed in chat UI

Example Questions

Query Tool Invoked
"How many days of annual leave do I get?" search_policy
"Summarise the WFH policy" summarize_policy
"What HR topics are available?" list_policy_sections
"I want to report harassment by my manager" create_hr_request
"How do I contact HR?" hr_contact

Tech Stack

  • Python 3.10+
  • Streamlit – Chat UI
  • LangChain – Agent framework and tool calling
  • LangChain Groq – Groq LLM integration
  • FAISS – Vector similarity search
  • HuggingFace Embeddingssentence-transformers/all-MiniLM-L6-v2
  • Groq – Fast LLM inference (llama-3.3-70b-versatile)
  • python-dotenv – Environment variable management

Notes

  • No login or authentication is required.
  • No employee database is used.
  • All policy answers are grounded in data/policy.txt — the LLM never invents policies.
  • Re-run create_vector_db.py whenever policy.txt is updated.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages