eisssa107 commited on
Commit
e0782f7
·
verified ·
1 Parent(s): a2c895c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -1,21 +1,23 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # تحميل النموذج محلياً
5
- chatbot_model = pipeline(
6
- "text-generation",
7
- model="microsoft/DialoGPT-small",
8
- max_new_tokens=100
9
- )
10
 
11
  def chat(message, history):
12
  history = history or []
13
  if not message.strip():
14
  return history, ""
15
-
16
  try:
17
- response = chatbot_model(message)[0]["generated_text"]
18
- bot_reply = response.replace(message, "").strip()
 
 
 
 
 
 
19
  if not bot_reply:
20
  bot_reply = "أخبرني أكثر!"
21
  except Exception as e:
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ print("جاري تحميل النموذج...")
5
+ chatbot_model = pipeline("text-generation", model="microsoft/DialoGPT-small")
6
+ print("تم تحميل النموذج!")
 
 
 
7
 
8
  def chat(message, history):
9
  history = history or []
10
  if not message.strip():
11
  return history, ""
 
12
  try:
13
+ result = chatbot_model(
14
+ message,
15
+ max_new_tokens=80,
16
+ do_sample=True,
17
+ temperature=0.7,
18
+ pad_token_id=50256
19
+ )
20
+ bot_reply = result[0]["generated_text"].replace(message, "").strip()
21
  if not bot_reply:
22
  bot_reply = "أخبرني أكثر!"
23
  except Exception as e: