Update app.py
Browse files
app.py
CHANGED
|
@@ -150,11 +150,11 @@ def chat_with_model(prompt, system_prompt, chatbot_display, internal_history,lan
|
|
| 150 |
internal_history.append({"role": "assistant", "content": response_text})
|
| 151 |
|
| 152 |
# 7. Cập nhật lịch sử hiển thị (gr.Chatbot)
|
| 153 |
-
chatbot_display.append([prompt, translated
|
| 154 |
|
| 155 |
# 8. Trả về cả hai để cập nhật UI
|
| 156 |
# (chuỗi rỗng "" để xóa nội dung trong ô prompt_box)
|
| 157 |
-
return "", chatbot_display, internal_history
|
| 158 |
|
| 159 |
def clear_chat():
|
| 160 |
"""Xóa lịch sử."""
|
|
@@ -187,6 +187,18 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
| 187 |
placeholder="Nhập tin nhắn của bạn và nhấn Enter...",
|
| 188 |
lines=1
|
| 189 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
with gr.Row():
|
| 192 |
clear_button = gr.Button("Clear Chat")
|
|
@@ -207,14 +219,14 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
| 207 |
prompt_box.submit(
|
| 208 |
fn=chat_with_model,
|
| 209 |
inputs=[prompt_box, system_prompt_box, chatbot_display, internal_history,lang],
|
| 210 |
-
outputs=[prompt_box, chatbot_display, internal_history]
|
| 211 |
)
|
| 212 |
|
| 213 |
# Khi người dùng nhấn nút "Send" (ẩn)
|
| 214 |
submit_button.click(
|
| 215 |
fn=chat_with_model,
|
| 216 |
inputs=[prompt_box, system_prompt_box, chatbot_display, internal_history,lang],
|
| 217 |
-
outputs=[prompt_box, chatbot_display, internal_history]
|
| 218 |
)
|
| 219 |
|
| 220 |
# Khi người dùng nhấn nút "Clear Chat"
|
|
|
|
| 150 |
internal_history.append({"role": "assistant", "content": response_text})
|
| 151 |
|
| 152 |
# 7. Cập nhật lịch sử hiển thị (gr.Chatbot)
|
| 153 |
+
chatbot_display.append([prompt, translated])
|
| 154 |
|
| 155 |
# 8. Trả về cả hai để cập nhật UI
|
| 156 |
# (chuỗi rỗng "" để xóa nội dung trong ô prompt_box)
|
| 157 |
+
return "", chatbot_display, internal_history, response_text, prompt
|
| 158 |
|
| 159 |
def clear_chat():
|
| 160 |
"""Xóa lịch sử."""
|
|
|
|
| 187 |
placeholder="Nhập tin nhắn của bạn và nhấn Enter...",
|
| 188 |
lines=1
|
| 189 |
)
|
| 190 |
+
|
| 191 |
+
prompt = gr.Textbox(
|
| 192 |
+
label="Your Message",
|
| 193 |
+
placeholder="Nhập tin nhắn của bạn và nhấn Enter...",
|
| 194 |
+
lines=1
|
| 195 |
+
)
|
| 196 |
+
|
| 197 |
+
response = gr.Textbox(
|
| 198 |
+
label="Your Message",
|
| 199 |
+
placeholder="Nhập tin nhắn của bạn và nhấn Enter...",
|
| 200 |
+
lines=1
|
| 201 |
+
)
|
| 202 |
|
| 203 |
with gr.Row():
|
| 204 |
clear_button = gr.Button("Clear Chat")
|
|
|
|
| 219 |
prompt_box.submit(
|
| 220 |
fn=chat_with_model,
|
| 221 |
inputs=[prompt_box, system_prompt_box, chatbot_display, internal_history,lang],
|
| 222 |
+
outputs=[prompt_box, chatbot_display, internal_history, response, prompt]
|
| 223 |
)
|
| 224 |
|
| 225 |
# Khi người dùng nhấn nút "Send" (ẩn)
|
| 226 |
submit_button.click(
|
| 227 |
fn=chat_with_model,
|
| 228 |
inputs=[prompt_box, system_prompt_box, chatbot_display, internal_history,lang],
|
| 229 |
+
outputs=[prompt_box, chatbot_display, internal_history, response, prompt]
|
| 230 |
)
|
| 231 |
|
| 232 |
# Khi người dùng nhấn nút "Clear Chat"
|