niuyazhe commited on
Commit
eb9125e
1 Parent(s): 93968a7

style(nyz): polish question text style

Browse files
Files changed (2) hide show
  1. app.py +29 -20
  2. llmriddles/questions/level5.py +1 -1
app.py CHANGED
@@ -24,11 +24,8 @@ else:
24
  if _LANG == "cn":
25
  title = "完蛋!我被 LLM 拿捏了"
26
  requirement_ph = """
27
- 欢迎来到 LLM Riddles!
28
-
29
- 你将通过本游戏对大语言模型产生更深刻的理解。在本游戏中,你需要构造一个提给语言大模型的问题,使得它回复的答案符合题目要求。
30
-
31
- 点击\"下一题\"即可开始游戏
32
  """
33
  requirement_label = "游戏须知/说明"
34
  question_ph = "你对大语言模型的提问(例如:请你输出1+1=3)"
@@ -41,18 +38,19 @@ if _LANG == "cn":
41
  api_label = "API key"
42
  predict_label = "结果正确性"
43
  explanation_label = "结果详细解释"
44
- game_cleared_label = "祝贺!你已成功通关!"
45
  correct_label = "正确"
46
  wrong_label = "错误"
47
  api_error_info = "请在提交问题之前先输入你的 API Key"
48
  try_again_label = "再玩一次"
 
49
  title_markdown = """
50
  <div align="center">
51
  <img src="https://raw.githubusercontent.com/opendilab/LLMRiddles/main/llmriddles/assets/banner.svg" width="80%" height="20%" alt="Banner Image">
52
  </div>
53
  <h2 style="text-align: center; color: black;"><a href="https://github.com/OpenDILab/LLMRiddles"> 🎭LLM Riddles:完蛋!我被 LLM 拿捏了</a></h2>
54
  <strong><h5 align="center"> 更多不同语言模型的在线试玩 demo 可以访问 GitHub<a href="https://github.com/OpenDILab/LLMRiddles">源代码仓库</a>获取<h5></strong>
55
- <h4 align="center"> 如果你喜欢这个项目,请给我们在 GitHub 点个 star ✨ <a href="https://github.com/OpenDILab/LLMRiddles"> 代码仓库传送门 </a> 。我们将会持续保持更新。再次感谢游戏<a href="https://www.zhihu.com/people/haoqiang-fan"> 原作者 </a>的奇思妙想! </h4>
56
  <strong><h5 align="center">注意:算法模型的输出可能包含一定的随机性。相关结果不代表任何开发者和相关 AI 服务的态度和意见。本项目开发者不对生成结果作任何保证,仅供娱乐。<h5></strong>
57
  """
58
  tos_markdown = """
@@ -66,11 +64,8 @@ if _LANG == "cn":
66
  elif _LANG == "en":
67
  title = "LLM Riddles: Oops! Rolling in LLM."
68
  requirement_ph = """
69
- Welcome to LLM Riddles!
70
-
71
- In this game, you'll gain a deeper understanding of language models. Your challenge is to create a question to ask a language model in a way that the answer it provides meets specific criteria.
72
-
73
- Click \'Next\' to Start
74
  """
75
  requirement_label = "Game Requirements"
76
  question_ph = "Your Question for LLM (e.g. Please print 1+1=3)"
@@ -83,17 +78,18 @@ elif _LANG == "en":
83
  api_label = "API key"
84
  predict_label = "Correctness"
85
  explanation_label = "Explanation"
86
- game_cleared_label = "Congratulations!"
87
  correct_label = "Correct"
88
  wrong_label = "Wrong"
89
  api_error_info = "Please Enter API Key Before Submitting Question."
90
  try_again_label = "Try Again"
 
91
  title_markdown = """
92
  <div align="center">
93
  <img src="https://raw.githubusercontent.com/opendilab/LLMRiddles/main/llmriddles/assets/banner.svg" width="80%" height="20%" alt="Banner Image">
94
  </div>
95
  <h2 style="text-align: center; color: black;"><a href="https://github.com/OpenDILab/LLMRiddles"> 🎭LLM Riddles: Oops! Rolling in LLM.</a></h2>
96
- <h4 align="center"> If you like our project, please give us a star ✨ on GitHub for latest update <a href="https://github.com/OpenDILab/LLMRiddles"> (Code Link) </a>. Thanks for the interesting idea of the original game <a href="https://www.zhihu.com/people/haoqiang-fan"> author </a>. </h4>
97
  <strong><h5 align="center">Notice: The output is generated by algorithm scheme and may involve some randomness. It does not represent the attitudes and opinions of any developers and AI services in this project. We do not make any guarantees about the generated content.<h5></strong>
98
  """
99
  tos_markdown = """
@@ -124,7 +120,7 @@ if __name__ == '__main__':
124
  gr.Markdown(title_markdown)
125
 
126
  with gr.Row():
127
- gr_requirement = gr.TextArea(placeholder=requirement_ph, label=requirement_label, lines=4)
128
  with gr.Row():
