Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| from langdetect import detect | |
| model_name = "aubmindlab/aragpt2-base" | |
| chatbot = pipeline("text-generation", model=model_name) | |
| def reply(prompt): | |
| if prompt.strip() == "": | |
| return "يرجى إدخال نص." | |
| try: | |
| lang = detect(prompt) | |
| except: | |
| lang = "ar" | |
| response = chatbot(prompt, max_length=100, do_sample=True)[0]["generated_text"] | |
| return response.strip() | |
| interface = gr.Interface( | |
| fn=reply, | |
| inputs=gr.Textbox(label="📝 أدخل نصًا بأي لغة"), | |
| outputs=gr.Textbox(label="💬 رد الوكيل"), | |
| title="🌍 TunisAI-Agent — ذكاء صناعي متعدد اللغات", | |
| description="وكيل ذكاء صناعي مجاني يعمل بأي لغة 🧠🌐" | |
| ) | |
| interface.launch(share=True) | |