Update app.py
Browse files
app.py
CHANGED
@@ -157,7 +157,6 @@ def predict(system_msg, inputs, top_p, temperature, chat_counter, chatbot=None,
|
|
157 |
# Kullanıcı mesajını hemen ekleyip chatbot’u güncelle
|
158 |
chatbot.append({"role": "user", "content": inputs})
|
159 |
chatbot.append({"role": "assistant", "content": ""}) # Boş assistant mesajı
|
160 |
-
yield chatbot, history, chat_counter # İlk yield ile kullanıcı mesajı görünür
|
161 |
|
162 |
response = requests.post(API_URL, headers=headers, json=payload, stream=True)
|
163 |
|
@@ -279,9 +278,14 @@ with gr.Blocks(css=demo_css, theme=theme) as demo:
|
|
279 |
chatbot_ref[:] = chat
|
280 |
return chat
|
281 |
|
282 |
-
#
|
283 |
-
inputs.submit(
|
284 |
-
|
|
|
|
|
|
|
|
|
|
|
285 |
|
286 |
scheduler_thread = threading.Thread(target=run_scheduler, args=(chatbot_ref,), daemon=True)
|
287 |
scheduler_thread.start()
|
|
|
157 |
# Kullanıcı mesajını hemen ekleyip chatbot’u güncelle
|
158 |
chatbot.append({"role": "user", "content": inputs})
|
159 |
chatbot.append({"role": "assistant", "content": ""}) # Boş assistant mesajı
|
|
|
160 |
|
161 |
response = requests.post(API_URL, headers=headers, json=payload, stream=True)
|
162 |
|
|
|
278 |
chatbot_ref[:] = chat
|
279 |
return chat
|
280 |
|
281 |
+
# reset_textbox’u önce çalıştırıp ardından predict’i çağırıyoruz
|
282 |
+
inputs.submit(reset_textbox, [], [inputs]).then(
|
283 |
+
predict, [system_msg, inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter]
|
284 |
+
).then(update_chatbot_ref, chatbot, chatbot)
|
285 |
+
|
286 |
+
send_button.click(reset_textbox, [], [inputs]).then(
|
287 |
+
predict, [system_msg, inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter]
|
288 |
+
).then(update_chatbot_ref, chatbot, chatbot)
|
289 |
|
290 |
scheduler_thread = threading.Thread(target=run_scheduler, args=(chatbot_ref,), daemon=True)
|
291 |
scheduler_thread.start()
|