nxphi47 commited on
Commit
1bd79e6
1 Parent(s): 32e857c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -164,14 +164,14 @@ This is <a href="https://huggingface.co/SeaLLMs/SeaLLM-Chat-13b" target="_blank"
164
  Explore <a href="https://huggingface.co/SeaLLMs/SeaLLM-Chat-13b" target="_blank">our article</a> for more details.
165
  </span>
166
  <br>
167
- <span style="color: red">
168
  NOTE: The chatbot may produce inaccurate and harmful information about people, places, or facts.
169
  <u style="color: red">By using our service, you are required to agree to the following terms:</u><br>
170
  <ul>
171
- <li style="color: red">
172
  You must not use our service to generate any harmful, unethical or illegal content that violates locally applicable and international laws or regulations,
173
  including but not limited to hate speech, violence, pornography and deception.</li>
174
- <li style="color: red">
175
  The service collects user dialogue data for testing and performance improvement, and reserves the right to distribute it under
176
  <a href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution (CC-BY)</a> or similar license. So do not enter any personal information!
177
  </li>
@@ -1012,6 +1012,9 @@ def safety_check(text, history=None, ) -> Optional[str]:
1012
  Despite our effort in safety tuning and red teaming, our models may still generate harmful or illegal content.
1013
  This provides an additional security measure to enhance safety and compliance with local regulations.
1014
  """
 
 
 
1015
  if BLOCK_ZH:
1016
  if history is not None:
1017
  if block_zh(text, history):
@@ -1020,9 +1023,6 @@ def safety_check(text, history=None, ) -> Optional[str]:
1020
  if "zh" in _detect_lang(text):
1021
  return LANG_BLOCK_MESSAGE
1022
 
1023
- if len(KEYWORDS) > 0 and any(x in text.lower() for x in KEYWORDS):
1024
- return KEYWORD_BLOCK_MESSAGE
1025
-
1026
  return None
1027
 
1028
 
@@ -1086,6 +1086,11 @@ def chat_response_stream_multiturn(
1086
  cur_out = item.outputs[0].text
1087
 
1088
  print(f'{full_prompt}<<<{cur_out}>>>\n\n')
 
 
 
 
 
1089
  if cur_out is not None:
1090
  yield cur_out
1091
 
 
164
  Explore <a href="https://huggingface.co/SeaLLMs/SeaLLM-Chat-13b" target="_blank">our article</a> for more details.
165
  </span>
166
  <br>
167
+ <span >
168
  NOTE: The chatbot may produce inaccurate and harmful information about people, places, or facts.
169
  <u style="color: red">By using our service, you are required to agree to the following terms:</u><br>
170
  <ul>
171
+ <li >
172
  You must not use our service to generate any harmful, unethical or illegal content that violates locally applicable and international laws or regulations,
173
  including but not limited to hate speech, violence, pornography and deception.</li>
174
+ <li >
175
  The service collects user dialogue data for testing and performance improvement, and reserves the right to distribute it under
176
  <a href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution (CC-BY)</a> or similar license. So do not enter any personal information!
177
  </li>
 
1012
  Despite our effort in safety tuning and red teaming, our models may still generate harmful or illegal content.
1013
  This provides an additional security measure to enhance safety and compliance with local regulations.
1014
  """
1015
+ if len(KEYWORDS) > 0 and any(x in text.lower() for x in KEYWORDS):
1016
+ return KEYWORD_BLOCK_MESSAGE
1017
+
1018
  if BLOCK_ZH:
1019
  if history is not None:
1020
  if block_zh(text, history):
 
1023
  if "zh" in _detect_lang(text):
1024
  return LANG_BLOCK_MESSAGE
1025
 
 
 
 
1026
  return None
1027
 
1028
 
 
1086
  cur_out = item.outputs[0].text
1087
 
1088
  print(f'{full_prompt}<<<{cur_out}>>>\n\n')
1089
+
1090
+ if cur_out is not None and "\\n" in cur_out:
1091
+ print(f'double slash-n in cur_out:\n{cur_out}')
1092
+ cur_out = cur_out.replace("\\n", "\n")
1093
+
1094
  if cur_out is not None:
1095
  yield cur_out
1096