Domain-Restricted Q&A Assistant is a Streamlit-based AI application that answers questions only within a selected domain using a custom CSV knowledge base. The app combines OpenAI’s GPT models with domain restrictions and personalized response styles to create a focused AI assistant experience.
- Python
- Streamlit
- Pandas
- OpenAI API
- CSV-based Knowledge Base
-
Domain-specific AI assistant
-
CSV knowledge base upload system
-
AI responses powered by OpenAI
-
Domain restriction enforcement
-
Adjustable response styles:
- Tone
- Length
- Audience level
-
Quick prebuilt questions
-
Session state persistence
-
Error handling for invalid uploads and API issues
-
Simple and responsive Streamlit UI
User selects a domain from the Setup tab
User uploads a CSV knowledge base containing:
topicinformation
The application:
- Loads and validates the CSV
- Converts the CSV into a formatted knowledge base
- Stores it in Streamlit session state
User enters:
- A question
- Tone preference
- Response length
- Audience level
The app:
- Builds a structured prompt
- Sends it to OpenAI GPT-4o-mini
- Displays the AI-generated answer
Users can also select quick template questions from the Quick Questions tab.
I built this project using Streamlit as the frontend framework and OpenAI’s API for AI-generated responses.
The development process involved:
- Designing a multi-tab Streamlit interface
- Creating domain-restricted prompt engineering
- Building CSV upload and validation functionality
- Managing persistent state using Streamlit session state
- Integrating OpenAI API calls
- Adding customizable response styles
- Creating reusable helper functions
- Implementing quick-question templates
- Handling file and API errors gracefully
- How Streamlit session state works
- Working with CSV uploads in Streamlit
- Prompt engineering for domain restriction
- Integrating OpenAI APIs into Python applications
- Structuring reusable functions and clean app architecture
- Error handling for file uploads and API responses
- Building multi-tab interactive applications
- Managing dynamic UI components in Streamlit
This project improved my understanding of AI application development, prompt engineering, and frontend-backend interaction using Streamlit.
It also helped me practice:
- Clean function-based architecture
- API integration
- State management
- User-focused UI design
- Building domain-constrained AI systems
- Add conversation history
- Support multiple uploaded knowledge bases
- Add embeddings/vector search for smarter retrieval
- Improve prompt engineering
- Add authentication system
- Export chat responses
- Add dark mode support
- Improve UI styling and animations
- Add real-time streaming responses
git clone <your-repo-url>
cd domain-qa-assistant
pip install -r requirements.txt
streamlit run app.pyThen open:
http://localhost:8501Example CSV structure:
topic,information
Protein,Protein helps build muscle.
Cardio,Cardio improves heart health.
Budgeting,Budgeting helps manage expenses.Required columns:
topicinformation
Enter your OpenAI API key in the sidebar after launching the application.
Get your API key from: