Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,19 +5,18 @@ import gradio as gr
|
|
5 |
client = Client("dicta-il/dictalm2.0-instruct-demo")
|
6 |
|
7 |
def chat_with_model(history):
|
|
|
8 |
prompt = history[-1]["content"]
|
9 |
-
|
10 |
-
|
11 |
-
api_name="/chat"
|
12 |
-
)
|
13 |
return history + [{"role": "user", "content": prompt}, {"role": "bot", "content": result}]
|
14 |
|
15 |
# ืืฆืืจืช ืืืฉืง ืืชืงืื ืขื Gradio ืืฆืืจืช ืฆ'ื-ืืื ืืกืื ืื ืืงืืื
|
16 |
with gr.Blocks(theme="default") as demo:
|
17 |
gr.HTML("""
|
18 |
<div style="background-color: #f5f5f5; padding: 20px; text-align: center;">
|
19 |
-
<h1 style="color: #003366; font-family:
|
20 |
-
<p style="font-family:
|
21 |
</div>
|
22 |
""")
|
23 |
chatbot = gr.Chatbot(label="ืฆ'ืื ืขื ืืืื DictaLM", type="messages")
|
@@ -26,12 +25,15 @@ with gr.Blocks(theme="default") as demo:
|
|
26 |
send_button = gr.Button("ืฉืื")
|
27 |
|
28 |
def user_chat(history, message):
|
|
|
29 |
return history + [{"role": "user", "content": message}], ""
|
30 |
|
31 |
-
#
|
32 |
-
user_input.submit(user_chat, inputs=[chatbot, user_input], outputs=[chatbot, user_input], queue=False)
|
33 |
-
|
34 |
-
|
35 |
-
send_button.click(
|
|
|
|
|
36 |
|
37 |
demo.launch()
|
|
|
5 |
client = Client("dicta-il/dictalm2.0-instruct-demo")
|
6 |
|
7 |
def chat_with_model(history):
|
8 |
+
# ืงืืืช ืืืืืขื ืืืืจืื ื ืฉื ืฉืืื ืขื ืืื ืืืฉืชืืฉ
|
9 |
prompt = history[-1]["content"]
|
10 |
+
# ืฉืืืืช ืืืืืขื ืืืืื ืืงืืืช ืชืืืื
|
11 |
+
result = client.predict(message=prompt, api_name="/chat")
|
|
|
|
|
12 |
return history + [{"role": "user", "content": prompt}, {"role": "bot", "content": result}]
|
13 |
|
14 |
# ืืฆืืจืช ืืืฉืง ืืชืงืื ืขื Gradio ืืฆืืจืช ืฆ'ื-ืืื ืืกืื ืื ืืงืืื
|
15 |
with gr.Blocks(theme="default") as demo:
|
16 |
gr.HTML("""
|
17 |
<div style="background-color: #f5f5f5; padding: 20px; text-align: center;">
|
18 |
+
<h1 style="color: #003366; font-family: Arial, sans-serif;">ืฆ'ืื ืขื ืืืื DictaLM</h1>
|
19 |
+
<p style="font-family: Arial, sans-serif; color: #333;">ืืจืืืื ืืืืื ืืฆ'ืื ืืืื ืืจืืงืืืื ืฉืื ื, ืืืืคืฉืจ ืืื ืืืชื ืกืืช ืืฉืืื ืขื ืืืื AI ืืชืงืื.</p>
|
20 |
</div>
|
21 |
""")
|
22 |
chatbot = gr.Chatbot(label="ืฆ'ืื ืขื ืืืื DictaLM", type="messages")
|
|
|
25 |
send_button = gr.Button("ืฉืื")
|
26 |
|
27 |
def user_chat(history, message):
|
28 |
+
# ืืืกืคืช ืืืืขืช ืืืฉืชืืฉ ืืืืกืืืจืื ืืคื ื ืฉืืืืช ืืฉืืื ืืืืื
|
29 |
return history + [{"role": "user", "content": message}], ""
|
30 |
|
31 |
+
# ืฉืืืืช ืืืืืขื ืื ืืืืืฆื ืขื Enter ืืื ืขื ืืื ืืืืฆื ืขื ืืคืชืืจ "ืฉืื"
|
32 |
+
user_input.submit(fn=user_chat, inputs=[chatbot, user_input], outputs=[chatbot, user_input], queue=False).then(
|
33 |
+
fn=chat_with_model, inputs=chatbot, outputs=chatbot
|
34 |
+
)
|
35 |
+
send_button.click(fn=user_chat, inputs=[chatbot, user_input], outputs=[chatbot, user_input], queue=False).then(
|
36 |
+
fn=chat_with_model, inputs=chatbot, outputs=chatbot
|
37 |
+
)
|
38 |
|
39 |
demo.launch()
|