Spaces:
Sleeping
feat: Add thinking indicator during bot response generation
Browse filesUX improvement: Show loading state while generating response
β¨ Enhancement:
- Display "π€ μλ΅ μμ± μ€..." message immediately after user input
- Replaced by actual bot response when generation completes
- Improves user feedback during wait time
π― User Experience Flow:
1. User sends message β Message displays instantly
2. "π€ μλ΅ μμ± μ€..." appears β User knows bot is working
3. Bot response ready β Thinking indicator replaced with response
π Implementation:
- Added intermediate yield with thinking indicator
- Three-stage generator: user message β thinking β response
- Clear visual feedback throughout entire process
π€ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
@@ -226,9 +226,12 @@ with gr.Blocks(title="π€ Llama-2-Ko Chatbot") as demo:
|
|
| 226 |
def submit(message, history):
|
| 227 |
# Immediately show user message
|
| 228 |
updated_history = history + [{"role": "user", "content": message}]
|
| 229 |
-
# Return updated history first (shows user message immediately)
|
| 230 |
-
# Then generate bot response
|
| 231 |
yield updated_history, ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
# Generate and add bot response
|
| 233 |
final_history = chat_wrapper(message, history)
|
| 234 |
yield final_history, ""
|
|
|
|
| 226 |
def submit(message, history):
|
| 227 |
# Immediately show user message
|
| 228 |
updated_history = history + [{"role": "user", "content": message}]
|
|
|
|
|
|
|
| 229 |
yield updated_history, ""
|
| 230 |
+
|
| 231 |
+
# Show "thinking" indicator
|
| 232 |
+
thinking_history = updated_history + [{"role": "assistant", "content": "π€ μλ΅ μμ± μ€..."}]
|
| 233 |
+
yield thinking_history, ""
|
| 234 |
+
|
| 235 |
# Generate and add bot response
|
| 236 |
final_history = chat_wrapper(message, history)
|
| 237 |
yield final_history, ""
|