Skip to content

yocho1/ChatGPT-like-Website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Your Own ChatGPT Website

Production-ready chat experience powered by BlenderBot (facebook/blenderbot-400M-distill) on a Flask backend with a modern, responsive frontend.

What’s Inside

  • Flask API with /chat, CORS, in-memory rate limiting, and per-client conversation memory (last 5 turns)
  • BlenderBot via Hugging Face Transformers with temperature control, max response length, bad-word filtering, and context truncation to 1024 tokens
  • ChatGPT-like UI: message bubbles, typing indicator, timestamps, copy-to-clipboard, clear chat, dark/light mode toggle, responsive layout
  • Safety & resilience: input length caps, graceful model-unavailable responses, basic content filtering, and request throttling

Quickstart

  1. Install Python 3.10+
  2. Create and activate a venv (PowerShell):
    python -m venv .venv; .venv\Scripts\activate
  3. Install dependencies:
    pip install -r requirements.txt
  4. Run the app:
    python app.py
    Visit http://localhost:5000

API

  • POST /chat
    • Body: { "message": "...", "client_id": "optional", "reset": false, "temperature": 0.0-1.5 }
    • Responses: { "response": "..." } on success, or { "error": "..." } with status codes 4xx/5xx
  • GET /
    • Serves the chat UI
  • GET /favicon.ico
    • Empty 204 to avoid 404 noise

Configuration (env vars)

  • MODEL_NAME (default facebook/blenderbot-400M-distill)
  • MAX_HISTORY_PAIRS (default 5)
  • MAX_CONTEXT_TOKENS (default 1024)
  • MAX_NEW_TOKENS (default 150)
  • TEMPERATURE (default 0.8) — UI slider can override per request
  • TOP_P (default 0.9)
  • RATE_LIMIT_MAX (default 10 requests)
  • RATE_LIMIT_WINDOW (default 60 seconds)
  • BAD_WORDS comma-separated list for filtering
  • MAX_MESSAGE_CHARS (default 2000)

Frontend Features

  • Auto-scroll, Enter-to-send, copy-to-clipboard on AI replies
  • Typing indicator while the backend generates
  • Theme persistence (dark/light) via localStorage
  • Client ID persistence with crypto UUID fallback for older browsers

Operational Notes

  • First run downloads the BlenderBot model (allow time/disk).
  • Rate limiting and history are in-memory; they reset on restart.
  • Clear Chat requests both reset the UI and ask the backend to drop history for that client.

Security Considerations

  • Basic bad-word masking in both user input and model output
  • Input length clamp (MAX_MESSAGE_CHARS) and context truncation (MAX_CONTEXT_TOKENS)
  • CORS enabled for local development; tighten origins for production

License

MIT

About

Chat-style web app powered by BlenderBot (facebook/blenderbot-400M-distill) with a Flask backend and a modern, responsive UI.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors