Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

💬 AI Chatbot Generative AI Project

Python 3.10+ Streamlit Generative AI

A full-stack, feature-rich conversational AI application powered by Large Language Models (LLMs), Python, and Streamlit. Moves beyond basic classification models to build contextual, memory-aware, multi-provider generative AI applications.


🎯 Features

🧠 Core Generative AI Capabilities

  • Multi-LLM Provider Engine: Seamlessly switch between Google Gemini (gemini-2.5-flash, gemini-1.5-pro), OpenAI (gpt-4o, gpt-4o-mini), Anthropic (claude-3-5-sonnet), and a built-in Demo/Mock Mode (no API key required).
  • Conversation Memory: Remembers context across chat turns (e.g., handles "My name is Alex" $\rightarrow$ "What is my name?" $\rightarrow$ "Your name is Alex").
  • Prompt Engineering & Personas: Pre-loaded system instructions including:
    • 📊 Data Analyst Mentor
    • 💻 Senior Coding Tutor
    • 🎧 Customer Support Agent
    • ⏱️ Executive Personal Assistant
    • ✏️ Custom System Persona
  • Hyperparameter Controls: Fine-tune Temperature (0.0 Factual to 1.0 Creative) and Max Tokens in real time via sidebar sliders.

🚀 Intermediate & Advanced Extensions

  • 📄 Document Q&A (PDF RAG): Upload PDFs to extract context and perform document-based question answering.
  • 🔍 Live Web Search: Toggle real-time search context using DuckDuckGo to answer queries with up-to-date online information.
  • 🎙️ Voice I/O: Integrated Speech Synthesis (Text-To-Speech audio playback) and browser Web Speech API for voice dictation.
  • 💾 SQLite Chat Persistence: Save, load, and manage past chat sessions persistently.
  • 📥 Export Options: One-click conversation download in JSON or TXT formats.
  • 🎨 Modern Dark Mode UI: Built with glassmorphism CSS, dynamic badges, responsive chat bubbles, and clean typography.

📌 Architecture Diagram

+-----------------------------------------------------------------------------------+
|                                 STREAMLIT FRONTEND                                |
|  +-----------------------+   +----------------------+   +-----------------------+ |
|  |   User Query Input    |   | Persona / Sys Prompt |   | Temp & Token Sliders  | |
|  +-----------+-----------+   +----------+-----------+   +-----------+-----------+ |
+--------------|--------------------------|---------------------------|-------------+
               |                          |                           |
               v                          v                           v
+-----------------------------------------------------------------------------------+
|                                 LLM CHATBOT ENGINE                                |
|  +------------------------+  +-------------------------+  +--------------------+  |
|  | Conversation Memory    |  | RAG Context (PDF PyPDF) |  | DuckDuckGo Search  |  |
|  +-----------+------------+  +------------+------------+  +---------+----------+  |
+--------------|----------------------------|-------------------------|-------------+
               |                            |                         |
               +--------------------+-------+-------------------------+
                                    |
                                    v
           +-------------------------------------------------+
           |                UNIFIED API ROUTER               |
           +--------+-----------------+-----------------+----+
                    |                 |                 |
                    v                 v                 v
            +---------------+ +---------------+ +---------------+
            | Google Gemini | |  OpenAI API   | | Anthropic API |
            |  (gemini-2.5) | | (gpt-4o-mini) | |  (claude-3.5) |
            +-------+-------+ +-------+-------+ +-------+-------+
                    |                 |                 |
                    +-----------------+-----------------+
                                      |
                                      v
           +-------------------------------------------------+
           |        GENERATED RESPONSE & VOICE TTS OUTPUT    |
           +-------------------------------------------------+

📂 Project Structure

AI_Chatbot/
├── app.py                     # Main Streamlit web application & modern interface
├── chatbot.py                 # Unified Multi-LLM provider client & memory manager
├── prompts/                   # System prompt persona templates
│   ├── default_system.txt     # General Assistant persona
│   ├── analyst_mentor.txt     # Data Analyst Mentor persona
│   ├── coding_tutor.txt       # Senior Coding Tutor persona
│   ├── customer_support.txt   # Customer Support Agent persona
│   └── personal_assistant.txt # Executive Assistant persona
├── utils/                     # Feature extension modules
│   ├── __init__.py
│   ├── pdf_processor.py       # PDF document reader & context builder
│   ├── search.py              # DuckDuckGo live web search wrapper
│   ├── voice.py               # gTTS audio synthesis & Web Speech HTML generator
│   └── database.py            # SQLite database history logger & session manager
├── requirements.txt           # Python dependency requirements
├── .env.example               # Template for API keys
├── .gitignore                 # Git ignore configuration
└── README.md                  # Comprehensive project documentation

⚙️ Quick Start & Installation

1. Clone the repository & navigate to directory:

cd AI_Chatbot

2. Create and activate a virtual environment:

# Windows
python -m venv .venv
.venv\Scripts\activate

# macOS / Linux
python3 -m venv .venv
source .venv/bin/activate

3. Install dependencies:

pip install -r requirements.txt

4. (Optional) Configure Environment Variables:

Copy .env.example to .env and add your API key(s):

cp .env.example .env

Note: You can also enter your API key directly in the app's sidebar UI!

5. Launch the Streamlit application:

streamlit run app.py

Open your browser at http://localhost:8501.


🚀 Deployment Guide

Deploying to Render

  1. Push code to your GitHub repository.
  2. Create a new Web Service on Render.
  3. Connect your repository and configure:
    • Environment: Python 3
    • Build Command: pip install -r requirements.txt
    • Start Command: streamlit run app.py --server.port $PORT --server.address 0.0.0.0
  4. Add environment variables (GEMINI_API_KEY, etc.) in Render's Environment tab.

Deploying to Hugging Face Spaces

  1. Create a new Space on Hugging Face.
  2. Select Streamlit as the SDK.
  3. Upload all project files (app.py, chatbot.py, utils/, prompts/, requirements.txt).
  4. Set secrets under Settings $\rightarrow$ Repository Secrets.

💼 Resume Project Description

AI Chatbot using Multi-Model LLMs & RAG
Developed a full-stack conversational AI application using Large Language Models (Gemini, OpenAI, Anthropic), Python, and Streamlit. Implemented conversation memory management, customizable system personas, hyperparameter controls, PDF document Q&A (RAG), live web search integration, SQLite history persistence, and text-to-speech audio synthesis.


📜 License

Apache-2.0 License. Free to use and modify for learning and portfolio development!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages