Spaces:
Runtime error
Runtime error
Yoon-gu Hwang
commited on
Commit
β’
21ef542
1
Parent(s):
9c8b9fe
add skip
Browse files
app.py
CHANGED
@@ -109,12 +109,7 @@ with gr.Blocks() as demo:
|
|
109 |
info[user]['score'] += 1
|
110 |
info[user]['count'] += 1
|
111 |
bot_message = f"πμ λ΅μ
λλ€! λ€μ λ¬Έμ μ
λλ€.\n{q}\n- νμ¬ μ μ: {info[user]['score']}μ \n- μμ μκ°: {time.time() - info[user]['time']:4.3f}μ΄"
|
112 |
-
|
113 |
-
bot_message = f"λͺ¨λ ν΄μ¦λ₯Ό λ€ νμμ΅λλ€. μ μλ {info[user]['score']:3.1f}μ μ
λλ€."
|
114 |
-
info[user]['done'] = True
|
115 |
-
if info[user]['score'] >= info[user]['best_score']:
|
116 |
-
info[user]['best_score'] = info[user]['score']
|
117 |
-
info[user]['best_time'] = min(time.time() - info[user]['time'], info[user]['best_time'])
|
118 |
elif "ν΄μ¦μ’
λ£" == message.replace(" ", ""):
|
119 |
bot_message = f"ν΄μ¦λ₯Ό κ°μ μ’
λ£ν©λλ€."
|
120 |
info[user]['done'] = True
|
@@ -135,9 +130,21 @@ with gr.Blocks() as demo:
|
|
135 |
hint1 += "X"
|
136 |
bot_message = f"***{message}***!? π§ λ€μ νλ² μκ°ν΄λ³΄μΈμ.\nννΈ: {hint1}"
|
137 |
info[user]['score'] -= 0.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
chat_history.append((message, bot_message))
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
play.click(respond,
|
143 |
inputs=[play, chatbot, user, quiz_count, generation, poke_types],
|
@@ -148,11 +155,13 @@ with gr.Blocks() as demo:
|
|
148 |
stop.click(respond,
|
149 |
inputs=[stop, chatbot, user, quiz_count, generation, poke_types],
|
150 |
outputs=[msg, chatbot, markdown])
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
156 |
inputs=None,
|
157 |
outputs=markdown)
|
158 |
msg.submit(respond, [msg, chatbot, user, quiz_count, generation, poke_types], [msg, chatbot, markdown])
|
|
|
109 |
info[user]['score'] += 1
|
110 |
info[user]['count'] += 1
|
111 |
bot_message = f"πμ λ΅μ
λλ€! λ€μ λ¬Έμ μ
λλ€.\n{q}\n- νμ¬ μ μ: {info[user]['score']}μ \n- μμ μκ°: {time.time() - info[user]['time']:4.3f}μ΄"
|
112 |
+
|
|
|
|
|
|
|
|
|
|
|
113 |
elif "ν΄μ¦μ’
λ£" == message.replace(" ", ""):
|
114 |
bot_message = f"ν΄μ¦λ₯Ό κ°μ μ’
λ£ν©λλ€."
|
115 |
info[user]['done'] = True
|
|
|
130 |
hint1 += "X"
|
131 |
bot_message = f"***{message}***!? π§ λ€μ νλ² μκ°ν΄λ³΄μΈμ.\nννΈ: {hint1}"
|
132 |
info[user]['score'] -= 0.1
|
133 |
+
|
134 |
+
if quiz_count == info[user]['count']:
|
135 |
+
bot_message = f"λͺ¨λ ν΄μ¦λ₯Ό λ€ νμμ΅λλ€. μ μλ {info[user]['score']:3.1f}μ μ
λλ€."
|
136 |
+
info[user]['done'] = True
|
137 |
+
if info[user]['score'] >= info[user]['best_score']:
|
138 |
+
info[user]['best_score'] = info[user]['score']
|
139 |
+
info[user]['best_time'] = min(time.time() - info[user]['time'], info[user]['best_time'])
|
140 |
|
141 |
chat_history.append((message, bot_message))
|
142 |
+
|
143 |
+
leader_board = sorted(info.items(), key=lambda x: (x[1]['best_score'], -x[1]['best_time']), reverse=True)
|
144 |
+
lbdf = pd.DataFrame([dict(**a[1], name=a[0]) for a in leader_board])
|
145 |
+
lbdf.index += 1
|
146 |
+
md = lbdf[['name', 'best_score', 'best_time']].to_markdown()
|
147 |
+
return "", chat_history, MD.format(content=md)
|
148 |
|
149 |
play.click(respond,
|
150 |
inputs=[play, chatbot, user, quiz_count, generation, poke_types],
|
|
|
155 |
stop.click(respond,
|
156 |
inputs=[stop, chatbot, user, quiz_count, generation, poke_types],
|
157 |
outputs=[msg, chatbot, markdown])
|
158 |
+
def update_table():
|
159 |
+
leader_board = sorted(info.items(), key=lambda x: (x[1]['best_score'], -x[1]['best_time']), reverse=True)
|
160 |
+
lbdf = pd.DataFrame([dict(**a[1], name=a[0]) for a in leader_board])
|
161 |
+
lbdf.index += 1
|
162 |
+
md = lbdf[['name', 'best_score', 'best_time']].to_markdown()
|
163 |
+
return MD.format(content=md)
|
164 |
+
demo.load(update_table,
|
165 |
inputs=None,
|
166 |
outputs=markdown)
|
167 |
msg.submit(respond, [msg, chatbot, user, quiz_count, generation, poke_types], [msg, chatbot, markdown])
|