AiCoderv2 commited on
Commit
d428657
·
verified ·
1 Parent(s): 7fdac37

Update app.py from anycoder

Browse files
Files changed (1) hide show
  1. app.py +31 -23
app.py CHANGED
@@ -166,27 +166,35 @@ demo.launch(
166
  {"label": "Hugging Face", "url": "https://huggingface.co/"}
167
  ],
168
  title="Hugging Face AI Chatbot",
169
- description="A conversational AI chatbot using Hugging Face's DialoGPT-small model"
 
170
  )
171
- Key changes made:
172
-
173
- 1. **Replaced the simple chatbot with Hugging Face model**:
174
- - Added `transformers` import for AutoTokenizer and AutoModelForCausalLM
175
- - Created `HuggingFaceChatbot` class using DialoGPT-small model
176
- - Added proper model loading and GPU support
177
-
178
- 2. **Enhanced the interface**:
179
- - Updated title to reflect Hugging Face integration
180
- - Added model information section showing device and parameters
181
- - Added Hugging Face link to footer
182
-
183
- 3. **Improved response generation**:
184
- - Uses proper tokenization and generation
185
- - Maintains conversation context with chat history
186
- - Better response quality with temperature and sampling
187
-
188
- 4. **Added technical details**:
189
- - Shows which device (CPU/GPU) is being used
190
- - Displays model parameters in the sidebar
191
-
192
- The application now uses a real AI model from Hugging Face while maintaining the same user-friendly interface and conversation flow. The DialoGPT-small model is a good choice as it's relatively lightweight but provides much better conversational abilities than the simple rule-based chatbot.
 
 
 
 
 
 
 
 
166
  {"label": "Hugging Face", "url": "https://huggingface.co/"}
167
  ],
168
  title="Hugging Face AI Chatbot",
169
+ description="A conversational AI chatbot using Hugging Face's DialoGPT-small model",
170
+ share=True
171
  )
172
+ Key changes made for publishing:
173
+
174
+ 1. **Added `share=True` parameter** to the `demo.launch()` call to enable public sharing
175
+ 2. **Maintained all existing functionality** including:
176
+ - Hugging Face DialoGPT-small model integration
177
+ - GPU acceleration support
178
+ - Timestamped messages
179
+ - Modern UI with custom theme
180
+ - Clear chat functionality
181
+
182
+ 3. **Kept the professional interface** with:
183
+ - Features section
184
+ - How-to-use instructions
185
+ - Model information
186
+ - Proper error handling
187
+
188
+ 4. **Ensured all dependencies are properly imported**:
189
+ - `transformers` for Hugging Face models
190
+ - `torch` for GPU support
191
+ - `datetime` for timestamps
192
+
193
+ The application is now ready to be published as a Hugging Face Space. When deployed, it will:
194
+ - Be publicly accessible
195
+ - Use the DialoGPT-small model for conversations
196
+ - Show proper model information and usage instructions
197
+ - Maintain conversation context
198
+ - Work on both CPU and GPU devices
199
+
200
+ The `share=True` parameter will generate a public link that can be shared with others to access the chatbot.