Nitzantry1 commited on
Commit
840b854
โ€ข
1 Parent(s): 4cc2167

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -5,12 +5,12 @@ import gradio as gr
5
  client = Client("dicta-il/dictalm2.0-instruct-demo")
6
 
7
  def chat_with_model(history):
8
- prompt = history[-1]["user"]
9
  result = client.predict(
10
  message=prompt,
11
  api_name="/chat"
12
  )
13
- return history + [{"user": prompt, "bot": result}]
14
 
15
  # ื™ืฆื™ืจืช ืžืžืฉืง ืžืชืงื“ื ืขื Gradio ื‘ืฆื•ืจืช ืฆ'ื˜-ื‘ื•ื˜
16
  with gr.Blocks(theme="default") as demo:
@@ -21,8 +21,10 @@ with gr.Blocks(theme="default") as demo:
21
  send_button = gr.Button("ืฉืœื—")
22
 
23
  def user_chat(history, message):
24
- return history + [{"user": message}], ""
25
 
 
 
26
  send_button.click(user_chat, inputs=[chatbot, user_input], outputs=[chatbot, user_input], queue=False)
27
  send_button.click(chat_with_model, inputs=chatbot, outputs=chatbot)
28
 
 
5
  client = Client("dicta-il/dictalm2.0-instruct-demo")
6
 
7
  def chat_with_model(history):
8
+ prompt = history[-1][0]
9
  result = client.predict(
10
  message=prompt,
11
  api_name="/chat"
12
  )
13
+ return history + [(prompt, result)]
14
 
15
  # ื™ืฆื™ืจืช ืžืžืฉืง ืžืชืงื“ื ืขื Gradio ื‘ืฆื•ืจืช ืฆ'ื˜-ื‘ื•ื˜
16
  with gr.Blocks(theme="default") as demo:
 
21
  send_button = gr.Button("ืฉืœื—")
22
 
23
  def user_chat(history, message):
24
+ return history + [(message, "")], ""
25
 
26
+ user_input.submit(user_chat, inputs=[chatbot, user_input], outputs=[chatbot, user_input], queue=False)
27
+ user_input.submit(chat_with_model, inputs=chatbot, outputs=chatbot)
28
  send_button.click(user_chat, inputs=[chatbot, user_input], outputs=[chatbot, user_input], queue=False)
29
  send_button.click(chat_with_model, inputs=chatbot, outputs=chatbot)
30