ghariani commited on
Commit
4710fe2
·
verified ·
1 Parent(s): fcddfa4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -13
app.py CHANGED
@@ -1,17 +1,24 @@
1
-
2
  import gradio as gr
3
- import datetime
4
 
5
- def agent(prompt):
6
- now = datetime.datetime.now()
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
- demo = gr.Interface(fn=agent, inputs="text", outputs="text", title="TunisAI-Agent",
15
- description="وكيل ذكاء صناعي مجاني مطور في تونس 🇹🇳")
16
- interface.launch(share=True)
 
 
 
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)