File size: 3,084 Bytes
aee0f17
 
 
 
 
 
92c50a5
99a8155
aee0f17
 
 
a2e4dd9
ba4a7ed
a2e4dd9
ba4a7ed
 
 
 
a2e4dd9
 
ba4a7ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99a8155
ba4a7ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99a8155
ba4a7ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99a8155
ba4a7ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92c50a5
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
116
117
118
119
120
121
122
123
124
---
title: AI Chatbot
emoji: πŸ€–
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.36.2
app_file: app_simple.py
pinned: false
---

# AI Chatbot with PDF Knowledge

A smart AI chatbot built with Gradio and OpenAI's GPT models, enhanced with PDF document knowledge. The chatbot can answer questions based on the Health Tech Hub Copenhagen PDF document, making it perfect for health tech inquiries and information retrieval.

## Features

- πŸ€– Powered by OpenAI's GPT-3.5-turbo
- πŸ“„ PDF Knowledge Integration - Answers based on Health Tech Hub Copenhagen document
- πŸ” Semantic Search - Finds relevant information from the PDF
- πŸ’¬ Real-time chat interface
- 🎨 Beautiful and responsive UI
- πŸ“± Mobile-friendly design
- πŸ”„ Conversation history
- 🧹 Clear chat functionality

## Local Development

### Prerequisites

- Python 3.8 or higher
- OpenAI API key

### Installation

1. Clone this repository:
```bash
git clone <your-repo-url>
cd chatbotsverige
```

2. Install dependencies:
```bash
pip install -r requirements.txt
```

3. Set up your OpenAI API key:
```bash
export OPENAI_API_KEY="your-api-key-here"
```

4. Run the application:
```bash
python app_simple.py
```

The chatbot will be available at `http://localhost:7860`

## Deployment on Hugging Face Spaces

### Method 1: Using the Hugging Face Web Interface

1. Go to [Hugging Face Spaces](https://huggingface.co/spaces)
2. Click "Create new Space"
3. Choose "Gradio" as the SDK
4. Upload your files or connect your GitHub repository
5. Add your `OPENAI_API_KEY` as a secret in the Space settings

### Method 2: Using Git

1. Create a new Space on Hugging Face
2. Clone the Space repository:
```bash
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
```

3. Copy your files to the Space repository:
```bash
cp app_simple.py requirements.txt README.md "Health Tech Hub Copenhagen.pdf" /path/to/space/repo/
```

4. Push to Hugging Face:
```bash
cd /path/to/space/repo/
git add .
git commit -m "Initial commit"
git push
```

### Environment Variables

Make sure to set the following environment variable in your Hugging Face Space:

- `OPENAI_API_KEY`: Your OpenAI API key

## Configuration

You can customize the chatbot by modifying the following parameters in `app_simple.py`:

- **Model**: Change `gpt-3.5-turbo` to other OpenAI models
- **Max tokens**: Adjust `max_tokens` for response length
- **Temperature**: Modify `temperature` for response creativity (0.0-1.0)
- **System prompt**: Customize the system message for different personalities

## Usage

1. Type your message in the text input
2. Press Enter or click the send button
3. The AI will respond based on the conversation context
4. Use the "Clear Chat" button to start a new conversation

## Security Notes

- Never commit your API keys to version control
- Use environment variables for sensitive information
- Consider implementing rate limiting for production use

## License

This project is open source and available under the MIT License.

## Contributing

Feel free to submit issues and enhancement requests!