Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # نموذج عربي مفتوح وخفيف | |
| chatbot = pipeline("text-generation", model="akhooli/gpt2-small-arabic", tokenizer="akhooli/gpt2-small-arabic") | |
| def chat(message, history=[]): | |
| prompt = f"المحادثة:\nالمستخدم: {message}\nالمساعد:" | |
| response = chatbot(prompt, max_length=80, num_return_sequences=1, do_sample=True, temperature=0.7)[0]["generated_text"] | |
| reply = response.split("المساعد:")[-1].strip() | |
| history.append((message, reply)) | |
| return history, history | |
| with gr.Blocks() as demo: | |
| gr.ChatInterface(fn=chat, title="شات عربي مجاني", description="بوت دردشة عربي مبسط يعمل عبر Hugging Face", theme="soft") | |
| demo.launch() | |