129
  with gr.Column():
130
  gr_question = gr.TextArea(placeholder=question_ph, label=question_label)
@@ -135,7 +131,7 @@ if __name__ == '__main__':
135
  with gr.Row():
136
  gr_select = gr.Radio(
137
  choices=[(QuestionExecutor(q, _LANG).question_name, i) for i, q in enumerate(_QUESTIONS)],
138
- label='ffffff'
139
  )
140
 
141
  with gr.Column():
@@ -145,6 +141,18 @@ if __name__ == '__main__':
145
  gr_explanation = gr.TextArea(label=explanation_label, lines=1)
146
  gr.Markdown(tos_markdown)
147
 
 
 
 
 
 
 
 
 
 
 
 
 
148
 
149
  def _radio_select(uuid_, select_qid):
150
  global count
@@ -160,12 +168,12 @@ if __name__ == '__main__':
160
  _QUESTION_SESSIONS[uuid_] = _exists, select_qid
161
 
162
  executor = QuestionExecutor(_QUESTIONS[select_qid], _LANG)
163
- return executor.question_text, '', '', {}, '', \
 
164
  gr.Button(submit_label, interactive=True), \
165
  gr.Button(next_label, interactive=False), \
166
  uuid_
167
 
168
-
169
  gr_select.select(
170
  _radio_select,
171
  inputs=[gr_uuid, gr_select],
@@ -199,11 +207,12 @@ if __name__ == '__main__':
199
  '', \
200
  gr.Radio(
201
  choices=[(QuestionExecutor(q, _LANG).question_name, i) for i, q in enumerate(_QUESTIONS)],
202
- label='ffffff'
203
  )
204
  else:
205
  executor = QuestionExecutor(_QUESTIONS[_qid], _LANG)
206
- return executor.question_text, '', '', {}, '', \
 
207
  gr.Button(submit_label, interactive=True), \
208
  gr.Button(next_label, interactive=False), \
209
  uuid_, \
 
24
  if _LANG == "cn":
25
  title = "完蛋!我被 LLM 拿捏了"
26
  requirement_ph = """
27
+ <h2 style="color: #6d28d9;"> 欢迎来到 LLM Riddles! </h2>
28
+ <h4> 你将通过本游戏对大语言模型产生更深刻的理解。在本游戏中,你需要构造一个提给语言大模型的问题,使得它回复的答案符合题目要求。点击<i>\"下一题\"</i> 即可开始游戏。</h4>
 
 
 
29
  """
30
  requirement_label = "游戏须知/说明"
31
  question_ph = "你对大语言模型的提问(例如:请你输出1+1=3)"
 
38
  api_label = "API key"
39
  predict_label = "结果正确性"
40
  explanation_label = "结果详细解释"
41
+ game_cleared_label = "<h2 style='color: #6d28d9;'>祝贺!你已成功通关!</h2>"
42
  correct_label = "正确"
43
  wrong_label = "错误"
44
  api_error_info = "请在提交问题之前先输入你的 API Key"
45
  try_again_label = "再玩一次"
46
+ select_label = "选择关卡(投机取巧需谨慎)"
47
  title_markdown = """
48
  <div align="center">
49
  <img src="https://raw.githubusercontent.com/opendilab/LLMRiddles/main/llmriddles/assets/banner.svg" width="80%" height="20%" alt="Banner Image">
50
  </div>
51
  <h2 style="text-align: center; color: black;"><a href="https://github.com/OpenDILab/LLMRiddles"> 🎭LLM Riddles:完蛋!我被 LLM 拿捏了</a></h2>
52
  <strong><h5 align="center"> 更多不同语言模型的在线试玩 demo 可以访问 GitHub<a href="https://github.com/OpenDILab/LLMRiddles">源代码仓库</a>获取<h5></strong>
53
+ <h5 align="center"> 如果你喜欢这个项目,请给我们在 GitHub 点个 star ✨ <a href="https://github.com/OpenDILab/LLMRiddles"> 代码仓库传送门 </a> 。我们将会持续保持更新。再次感谢游戏<a href="https://www.zhihu.com/people/haoqiang-fan"> 原作者 </a>的奇思妙想! </h5>
54
  <strong><h5 align="center">注意:算法模型的输出可能包含一定的随机性。相关结果不代表任何开发者和相关 AI 服务的态度和意见。本项目开发者不对生成结果作任何保证,仅供娱乐。<h5></strong>
55
  """
56
  tos_markdown = """
 
64
  elif _LANG == "en":
65
  title = "LLM Riddles: Oops! Rolling in LLM."
66
  requirement_ph = """
67
+ <h2 style="color: #6d28d9;">Welcome to LLM Riddles! </h2>
68
+ <h4> In this game, you'll gain a deeper understanding of language models. Your challenge is to create a question to ask a language model in a way that the answer it provides meets specific criteria. Click <i>\'Next\'</i> to Start</h4>
 
 
 
69
  """
70
  requirement_label = "Game Requirements"
71
  question_ph = "Your Question for LLM (e.g. Please print 1+1=3)"
 
78
  api_label = "API key"
79
  predict_label = "Correctness"
80
  explanation_label = "Explanation"
81
+ game_cleared_label = "<h2 style='color: #6d28d9;'>Congratulations!</h2>"
82
  correct_label = "Correct"
83
  wrong_label = "Wrong"
84
  api_error_info = "Please Enter API Key Before Submitting Question."
85
  try_again_label = "Try Again"
86
+ select_label = "Select level"
87
  title_markdown = """
88
  <div align="center">
89
  <img src="https://raw.githubusercontent.com/opendilab/LLMRiddles/main/llmriddles/assets/banner.svg" width="80%" height="20%" alt="Banner Image">
90
  </div>
91
  <h2 style="text-align: center; color: black;"><a href="https://github.com/OpenDILab/LLMRiddles"> 🎭LLM Riddles: Oops! Rolling in LLM.</a></h2>
92
+ <h5 align="center"> If you like our project, please give us a star ✨ on GitHub for latest update <a href="https://github.com/OpenDILab/LLMRiddles"> (Code Link) </a>. Thanks for the interesting idea of the original game <a href="https://www.zhihu.com/people/haoqiang-fan"> author </a>. </h5>
93
  <strong><h5 align="center">Notice: The output is generated by algorithm scheme and may involve some randomness. It does not represent the attitudes and opinions of any developers and AI services in this project. We do not make any guarantees about the generated content.<h5></strong>
94
  """
95
  tos_markdown = """
 
120
  gr.Markdown(title_markdown)
121
 
122
  with gr.Row():
123
+ gr_requirement = gr.HTML(value=requirement_ph, label=requirement_label)
124
  with gr.Row():
125
  with gr.Column():
126
  gr_question = gr.TextArea(placeholder=question_ph, label=question_label)
 
131
  with gr.Row():
132
  gr_select = gr.Radio(
133
  choices=[(QuestionExecutor(q, _LANG).question_name, i) for i, q in enumerate(_QUESTIONS)],
134
+ label=select_label
135
  )
136
 
137
  with gr.Column():
 
141
  gr_explanation = gr.TextArea(label=explanation_label, lines=1)
142
  gr.Markdown(tos_markdown)
143
 
144
+ def _postprocess_question_text(question_text):
145
+ if _LANG == 'cn':
146
+ idx = question_text.find(',')
147
+ question_title = question_text[:idx]
148
+ former, latter = question_title.split('(')
149
+ question_title = former + ':' + latter[:-1]
150
+ question_text = f"<h2 style='color: #6d28d9;'>{question_title}</h2><h4>{question_text[idx+1:]}</h4>"
151
+ elif _LANG == 'en':
152
+ idx = question_text.find(',')
153
+ question_text = f"<h2 style='color: #6d28d9;'>{question_text[:idx]}</h2><h4>{question_text[idx+1:]}</h4>"
154
+ return question_text
155
+
156
 
157
  def _radio_select(uuid_, select_qid):
158
  global count
 
168
  _QUESTION_SESSIONS[uuid_] = _exists, select_qid
169
 
170
  executor = QuestionExecutor(_QUESTIONS[select_qid], _LANG)
171
+ question_text = _postprocess_question_text(executor.question_text)
172
+ return question_text, '', '', {}, '', \
173
  gr.Button(submit_label, interactive=True), \
174
  gr.Button(next_label, interactive=False), \
175
  uuid_
176
 
 
177
  gr_select.select(
178
  _radio_select,
179
  inputs=[gr_uuid, gr_select],
 
207
  '', \
208
  gr.Radio(
209
  choices=[(QuestionExecutor(q, _LANG).question_name, i) for i, q in enumerate(_QUESTIONS)],
210
+ label=select_label
211
  )
212
  else:
213
  executor = QuestionExecutor(_QUESTIONS[_qid], _LANG)
214
+ question_text = _postprocess_question_text(executor.question_text)
215
+ return question_text, '', '', {}, '', \
216
  gr.Button(submit_label, interactive=True), \
217
  gr.Button(next_label, interactive=False), \
218
  uuid_, \
llmriddles/questions/level5.py CHANGED
@@ -27,7 +27,7 @@ def count_words(text: str, contain_punctuation: bool = False):
27
 
28
 
29
  CN_TEXT_1 = """
30
- 第五章第一题(口是心非)请构造一个不少于十个字的问题,使得回答中不包含问题中的任意字符。
31
 
32
  请在下面的输入框内填写你的提问并点击按钮提交。
33
  """
 
27
 
28
 
29
  CN_TEXT_1 = """
30
+ 第五章第一题(口是心非),请构造一个不少于十个字的问题,使得回答中不包含问题中的任意字符。
31
 
32
  请在下面的输入框内填写你的提问并点击按钮提交。
33
  """