Update app.py
Browse files
app.py
CHANGED
|
@@ -321,7 +321,7 @@ with gr.Blocks(
|
|
| 321 |
# LEFT SIDE (CHAT)
|
| 322 |
with gr.Column(scale=3):
|
| 323 |
|
| 324 |
-
chatbot = gr.Chatbot(label="💬 Conversation",
|
| 325 |
|
| 326 |
question = gr.Textbox(
|
| 327 |
label="Ask Dox a question:",
|
|
@@ -358,10 +358,21 @@ with gr.Blocks(
|
|
| 358 |
# Chat Logic
|
| 359 |
# -----------------------------
|
| 360 |
def chat_ui(user_message, chat_history):
|
|
|
|
|
|
|
|
|
|
| 361 |
response_text, link = ask_agent(user_message)
|
| 362 |
-
|
| 363 |
-
chat_history
|
| 364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
return (
|
| 366 |
chat_history,
|
| 367 |
link,
|
|
|
|
| 321 |
# LEFT SIDE (CHAT)
|
| 322 |
with gr.Column(scale=3):
|
| 323 |
|
| 324 |
+
chatbot = gr.Chatbot(label="💬 Conversation", type="messages")
|
| 325 |
|
| 326 |
question = gr.Textbox(
|
| 327 |
label="Ask Dox a question:",
|
|
|
|
| 358 |
# Chat Logic
|
| 359 |
# -----------------------------
|
| 360 |
def chat_ui(user_message, chat_history):
|
| 361 |
+
if chat_history is None:
|
| 362 |
+
chat_history = []
|
| 363 |
+
|
| 364 |
response_text, link = ask_agent(user_message)
|
| 365 |
+
|
| 366 |
+
chat_history.append({
|
| 367 |
+
"role": "user",
|
| 368 |
+
"content": user_message
|
| 369 |
+
})
|
| 370 |
+
|
| 371 |
+
chat_history.append({
|
| 372 |
+
"role": "assistant",
|
| 373 |
+
"content": response_text
|
| 374 |
+
})
|
| 375 |
+
|
| 376 |
return (
|
| 377 |
chat_history,
|
| 378 |
link,
|