Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,31 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# نموذج عربي خفيف
|
| 5 |
-
chatbot = pipeline(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def chat(message, history=[]):
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return history, history
|
| 11 |
|
| 12 |
with gr.Blocks() as demo:
|
| 13 |
gr.ChatInterface(
|
| 14 |
fn=chat,
|
| 15 |
title="شات عربي مجاني",
|
| 16 |
-
description="بوت دردشة عربي
|
| 17 |
theme="soft"
|
| 18 |
)
|
| 19 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# نموذج عربي مولد نصوص خفيف
|
| 5 |
+
chatbot = pipeline(
|
| 6 |
+
"text-generation",
|
| 7 |
+
model="aubmindlab/aragpt2-small",
|
| 8 |
+
tokenizer="aubmindlab/aragpt2-small"
|
| 9 |
+
)
|
| 10 |
|
| 11 |
def chat(message, history=[]):
|
| 12 |
+
prompt = f"المحادثة:\nالمستخدم: {message}\nالمساعد:"
|
| 13 |
+
response = chatbot(
|
| 14 |
+
prompt,
|
| 15 |
+
max_length=80,
|
| 16 |
+
num_return_sequences=1,
|
| 17 |
+
do_sample=True,
|
| 18 |
+
temperature=0.7
|
| 19 |
+
)[0]["generated_text"]
|
| 20 |
+
reply = response.split("المساعد:")[-1].strip()
|
| 21 |
+
history.append((message, reply))
|
| 22 |
return history, history
|
| 23 |
|
| 24 |
with gr.Blocks() as demo:
|
| 25 |
gr.ChatInterface(
|
| 26 |
fn=chat,
|
| 27 |
title="شات عربي مجاني",
|
| 28 |
+
description="بوت دردشة عربي مبسط يعمل عبر Hugging Face",
|
| 29 |
theme="soft"
|
| 30 |
)
|
| 31 |
|