Spaces:
Build error
Build error
| # app.py | |
| import gradio as gr | |
| from transformers import pipeline | |
| # تهيئة موديل ChatGPT من Hugging Face | |
| chatbot = pipeline("text-generation", model="phamxuankhoa/chatgpt") | |
| def chat_ar(input_text): | |
| if not input_text: | |
| return "الرجاء كتابة نص للتجربة." | |
| # توليد الرد من الموديل | |
| result = chatbot(input_text, max_length=200, do_sample=True) | |
| return result[0]["generated_text"] | |
| # واجهة Gradio بالعربية | |
| iface = gr.Interface( | |
| fn=chat_ar, | |
| inputs=gr.Textbox(lines=5, placeholder="اكتب رسالتك هنا..."), | |
| outputs=gr.Textbox(label="رد الذكاء الاصطناعي"), | |
| title="دردشة ChatGPT بالعربية", | |
| description="تجربة نموذج ChatGPT لإرسال النصوص واستقبال الردود باللغة العربية." | |
| ) | |
| iface.launch() |