SamiKoen commited on
Commit
60bb8e1
·
verified ·
1 Parent(s): 607f786

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
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
- # inputs.submit ve send_button.click içinde reset_textboxu hemen çağırıyoruz
283
- inputs.submit(predict, [system_msg, inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter]).then(update_chatbot_ref, chatbot, chatbot).then(reset_textbox, [], [inputs])
284
- send_button.click(predict, [system_msg, inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter]).then(update_chatbot_ref, chatbot, chatbot).then(reset_textbox, [], [inputs])
 
 
 
 
 
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 predicti ç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()