Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -26,32 +26,16 @@ def chat(input_text, history=[]):
|
|
26 |
|
27 |
|
28 |
with gr.Blocks() as app:
|
29 |
-
gr.Markdown("<h1 style='text-align: center;'>دردشة
|
30 |
chatbot = gr.Chatbot(label="المحادثة")
|
31 |
state = gr.State([])
|
32 |
|
33 |
with gr.Row():
|
34 |
-
txt = gr.Textbox(show_label=False, placeholder="اكتب رسالتك هنا...")
|
35 |
send_button = gr.Button("إرسال")
|
36 |
|
37 |
-
#
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
def bot_response(history):
|
42 |
-
user_message = history[-1][0]
|
43 |
-
inputs = tokenizer(user_message, return_tensors="pt").to(model.device)
|
44 |
-
outputs = model.generate(**inputs, max_new_tokens=150)
|
45 |
-
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
46 |
-
history[-1][1] = response
|
47 |
-
return history
|
48 |
-
|
49 |
-
# Link functions to button clicks
|
50 |
-
txt.submit(user_input, [txt, state], [txt, state]).then(
|
51 |
-
bot_response, state, chatbot
|
52 |
-
)
|
53 |
-
send_button.click(user_input, [txt, state], [txt, state]).then(
|
54 |
-
bot_response, state, chatbot
|
55 |
-
)
|
56 |
|
57 |
app.launch()
|
|
|
26 |
|
27 |
|
28 |
with gr.Blocks() as app:
|
29 |
+
gr.Markdown("<h1 style='text-align: center;'>دردشة أطلس-شات 27B</h1>")
|
30 |
chatbot = gr.Chatbot(label="المحادثة")
|
31 |
state = gr.State([])
|
32 |
|
33 |
with gr.Row():
|
34 |
+
txt = gr.Textbox(show_label=False, placeholder="اكتب رسالتك هنا...")
|
35 |
send_button = gr.Button("إرسال")
|
36 |
|
37 |
+
# Link the chat function to both text submission and button click
|
38 |
+
txt.submit(chat, [txt, state], [chatbot, state])
|
39 |
+
send_button.click(chat, [txt, state], [chatbot, state])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
app.launch()
|