Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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][
|
9 |
result = client.predict(
|
10 |
message=prompt,
|
11 |
api_name="/chat"
|
12 |
)
|
13 |
-
return history + [
|
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 + [
|
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()
|