Simple Support agent primarily using RAG with Vector DB consisting of a companies documention with a fallback to OpenAI GPT-3.5-Turbo for general question handling.
To enable Retrieval-Augmented Generation (RAG) we do the following:
- Convert Q&A documents into embeddings using OpenAI’s
text-embedding-ada-002model. - Store them in a Chroma vector store.
- At runtime, retrieve the most semantically similar Q&A using vector similarity search.
- If a strong match is found, use it directly. Otherwise, fall back to querying the OpenAI API.
This approach enables flexible, robust answers even for paraphrased questions.
This project allows you to:
- Load Q&A JSON documents from the
docs/folder - Embed and index them using Chroma and OpenAI
- Run a Streamlit app that answers questions using vector search and LLM fallback
Create a docs/ directory and add .json files structured like this:
[
{
"question": "What is AI?",
"answer": "Artificial Intelligence is the simulation of human intelligence."
},
{
"question": "What is Python?",
"answer": "A programming language."
}
]Run the document loader to embed and store the data:
poetry run python -m support_agent.scripts.docs_loaderThis will:
- Read all .json files from docs/
- Create Q:/A: pairs
- Embed them using OpenAI
- Save them to a persistent Chroma vector store in vectorstore/
Launch the Streamlit interface with:
poetry run streamlit run src/support_agent/agent.pyThen open the app in your browser to begin asking questions.
The application has ben tested with 100% code coverage
You can run all tests and view coverage:
poetry run pytest --cov=support_agent --cov-report=term-missingsupport_agent/
├── agent.py # Main agent routing logic
├── fallback.py # Fallback logic using OpenAI API
├── tools/
│ └── retriever.py # Chroma-based vector search
├── scripts/
│ └── docs_loader.py # JSON to vectorstore loader
├── assets/
tests/
├── test_agent.py
├── test_fallback.py
└── test_retriever.py
docs/ # Your source Q&A JSON documents
vectorstore/ # Persisted vector indexMake sure to set your OpenAI key:
export OPENAI_API_KEY=your-key-hereOr add it to a .env file in the project root:
OPENAI_API_KEY=your-key-hereMIT

