Spaces:
Running
Running
File size: 1,884 Bytes
6eeab27 4d0e37d 6eeab27 4d0e37d 6eeab27 4d0e37d 6eeab27 4d0e37d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | ---
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:
```bash
pip install -r requirements.txt
```
2. Run the app:
```bash
python app.py
```
3. 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
1. Build the image:
```bash
docker build -t chatbot-api .
```
2. Run the container:
```bash
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
```bash
curl http://localhost:7860/api
```
### GET `/health`
Detailed health status
```bash
curl http://localhost:7860/health
```
### POST `/chat`
Generate chatbot response
Request body:
```json
{
"user": ["Hello!", "How are you?"],
"ai": ["Hi there!"]
}
```
Example:
```bash
curl -X POST http://localhost:7860/chat \
-H "Content-Type: application/json" \
-d '{"user": ["Hello!"], "ai": []}'
```
Response:
```json
{
"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
|