A simple chatbot built with Streamlit and the OpenAI API, featuring login authentication backed by SQLite. The assistant is specialized in data analysis.
- Install dependencies:
pip install -r requirements.txt - Set your OpenAI API key in a
.envfile:OPENAI_API_KEY=your_key_here - Run the app:
streamlit run app.py
- Login with username
adminand passwordpassword(default user stored inusers.db). - To add more users, run
python add_user.pyand follow the prompts, or insert records directly into theuserstable with SHA-256 hashed passwords. - Type your message and press Enter to chat with the AI.
- The chatbot can access
sales.dbfor data analysis. Mention keywords like "sales", "data", "analysis", "bicycle", or "bike" to encourage database use. - The AI is configured as the world's best sales data analyst, never makes calculation errors, and describes charts when appropriate. It politely declines non-sales requests.
- Conversation transcripts are written to
conversations/<username>_<session_id>_messages.json(or<username>_messages.jsonif no session ID). The file is updated after every assistant reply and again when you click Logout. - Click Logout to return to the login screen. After logging out you'll see a Conversation saved to ... banner with the relative path to the transcript.
- If you do not see files in the
conversationsfolder, make sure the Streamlit app is shut down via the Logout button or that it has generated at least one assistant response. The folder is ignored by Git via.gitignore, so new transcripts won't appear ingit status. - Each login starts a fresh chat session.