Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,24 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
3 |
-
import
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
if "تونس" in prompt.lower():
|
8 |
-
return f"🇹🇳 أنا وكيل ذكاء صناعي مجاني طور في تونس. سؤالك: {prompt}"
|
9 |
-
elif "ساعة" in prompt or "الوقت":
|
10 |
-
return f"⏰ الساعة الآن في تونس: {now.strftime('%H:%M')}"
|
11 |
-
else:
|
12 |
-
return f"🤖 تلقيت سؤالك: {prompt} (سيتم تحسين الذكاء لاحقًا)"
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# تحميل النموذج
|
5 |
+
chatbot = pipeline("text-generation", model="aubmindlab/aragpt2-base")
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
# الدالة التي تستقبل وترد
|
8 |
+
def reply(prompt):
|
9 |
+
if prompt.strip() == "":
|
10 |
+
return "يرجى إدخال نص."
|
11 |
+
response = chatbot(prompt, max_length=100, do_sample=True)[0]["generated_text"]
|
12 |
+
return response
|
13 |
|
14 |
+
# بناء الواجهة
|
15 |
+
interface = gr.Interface(
|
16 |
+
fn=reply,
|
17 |
+
inputs=gr.Textbox(label="prompt"),
|
18 |
+
outputs=gr.Textbox(label="output"),
|
19 |
+
title="TunisAI-Agent",
|
20 |
+
description="وكيل ذكاء صناعي مجاني مطور في تونس 🇹🇳"
|
21 |
+
)
|
22 |
+
|
23 |
+
# إطلاق التطبيق مع رابط عام
|
24 |
+
interface.launch(share=True)
|