Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -187,7 +187,7 @@ with gr.Blocks(theme=theme, css="""
|
|
| 187 |
flex-shrink: 0;
|
| 188 |
margin-top: 0.5rem;
|
| 189 |
display: flex;
|
| 190 |
-
justify-content:
|
| 191 |
align-items: flex-end;
|
| 192 |
gap: 10px;
|
| 193 |
max-width: 700px;
|
|
@@ -227,13 +227,14 @@ with gr.Blocks(theme=theme, css="""
|
|
| 227 |
}
|
| 228 |
|
| 229 |
.send-button {
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
|
|
|
| 237 |
}
|
| 238 |
|
| 239 |
@media (max-width: 768px) {
|
|
@@ -297,12 +298,20 @@ with gr.Blocks(theme=theme, css="""
|
|
| 297 |
send_btn = gr.Button("📤", variant="primary", elem_classes=["send-button"])
|
| 298 |
|
| 299 |
def respond_and_update(message, history):
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
|
| 307 |
if __name__ == "__main__":
|
| 308 |
logger.info("Starting EduBot...")
|
|
|
|
| 187 |
flex-shrink: 0;
|
| 188 |
margin-top: 0.5rem;
|
| 189 |
display: flex;
|
| 190 |
+
justify-content: stretch;
|
| 191 |
align-items: flex-end;
|
| 192 |
gap: 10px;
|
| 193 |
max-width: 700px;
|
|
|
|
| 227 |
}
|
| 228 |
|
| 229 |
.send-button {
|
| 230 |
+
border-radius: 50% !important;
|
| 231 |
+
width: 50px !important;
|
| 232 |
+
height: 50px !important;
|
| 233 |
+
display: flex !important;
|
| 234 |
+
align-items: center !important;
|
| 235 |
+
justify-content: center !important;
|
| 236 |
+
flex-shrink: 0 !important;
|
| 237 |
+
align-self: flex-end !important;
|
| 238 |
}
|
| 239 |
|
| 240 |
@media (max-width: 768px) {
|
|
|
|
| 298 |
send_btn = gr.Button("📤", variant="primary", elem_classes=["send-button"])
|
| 299 |
|
| 300 |
def respond_and_update(message, history):
|
| 301 |
+
# Add the user's message to history with a placeholder for the bot's response
|
| 302 |
+
history.append([message, None])
|
| 303 |
+
|
| 304 |
+
# This first yield makes the user's message appear immediately
|
| 305 |
+
yield history, ""
|
| 306 |
+
|
| 307 |
+
full_response = ""
|
| 308 |
+
# Stream the bot's full response
|
| 309 |
+
for response_chunk in respond_with_enhanced_streaming(message, history):
|
| 310 |
+
full_response = response_chunk
|
| 311 |
+
# Continuously update the bot's message in the last row of history
|
| 312 |
+
history[-1][1] = full_response
|
| 313 |
+
# Yield the updated history and clear the input textbox
|
| 314 |
+
yield history, ""
|
| 315 |
|
| 316 |
if __name__ == "__main__":
|
| 317 |
logger.info("Starting EduBot...")
|