Spaces:
Running
Running
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
- Install dependencies:
pip install -r requirements.txt
- Run the app:
python app.py
- Access the application:
- Web Interface: http://localhost:7860 (Chat directly in your browser!)
- API Info: http://localhost:7860/api
- Health check: http://localhost:7860/health
Docker
- Build the image:
docker build -t chatbot-api .
- 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