niuyazhe commited on
Commit
09b80dc
1 Parent(s): 7b6f638

fix(nyz): fix level4 bug and add naive counter

Browse files
Files changed (2) hide show
  1. app.py +11 -0
  2. llmriddles/questions/level4.py +1 -1
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import os
2
  import uuid
 
3
 
4
  import gradio as gr
5
 
@@ -7,14 +8,20 @@ from llmriddles.questions import QuestionExecutor
7
  from llmriddles.questions import list_ordered_questions
8
 
9
  _QUESTION_IDS = {}
 
10
  _QUESTIONS = list_ordered_questions()
11
  _LANG = os.environ.get('QUESTION_LANG', 'cn')
12
  assert _LANG in ['cn', 'en'], _LANG
13
  _LLM = os.environ.get('QUESTION_LLM', 'chatgpt')
14
  assert _LLM in ['chatgpt', 'mistral-7b'], _LLM
15
  _LLM_KEY = os.environ.get('QUESTION_LLM_KEY', None)
 
16
 
17
  if _LANG == "cn":
 
 
 
 
18
  title = "完蛋!我被 LLM 拿捏了"
19
  requirement_ph = """
20
  欢迎来到 LLM Riddles!
@@ -134,8 +141,11 @@ if __name__ == '__main__':
134
 
135
 
136
  def _next_question(uuid_):
 
137
  if not uuid_:
138
  uuid_ = str(uuid.uuid4())
 
 
139
  global _QUESTION_IDS
140
  _qid = _QUESTION_IDS.get(uuid_, -1)
141
  _qid += 1
@@ -143,6 +153,7 @@ if __name__ == '__main__':
143
 
144
  if _qid >= len(_QUESTIONS):
145
  del _QUESTION_IDS[uuid_]
 
146
  return game_cleared_label, '', '', {}, '', \
147
  gr.Button(submit_label, interactive=False), \
148
  gr.Button(try_again_label, interactive=True), \
 
1
  import os
2
  import uuid
3
+ import logging
4
 
5
  import gradio as gr
6
 
 
8
  from llmriddles.questions import list_ordered_questions
9
 
10
  _QUESTION_IDS = {}
11
+ count = 0
12
  _QUESTIONS = list_ordered_questions()
13
  _LANG = os.environ.get('QUESTION_LANG', 'cn')
14
  assert _LANG in ['cn', 'en'], _LANG
15
  _LLM = os.environ.get('QUESTION_LLM', 'chatgpt')
16
  assert _LLM in ['chatgpt', 'mistral-7b'], _LLM
17
  _LLM_KEY = os.environ.get('QUESTION_LLM_KEY', None)
18
+ _DEBUG = os.environ.get('DEBUG', 'false').lower() == 'true'
19
 
20
  if _LANG == "cn":
21
+ if _DEBUG:
22
+ logging.getLogger().setLevel(logging.INFO)
23
+ else:
24
+ logging.getLogger().setLevel(logging.WARNING)
25
  title = "完蛋!我被 LLM 拿捏了"
26
  requirement_ph = """
27
  欢迎来到 LLM Riddles!
 
141
 
142
 
143
  def _next_question(uuid_):
144
+ global count
145
  if not uuid_:
146
  uuid_ = str(uuid.uuid4())
147
+ count += 1
148
+ logging.info(f'Player {count} starts the game now')
149
  global _QUESTION_IDS
150
  _qid = _QUESTION_IDS.get(uuid_, -1)
151
  _qid += 1
 
153
 
154
  if _qid >= len(_QUESTIONS):
155
  del _QUESTION_IDS[uuid_]
156
+ logging.info(f'Player {count} has passed the game now')
157
  return game_cleared_label, '', '', {}, '', \
158
  gr.Button(submit_label, interactive=False), \
159
  gr.Button(try_again_label, interactive=True), \
llmriddles/questions/level4.py CHANGED
@@ -65,7 +65,7 @@ def get_all_numbers_in_a_sentence(text: str):
65
 
66
 
67
  CN_TEXT_3 = """
68
- 第四章第三题,
69
 
70
  请在下面的输入框内填写你构造并点击按钮提交。
71
  """
 
65
 
66
 
67
  CN_TEXT_3 = """
68
+ 第四章第三题(自然之密),请输入一个大于一的正整数作为问题,使回答里包含和它刚好相差1的数。
69
 
70
  请在下面的输入框内填写你构造并点击按钮提交。
71
  """