Spaces:
Sleeping
Sleeping
| title: AI Chatbot | |
| emoji: π€ | |
| colorFrom: blue | |
| colorTo: purple | |
| sdk: gradio | |
| sdk_version: 4.0.0 | |
| app_file: app.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.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.py requirements.txt README.md /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.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! |