basic_chatbot / README.md
arcsu1's picture
frst
4d0e37d
metadata
title: Basic Chatbot
emoji: 💬
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860
pinned: false

AI Chatbot Flask App

Flask service for a fine-tuned GPT-2 conversational chatbot model.

Setup

Local Development

  1. Install dependencies:
pip install -r requirements.txt
  1. Run the app:
python app.py
  1. Access the application:

Docker

  1. Build the image:
docker build -t chatbot-api .
  1. Run the container:
docker run -p 7860:7860 chatbot-api

API Endpoints

Web Interface

Visit the root URL to access the interactive chat interface.

GET /api

Health check and info

curl http://localhost:7860/api

GET /health

Detailed health status

curl http://localhost:7860/health

POST /chat

Generate chatbot response

Request body:

{
  "user": ["Hello!", "How are you?"],
  "ai": ["Hi there!"]
}

Example:

curl -X POST http://localhost:7860/chat \
  -H "Content-Type: application/json" \
  -d '{"user": ["Hello!"], "ai": []}'

Response:

{
  "response": "Hi there! How can I help you today",
  "device": "cuda:0"
}

Model

  • Model: Fine-tuned GPT-2
  • Location: ./models/fine-tuned-gpt2
  • Type: Conversational AI Chatbot
  • Port: 7860

Features

  • CORS enabled for all origins
  • Automatic GPU detection and usage
  • Conversation history support (last 7 exchanges)
  • Clean chat interface
  • Real-time responses
  • Message history management
  • Typing indicators

Chat Interface

The web interface provides:

  • Real-time chat with the AI
  • Conversation history
  • Typing indicators
  • Clear chat functionality
  • Responsive design for mobile and desktop