hiyouga commited on
Commit
6be3233
1 Parent(s): 008f530

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -9,6 +9,8 @@ TITLE = "<h1><center>Chat with Llama3-8B-Chinese-Chat-v2</center></h1>"
9
 
10
  DESCRIPTION = "<h3><center>Visit <a href='https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat' target='_blank'>our model page</a> for details.</center></h3>"
11
 
 
 
12
  TOOL_EXAMPLE = '''You have access to the following tools:
13
  ```python
14
  def generate_password(length: int, include_symbols: Optional[bool]):
@@ -50,7 +52,7 @@ model = AutoModelForCausalLM.from_pretrained("shenzhi-wang/Llama3-8B-Chinese-Cha
50
 
51
  @spaces.GPU
52
  def stream_chat(message: str, history: list, system: str, temperature: float, max_new_tokens: int):
53
- conversation = [{"role": "system", "content": system}]
54
  for prompt, answer in history:
55
  conversation.extend([{"role": "user", "content": prompt}, {"role": "assistant", "content": answer}])
56
 
@@ -115,8 +117,8 @@ with gr.Blocks(css=CSS) as demo:
115
  ),
116
  ],
117
  examples=[
118
- ["我的蓝牙耳机坏了,我该去看牙科还是耳鼻喉科?", "You are a helpful assistant."],
119
- ["小明有18支铅笔和24张纸,他想将它们分成每份相同的组,每组既有铅笔又有纸,问他最少可以分成几组,每组有多少支铅笔和多少张纸?", "You are a helpful assistant."],
120
  ["我的笔记本找不到了。", "扮演诸葛亮和我对话。"],
121
  ["我想要一个新的密码,长度为8位,包含特殊符号。", TOOL_EXAMPLE],
122
  ],
 
9
 
10
  DESCRIPTION = "<h3><center>Visit <a href='https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat' target='_blank'>our model page</a> for details.</center></h3>"
11
 
12
+ DEFAULT_SYSTEM = "You are Llama3-8B-Chinese-Chat-v2, finetuned from Llama3-8B-Instruct on Chinese-English dataset using the ORPO algorithm. You are a helpful assistant."
13
+
14
  TOOL_EXAMPLE = '''You have access to the following tools:
15
  ```python
16
  def generate_password(length: int, include_symbols: Optional[bool]):
 
52
 
53
  @spaces.GPU
54
  def stream_chat(message: str, history: list, system: str, temperature: float, max_new_tokens: int):
55
+ conversation = [{"role": "system", "content": system or DEFAULT_SYSTEM}]
56
  for prompt, answer in history:
57
  conversation.extend([{"role": "user", "content": prompt}, {"role": "assistant", "content": answer}])
58
 
 
117
  ),
118
  ],
119
  examples=[
120
+ ["我的蓝牙耳机坏了,我该去看牙科还是耳鼻喉科?", ""],
121
+ ["小明有18支铅笔和24张纸,他想将它们分成每份相同的组,每组既有铅笔又有纸,问他最少可以分成几组,每组有多少支铅笔和多少张纸?", ""],
122
  ["我的笔记本找不到了。", "扮演诸葛亮和我对话。"],
123
  ["我想要一个新的密码,长度为8位,包含特殊符号。", TOOL_EXAMPLE],
124
  ],