--- 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 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!