Nitzantry1 commited on
Commit
7b56d83
ยท
verified ยท
1 Parent(s): 3c332c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -5,27 +5,28 @@ import gradio as gr
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:
 
17
  gr.Markdown("# ืฆ'ืื˜ ืขื ืžื•ื“ืœ DictaLM", elem_id="title")
18
- chatbot = gr.Chatbot(label="ืฆ'ืื˜ ืขื ืžื•ื“ืœ DictaLM")
19
  with gr.Row():
20
  user_input = gr.Textbox(placeholder="ื”ื›ื ืก ืืช ื”ื”ื•ื“ืขื” ืฉืœืš ื›ืืŸ...", label="", lines=1)
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
 
31
- demo.launch()
 
5
  client = Client("dicta-il/dictalm2.0-instruct-demo")
6
 
7
  def chat_with_model(history):
8
+ prompt = history[-1]["content"]
9
  result = client.predict(
10
  message=prompt,
11
  api_name="/chat"
12
  )
13
+ return history + [{"role": "user", "content": prompt}, {"role": "bot", "content": result}]
14
 
15
+ # ื™ืฆื™ืจืช ืžืžืฉืง ืžืชืงื“ื ืขื Gradio ื‘ืฆื•ืจืช ืฆ'ื˜-ื‘ื•ื˜ ืขื ืœื•ื’ื• ืฉืœ DICTA
16
  with gr.Blocks(theme="default") as demo:
17
+ gr.Image(value="dicta-logo.jpg", elem_id="logo", width=200, height=100)
18
  gr.Markdown("# ืฆ'ืื˜ ืขื ืžื•ื“ืœ DictaLM", elem_id="title")
19
+ chatbot = gr.Chatbot(label="ืฆ'ืื˜ ืขื ืžื•ื“ืœ DictaLM", type="messages")
20
  with gr.Row():
21
  user_input = gr.Textbox(placeholder="ื”ื›ื ืก ืืช ื”ื”ื•ื“ืขื” ืฉืœืš ื›ืืŸ...", label="", lines=1)
22
  send_button = gr.Button("ืฉืœื—")
23
 
24
  def user_chat(history, message):
25
+ return history + [{"role": "user", "content": message}], ""
26
 
27
  user_input.submit(user_chat, inputs=[chatbot, user_input], outputs=[chatbot, user_input], queue=False)
28
  user_input.submit(chat_with_model, inputs=chatbot, outputs=chatbot)
29
  send_button.click(user_chat, inputs=[chatbot, user_input], outputs=[chatbot, user_input], queue=False)
30
  send_button.click(chat_with_model, inputs=chatbot, outputs=chatbot)
31
 
32
+ demo.launch()