skdjhfvvewhuisol commited on
Commit
793a8d7
1 Parent(s): 9334d9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -4,7 +4,8 @@ from huggingface_hub import InferenceClient
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
- client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
 
8
 
9
 
10
  def respond(
@@ -17,16 +18,19 @@ def respond(
17
  ):
18
  messages = [{"role": "system", "content": system_message}]
19
 
 
20
  for val in history:
21
  if val[0]:
22
  messages.append({"role": "user", "content": val[0]})
23
  if val[1]:
24
  messages.append({"role": "assistant", "content": val[1]})
25
 
 
26
  messages.append({"role": "user", "content": message})
27
 
28
  response = ""
29
 
 
30
  for message in client.chat_completion(
31
  messages,
32
  max_tokens=max_tokens,
@@ -35,7 +39,6 @@ def respond(
35
  top_p=top_p,
36
  ):
37
  token = message.choices[0].delta.content
38
-
39
  response += token
40
  yield response
41
 
@@ -59,6 +62,5 @@ demo = gr.ChatInterface(
59
  ],
60
  )
61
 
62
-
63
  if __name__ == "__main__":
64
  demo.launch()
 
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
+ # استخدم GPT-J بدلاً من Zephyr-7B-beta
8
+ client = InferenceClient("EleutherAI/gpt-j-6B")
9
 
10
 
11
  def respond(
 
18
  ):
19
  messages = [{"role": "system", "content": system_message}]
20
 
21
+ # إضافة المحادثات السابقة إذا كانت موجودة
22
  for val in history:
23
  if val[0]:
24
  messages.append({"role": "user", "content": val[0]})
25
  if val[1]:
26
  messages.append({"role": "assistant", "content": val[1]})
27
 
28
+ # إضافة الرسالة الجديدة
29
  messages.append({"role": "user", "content": message})
30
 
31
  response = ""
32
 
33
+ # استخدام واجهة Inference API مع GPT-J
34
  for message in client.chat_completion(
35
  messages,
36
  max_tokens=max_tokens,
 
39
  top_p=top_p,
40
  ):
41
  token = message.choices[0].delta.content
 
42
  response += token
43
  yield response
44
 
 
62
  ],
63
  )
64
 
 
65
  if __name__ == "__main__":
66
  demo.launch()