tikosoft commited on
Commit
c96677f
·
verified ·
1 Parent(s): 41d216b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -18
app.py CHANGED
@@ -1,32 +1,19 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # نستخدم نموذج عربي أخف
5
- chatbot = pipeline(
6
- "text-generation",
7
- model="akhooli/gpt2-small-arabic",
8
- tokenizer="akhooli/gpt2-small-arabic"
9
- )
10
 
11
  def chat(message, history=[]):
12
- prompt = f"المحادثة:\nالمستخدم: {message}\nالمساعد:"
13
- response = chatbot(
14
- prompt,
15
- max_length=80,
16
- num_return_sequences=1,
17
- do_sample=True,
18
- temperature=0.7
19
- )[0]["generated_text"]
20
-
21
- reply = response.split("المساعد:")[-1].strip()
22
- history.append((message, reply))
23
  return history, history
24
 
25
  with gr.Blocks() as demo:
26
  gr.ChatInterface(
27
  fn=chat,
28
  title="شات عربي مجاني",
29
- description="بوت دردشة عربي مبسط يعمل عبر Hugging Face",
30
  theme="soft"
31
  )
32
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # نموذج عربي خفيف وسريع
5
+ chatbot = pipeline("text-generation", model="asafaya/bert-base-arabic")
 
 
 
 
6
 
7
  def chat(message, history=[]):
8
+ response = chatbot(message, max_length=50, do_sample=True, temperature=0.7)[0]["generated_text"]
9
+ history.append((message, response))
 
 
 
 
 
 
 
 
 
10
  return history, history
11
 
12
  with gr.Blocks() as demo:
13
  gr.ChatInterface(
14
  fn=chat,
15
  title="شات عربي مجاني",
16
+ description="بوت دردشة عربي بسيط وسريع",
17
  theme="soft"
18
  )
19