A modernized rewrite of the original HR chatbot using an agent loop via OpenAI Responses API directly — no LangChain, no Pinecone. Surfaces real model reasoning via gpt-5.2's reasoning summaries and demonstrates the Responses API's native function calling and file_search built-in tool.
| Original (2023) | v2 (2026) | |
|---|---|---|
| Framework | LangChain 0.0.220 |
None — pure OpenAI SDK |
| Model | gpt-3.5-turbo |
gpt-5.2 |
| "Thought" panel | LangChain verbose=True scratchpad text |
Real reasoning summaries from the model |
| RAG | Pinecone vector DB + manual embeddings | OpenAI file_search built-in tool |
| Employee data tool | PythonAstREPLTool (arbitrary code exec) |
Typed function tools |
| Frontend | streamlit-chat (deprecated) |
Native st.chat_message / st.status |
| State | Full message replay each turn | previous_response_id (server-side) |
- OpenAI Python SDK
>=1.55 - Streamlit
>=1.40 - pandas — employee data
- python-dotenv
cd v2
python -m venv .venvActivate:
- macOS / Linux:
source .venv/bin/activate - Windows (CMD):
.venv\Scripts\activate.bat - Windows (PowerShell):
.venv\Scripts\Activate.ps1
pip install -r requirements.txtPick the path that matches where your LLM is hosted — Path A for OpenAI, Path B for Azure OpenAI.
cp .env.example .envFill in OPENAI_API_KEY. Leave OPENAI_VECTOR_STORE_ID blank for now.
python ingest_policy.pyCopy the printed vs_… ID into your .env as OPENAI_VECTOR_STORE_ID.
streamlit run app.pyRequirements:
- A
gpt-5.ndeployment (or any reasoning model that supports the Responses API)
cp .env.example .envSet BACKEND=azure and fill in all AZURE_OPENAI_* variables. Leave AZURE_OPENAI_VECTOR_STORE_ID blank for now.
python ingest_policy.pyCopy the printed vs_… ID into your .env as AZURE_OPENAI_VECTOR_STORE_ID.
streamlit run app.py| File | Purpose |
|---|---|
app.py |
Streamlit UI — renders reasoning panel, tool traces, final answer |
agent_loop.py |
Responses API streaming loop — dispatches tool calls, yields events |
tools.py |
Typed function tools + JSON schemas + dispatch table |
backend_local.py |
OpenAI client + config |
backend_azure.py |
AzureOpenAI client + config |
ingest_policy.py |
One-time script to create vector store and upload hr_policy.txt |
- "How many vacation leaves do I have left?"
- "What's the policy on unused vacation leave?"
- "If I encash 10 unused vacation days, how much will I be paid?"
- "Who are the direct reports of Joseph Santos?"
- "Can I apply for sick leave while on probation?"
