A retrieval-augmented generation (RAG) chatbot that answers employee questions about a company's HR policy document. Built with LangChain, Groq-hosted LLMs, Jina embeddings, and a Qdrant Cloud vector store, with input/output safety guardrails and LangSmith tracing.
- Ingest —
hr_assistant/document_loader.pyloadsdata/hr_policy.txt, andhr_assistant/splitter.pysplits it into chunks (CHUNK_SIZE=500,CHUNK_OVERLAP=60). - Embed & store —
hr_assistant/embeddings.pycreates embeddings with Jina (jina-embeddings-v2-base-en), andhr_assistant/vector_store.pyuploads/loads them from a Qdrant Cloud collection (reused on subsequent runs instead of re-embedding). - Retrieve —
hr_assistant/tools.pywraps the vector store retriever (top-k = 3) as asearch_hr_policytool. - Agent —
hr_assistant/agent.pybuilds a LangChain agent (openai/gpt-oss-20bvia Groq) that calls the search tool to ground its answers. - Guardrails —
hr_assistant/guardrails.pyruns a separate Groq safety model (openai/gpt-oss-safeguard-20b) to screen both the incoming question (prompt injection, requests for other employees' data) and the outgoing answer (PII leaks, unauthorized promises, suspicious links) before it reaches the user. - Everything is wired together in
hr_assistant/pipeline.py(build_hr_assistant()/ask()), used by both entry points below.
python main.py— CLI demo that asks a few sample HR questions.streamlit run app.py— interactive chat UI.rag.ipynb— notebook version for experimentation.
hr_assistant/
config.py settings, env vars, system prompt
document_loader.py load the HR policy text file
splitter.py chunk the document
embeddings.py Jina embeddings model
vector_store.py Qdrant Cloud build/load/retriever
tools.py search tool for the agent
llm.py Groq LLM setup
agent.py LangChain agent construction
guardrails.py input/output safety checks
pipeline.py wires everything together (build_hr_assistant, ask)
logger.py file logging (logs/)
tracing.py LangSmith tracing check
data/hr_policy.txt source HR policy document
docs/ notes on logging, LangSmith, Qdrant Cloud migration, guardrail attack testing
NOTES/ reference PDFs
- Install uv:
pip install uv - Create and activate a virtual environment:
uv venv ragenv ragenv\Scripts\activate - Install dependencies:
uv pip install -r requirements.txt - Create a
.envfile with:GROQ_API_KEY=... JINA_API_KEY=... QDRANT_URL=... QDRANT_API_KEY=... QDRANT_COLLECTION_NAME=hr_policy LANGSMITH_TRACING=false LANGSMITH_ENDPOINT=... LANGSMITH_API_KEY=... LANGSMITH_PROJECT=...
git add .
git commit -m "Some message"
git push