yoon-gu commited on
Commit
b7ed881
โ€ข
1 Parent(s): 0195f76

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -39,6 +39,11 @@ def get_question_answer(pokemons_set):
39
  info = {u: {"done" : True, "score": 0, "count": 0, "best_score": 0, "best_time": float("inf"), "time": 0.0} for u in USERS}
40
 
41
  MD = """# ํฌ์ผ“๋ชฌ ํ€ด์ฆˆ
 
 
 
 
 
42
  ## ์‚ฌ์šฉ๋ฐฉ๋ฒ•
43
 
44
  1. ์‚ฌ์šฉ์ž๋ฅผ ์„ ํƒํ•˜์„ธ์š”.
@@ -72,6 +77,7 @@ with gr.Blocks() as demo:
72
  )
73
  with gr.Row():
74
  play = gr.Button(value="ํ€ด์ฆˆ ์‹œ์ž‘", label="ํ€ด์ฆˆ ์‹œ์ž‘")
 
75
  stop = gr.Button(value="ํ€ด์ฆˆ ์ข…๋ฃŒ", label="ํ€ด์ฆˆ ์ข…๋ฃŒ")
76
  chatbot = gr.Chatbot(bubble_full_width=False,
77
  avatar_images=["https://huggingface.co/spaces/yoon-gu/pokemon/resolve/main/images/No_0001_์ด์ƒํ•ด์”จ.png",
@@ -112,6 +118,11 @@ with gr.Blocks() as demo:
112
  elif "ํ€ด์ฆˆ์ข…๋ฃŒ" == message.replace(" ", ""):
113
  bot_message = f"ํ€ด์ฆˆ๋ฅผ ๊ฐ•์ œ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค."
114
  info[user]['done'] = True
 
 
 
 
 
115
  else:
116
  hint1 = ""
117
  for i, y in enumerate(answer.value):
@@ -131,6 +142,9 @@ with gr.Blocks() as demo:
131
  play.click(respond,
132
  inputs=[play, chatbot, user, quiz_count, generation, poke_types],
133
  outputs=[msg, chatbot, markdown])
 
 
 
134
  stop.click(respond,
135
  inputs=[stop, chatbot, user, quiz_count, generation, poke_types],
136
  outputs=[msg, chatbot, markdown])
 
39
  info = {u: {"done" : True, "score": 0, "count": 0, "best_score": 0, "best_time": float("inf"), "time": 0.0} for u in USERS}
40
 
41
  MD = """# ํฌ์ผ“๋ชฌ ํ€ด์ฆˆ
42
+ ## ๊ณต๋ถ€ ๋ฐฉ๋ฒ•
43
+
44
+ ์•„๋ž˜ ํฌ์ผ“๋ชฌ ๋„๊ฐ์„ ๋ณด๊ณ  ๊ณต๋ถ€ํ•˜๋ฉด ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.
45
+ - https://huggingface.co/spaces/yoon-gu/pokemon
46
+
47
  ## ์‚ฌ์šฉ๋ฐฉ๋ฒ•
48
 
49
  1. ์‚ฌ์šฉ์ž๋ฅผ ์„ ํƒํ•˜์„ธ์š”.
 
77
  )
78
  with gr.Row():
79
  play = gr.Button(value="ํ€ด์ฆˆ ์‹œ์ž‘", label="ํ€ด์ฆˆ ์‹œ์ž‘")
80
+ skip = gr.Button(value="๋ฌธ์ œ ๋„˜์–ด๊ฐ€๊ธฐ", label="๋ฌธ์ œ ์Šคํ‚ต")
81
  stop = gr.Button(value="ํ€ด์ฆˆ ์ข…๋ฃŒ", label="ํ€ด์ฆˆ ์ข…๋ฃŒ")
82
  chatbot = gr.Chatbot(bubble_full_width=False,
83
  avatar_images=["https://huggingface.co/spaces/yoon-gu/pokemon/resolve/main/images/No_0001_์ด์ƒํ•ด์”จ.png",
 
118
  elif "ํ€ด์ฆˆ์ข…๋ฃŒ" == message.replace(" ", ""):
119
  bot_message = f"ํ€ด์ฆˆ๋ฅผ ๊ฐ•์ œ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค."
120
  info[user]['done'] = True
121
+ elif "๋ฌธ์ œ ๋„˜์–ด๊ฐ€๊ธฐ" == message:
122
+ info[user]['count'] += 1
123
+ q, a = get_question_answer(pokemons_set)
124
+ answer.value = a
125
+ bot_message = f"๋ฌธ์ œ๋ฅผ ๋„˜์–ด๊ฐ‘๋‹ˆ๋‹ค. ๋‹ค์Œ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.\n{q}"
126
  else:
127
  hint1 = ""
128
  for i, y in enumerate(answer.value):
 
142
  play.click(respond,
143
  inputs=[play, chatbot, user, quiz_count, generation, poke_types],
144
  outputs=[msg, chatbot, markdown])
145
+ stop.click(respond,
146
+ inputs=[skip, chatbot, user, quiz_count, generation, poke_types],
147
+ outputs=[msg, chatbot, markdown])
148
  stop.click(respond,
149
  inputs=[stop, chatbot, user, quiz_count, generation, poke_types],
150
  outputs=[msg, chatbot, markdown])