Spaces:
Sleeping
Sleeping
Nitzantry1
commited on
Commit
โข
8239d17
1
Parent(s):
53a67f8
Update app.py
Browse files
app.py
CHANGED
@@ -4,20 +4,26 @@ import gradio as gr
|
|
4 |
# ืืืืืจ ื-Space ืขื ืืืืื ื-Hugging Face
|
5 |
client = Client("dicta-il/dictalm2.0-instruct-demo")
|
6 |
|
7 |
-
def chat_with_model(
|
|
|
8 |
result = client.predict(
|
9 |
message=prompt,
|
10 |
api_name="/chat"
|
11 |
)
|
12 |
-
return result
|
13 |
|
14 |
-
# ืืฆืืจืช ืืืฉืง ืืชืงืื ืขื Gradio
|
15 |
-
with gr.Blocks() as demo:
|
16 |
-
gr.Markdown("#
|
|
|
17 |
with gr.Row():
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
|
23 |
demo.launch()
|
|
|
4 |
# ืืืืืจ ื-Space ืขื ืืืืื ื-Hugging Face
|
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:
|
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 + [{"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 |
|
29 |
demo.launch()
|