Spaces:
Running
Running
ChenyuRabbitLove
commited on
Commit
•
46bdf42
1
Parent(s):
dc960aa
bugfix: fix minor bugs
Browse files
app.py
CHANGED
@@ -76,222 +76,221 @@ def init_reward():
|
|
76 |
with gr.Blocks(theme=seafoam, css=get_content("css/style.css")) as demo:
|
77 |
player_info = gr.State()
|
78 |
player_logs = gr.State()
|
79 |
-
completion_reward = gr.State(init_reward)
|
80 |
player_activity_tracker = gr.State(create_new_player_activity)
|
81 |
|
82 |
-
with gr.
|
83 |
-
with gr.
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
)
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
height=200,
|
96 |
-
)
|
97 |
-
|
98 |
-
badge_description = gr.Markdown("# 徽章", elem_id="badge_avatar_description")
|
99 |
-
badge_gallery = gr.Gallery(
|
100 |
-
[],
|
101 |
-
label="徽章",
|
102 |
-
preview=False,
|
103 |
-
elem_id="badge_gallery",
|
104 |
-
columns=30,
|
105 |
-
height=200,
|
106 |
-
)
|
107 |
-
|
108 |
-
with gr.Column(scale=1, elem_id="player_avatar_container"):
|
109 |
-
avatar = gr.Image(
|
110 |
-
"avatar/blank_avatar.png",
|
111 |
-
elem_id="player_avatar",
|
112 |
-
)
|
113 |
-
avatar_description = gr.Markdown(
|
114 |
-
"# 光束守護者", elem_id="player_avatar_description"
|
115 |
-
)
|
116 |
-
|
117 |
-
with gr.Column(scale=1):
|
118 |
-
adventure_description = gr.Markdown(
|
119 |
-
"# 冒險階段", elem_id="adventure_description"
|
120 |
-
)
|
121 |
-
adventure = gr.Slider(
|
122 |
-
value=0,
|
123 |
-
show_label=False,
|
124 |
-
interactive=False,
|
125 |
-
elem_id="adventure_slider",
|
126 |
-
info="",
|
127 |
-
)
|
128 |
-
achievements_description = gr.Markdown(
|
129 |
-
"# 達成成就", elem_id="achievements_description"
|
130 |
-
)
|
131 |
-
achievements = gr.HighlightedText(
|
132 |
-
value=[],
|
133 |
-
elem_classes="achievements",
|
134 |
-
color_map={
|
135 |
-
"完成": "green",
|
136 |
-
"未完成": "red",
|
137 |
-
},
|
138 |
-
)
|
139 |
-
|
140 |
-
with gr.Row():
|
141 |
-
html = (
|
142 |
-
"<div style='max-width:100%; max-height:360px; overflow:auto'>"
|
143 |
-
+ get_content("htmls/adventure_blank.html")
|
144 |
)
|
145 |
-
adventure_log = gr.HTML(html, label="Adventure Log", elem_id="adventure_log")
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
152 |
)
|
153 |
-
pull_newest_player_data = gr.Textbox("", visible=False)
|
154 |
-
update_status = gr.Textbox("", visible=False)
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
)
|
161 |
-
|
162 |
-
|
163 |
-
not_participate = gr.Markdown(
|
164 |
-
"# 同學並未參與 2023 的星空探險隊唷!", visible=False, elem_id="not_participate"
|
165 |
-
)
|
166 |
-
|
167 |
-
with gr.Row():
|
168 |
-
not_start = gr.Markdown(
|
169 |
-
"# 完賽獎勵還沒有開放申請,但是就快了,請敬請期待!", visible=False, elem_id="not_start"
|
170 |
-
)
|
171 |
-
|
172 |
-
with gr.Row():
|
173 |
-
already_issued = gr.Image(visible=False)
|
174 |
-
|
175 |
-
with gr.Row():
|
176 |
-
player_name_title = gr.Markdown(
|
177 |
-
"# 選擇玩家暱稱", visible=False, elem_id="player_name_title"
|
178 |
-
)
|
179 |
-
|
180 |
-
with gr.Row():
|
181 |
-
player_name = gr.Textbox(
|
182 |
-
label="玩家暱稱",
|
183 |
-
info="請輸入想要用在完賽獎勵上的玩家暱稱,上限為 10 字,獎勵發送後無法更改也無法補發,還請同學們謹慎填寫。",
|
184 |
-
interactive=True,
|
185 |
-
elem_id="player_name",
|
186 |
-
visible=False,
|
187 |
-
)
|
188 |
-
|
189 |
-
with gr.Row():
|
190 |
-
confirm_player_name = gr.Button(
|
191 |
-
"確認暱稱", elem_id="confirm_player_name", visible=False
|
192 |
-
)
|
193 |
-
cancel_player_name = gr.Button(
|
194 |
-
"取消", elem_id="cancel_player_name", visible=False
|
195 |
)
|
196 |
|
197 |
-
with gr.
|
198 |
-
|
199 |
-
"
|
200 |
)
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
with gr.Row():
|
206 |
-
story_description = gr.Markdown(
|
207 |
-
"有五位星際夥伴來為你撰寫專屬於你的冒險故事,每位星際夥伴都會得到同學冒險週記的內容,並寫成一段故事,請同學選擇自己最喜歡的一段故事,這段故事將會被用來印在獎狀上<br><br>小叮嚀:請同學選擇喜歡的故事內容,而不是星際夥伴唷!星際夥伴可是不會和同學們一起冒險的!最後,撰寫故事的過程大概需要幾分鐘的時間,請同學耐心等待",
|
208 |
-
visible=False,
|
209 |
-
elem_id="story_description",
|
210 |
-
)
|
211 |
-
|
212 |
-
with gr.Row():
|
213 |
-
openai_description = gr.Markdown(
|
214 |
-
"# 露米娜", elem_id="openai_description", visible=False
|
215 |
-
)
|
216 |
-
aws_description = gr.Markdown(
|
217 |
-
"# 索拉拉", elem_id="aws_description", visible=False
|
218 |
-
)
|
219 |
-
google_description = gr.Markdown(
|
220 |
-
"# 薇丹特", elem_id="google_description", visible=False
|
221 |
-
)
|
222 |
-
mtk_description = gr.Markdown(
|
223 |
-
"# 蔚藍", elem_id="mtk_description", visible=False
|
224 |
-
)
|
225 |
-
|
226 |
-
with gr.Row():
|
227 |
-
openai_img = gr.Image(
|
228 |
-
"medias/lumina.png",
|
229 |
-
visible=False,
|
230 |
-
elem_id="openai_img",
|
231 |
interactive=False,
|
232 |
-
|
|
|
233 |
)
|
234 |
-
|
235 |
-
"
|
236 |
-
visible=False,
|
237 |
-
elem_id="aws_img",
|
238 |
-
interactive=False,
|
239 |
-
show_download_button=False,
|
240 |
)
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
mtk_img = gr.Image(
|
249 |
-
"medias/azure.png",
|
250 |
-
visible=False,
|
251 |
-
elem_id="mtk_img",
|
252 |
-
interactive=False,
|
253 |
-
show_download_button=False,
|
254 |
-
)
|
255 |
-
|
256 |
-
with gr.Row():
|
257 |
-
start_generate_story = gr.Button(
|
258 |
-
"開始寫作故事", visible=False, elem_id="start_generate_story"
|
259 |
-
)
|
260 |
-
|
261 |
-
with gr.Row():
|
262 |
-
bot1 = gr.Chatbot(visible=False)
|
263 |
-
bot2 = gr.Chatbot(visible=False)
|
264 |
-
bot3 = gr.Chatbot(visible=False)
|
265 |
-
bot4 = gr.Chatbot(visible=False)
|
266 |
-
|
267 |
-
with gr.Row():
|
268 |
-
select_story = gr.Radio(
|
269 |
-
["露米娜", "索拉拉", "薇丹特", "蔚藍"],
|
270 |
-
interactive=True,
|
271 |
-
label="選擇故事",
|
272 |
-
visible=False,
|
273 |
-
elem_id="select_story",
|
274 |
)
|
275 |
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
"開始製作完賽獎勵!", visible=False, elem_id="start_generate_certificate"
|
283 |
-
)
|
284 |
-
processing = gr.Button(
|
285 |
-
"製作中...",
|
286 |
-
visible=False,
|
287 |
-
elem_id="processing",
|
288 |
-
size="lg",
|
289 |
-
interactive=False,
|
290 |
-
)
|
291 |
-
complete = gr.Markdown("# 完成!", visible=False, elem_id="complete")
|
292 |
|
293 |
-
|
294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
|
296 |
# actions when player login
|
297 |
# define args
|
@@ -302,8 +301,6 @@ with gr.Blocks(theme=seafoam, css=get_content("css/style.css")) as demo:
|
|
302 |
)
|
303 |
|
304 |
player_info_query_btn.click(get_player_info, player_backend_id, player_info).then(
|
305 |
-
get_player_logs, player_backend_id, player_logs
|
306 |
-
).then(
|
307 |
render_player_data,
|
308 |
player_info,
|
309 |
[avatar, pet_gallery, badge_gallery, adventure_log, achievements, adventure],
|
@@ -318,186 +315,186 @@ with gr.Blocks(theme=seafoam, css=get_content("css/style.css")) as demo:
|
|
318 |
api_name="pull_newest_player_data",
|
319 |
)
|
320 |
|
321 |
-
def create_visibility_updates(visible, count):
|
322 |
-
|
323 |
-
|
324 |
-
start_make_reward.click(
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
)
|
338 |
-
|
339 |
-
set_player_name_args = dict(
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
)
|
345 |
-
|
346 |
-
confirm_player_name.click(
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
).then(
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
).then(
|
357 |
-
|
358 |
-
)
|
359 |
-
|
360 |
-
cancel_player_name.click(
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
).then(
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
)
|
371 |
-
|
372 |
-
player_name_next_step.click(
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
).then(
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
)
|
401 |
-
|
402 |
-
get_llm_response_args = dict(
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
)
|
408 |
-
|
409 |
-
start_generate_story.click(
|
410 |
-
|
411 |
-
).then(
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
).then(
|
417 |
-
|
418 |
-
).then(
|
419 |
-
|
420 |
-
)
|
421 |
-
|
422 |
-
select_story.select(
|
423 |
-
|
424 |
-
)
|
425 |
-
|
426 |
-
set_player_selected_character_args = dict(
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
)
|
432 |
-
|
433 |
-
confirm_story.click(
|
434 |
-
|
435 |
-
).then(lambda: gr.update(visible=False), None, [confirm_story], queue=False).then(
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
).then(
|
441 |
-
|
442 |
-
)
|
443 |
-
|
444 |
-
cancel_story.click(
|
445 |
-
|
446 |
-
).then(lambda: gr.update(visible=False), None, [cancel_story], queue=False).then(
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
)
|
452 |
-
|
453 |
-
create_certificate_args = dict(
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
)
|
459 |
-
|
460 |
-
complete_reward_args = dict(
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
)
|
466 |
-
|
467 |
-
start_generate_certificate.click(
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
).then(lambda: gr.update(visible=True), None, [processing], queue=False).then(
|
492 |
-
|
493 |
-
).then(
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
).then(
|
499 |
-
|
500 |
-
)
|
501 |
|
502 |
if __name__ == "__main__":
|
503 |
demo.launch()
|
|
|
76 |
with gr.Blocks(theme=seafoam, css=get_content("css/style.css")) as demo:
|
77 |
player_info = gr.State()
|
78 |
player_logs = gr.State()
|
79 |
+
# completion_reward = gr.State(init_reward)
|
80 |
player_activity_tracker = gr.State(create_new_player_activity)
|
81 |
|
82 |
+
with gr.Row():
|
83 |
+
with gr.Column(
|
84 |
+
scale=1,
|
85 |
+
elem_classes="gallery_container",
|
86 |
+
):
|
87 |
+
pet_description = gr.Markdown("# 夥伴", elem_id="pet_avatar_description")
|
88 |
+
pet_gallery = gr.Gallery(
|
89 |
+
[],
|
90 |
+
label="夥伴",
|
91 |
+
preview=False,
|
92 |
+
elem_id="pet_gallery",
|
93 |
+
columns=30,
|
94 |
+
height=200,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
)
|
|
|
96 |
|
97 |
+
badge_description = gr.Markdown("# 徽章", elem_id="badge_avatar_description")
|
98 |
+
badge_gallery = gr.Gallery(
|
99 |
+
[],
|
100 |
+
label="徽章",
|
101 |
+
preview=False,
|
102 |
+
elem_id="badge_gallery",
|
103 |
+
columns=30,
|
104 |
+
height=200,
|
105 |
)
|
|
|
|
|
106 |
|
107 |
+
with gr.Column(scale=1, elem_id="player_avatar_container"):
|
108 |
+
avatar = gr.Image(
|
109 |
+
"avatar/blank_avatar.png",
|
110 |
+
elem_id="player_avatar",
|
111 |
)
|
112 |
+
avatar_description = gr.Markdown(
|
113 |
+
"# 光束守護者", elem_id="player_avatar_description"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
)
|
115 |
|
116 |
+
with gr.Column(scale=1):
|
117 |
+
adventure_description = gr.Markdown(
|
118 |
+
"# 冒險階段", elem_id="adventure_description"
|
119 |
)
|
120 |
+
adventure = gr.Slider(
|
121 |
+
value=0,
|
122 |
+
show_label=False,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
interactive=False,
|
124 |
+
elem_id="adventure_slider",
|
125 |
+
info="",
|
126 |
)
|
127 |
+
achievements_description = gr.Markdown(
|
128 |
+
"# 達成成就", elem_id="achievements_description"
|
|
|
|
|
|
|
|
|
129 |
)
|
130 |
+
achievements = gr.HighlightedText(
|
131 |
+
value=[],
|
132 |
+
elem_classes="achievements",
|
133 |
+
color_map={
|
134 |
+
"完成": "green",
|
135 |
+
"未完成": "red",
|
136 |
+
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
)
|
138 |
|
139 |
+
with gr.Row():
|
140 |
+
html = (
|
141 |
+
"<div style='max-width:100%; max-height:360px; overflow:auto'>"
|
142 |
+
+ get_content("htmls/adventure_blank.html")
|
143 |
+
)
|
144 |
+
adventure_log = gr.HTML(html, label="Adventure Log", elem_id="adventure_log")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
+
# handling player info
|
147 |
+
with gr.Row():
|
148 |
+
player_backend_id = gr.Textbox("", elem_id="player_backend_id", visible=False)
|
149 |
+
player_info_query_btn = gr.Button(
|
150 |
+
"Query", elem_id="trigger_button", visible=False
|
151 |
+
)
|
152 |
+
pull_newest_player_data = gr.Textbox("", visible=False)
|
153 |
+
update_status = gr.Textbox("", visible=False)
|
154 |
+
|
155 |
+
# with gr.Tab("完賽獎勵"):
|
156 |
+
# with gr.Row():
|
157 |
+
# start_make_reward = gr.Button(
|
158 |
+
# "開始製作完賽獎勵!", visible=True, elem_id="start_make_reward"
|
159 |
+
# )
|
160 |
+
|
161 |
+
# with gr.Row():
|
162 |
+
# not_participate = gr.Markdown(
|
163 |
+
# "# 同學並未參與 2023 的星空探險隊唷!", visible=False, elem_id="not_participate"
|
164 |
+
# )
|
165 |
+
|
166 |
+
# with gr.Row():
|
167 |
+
# not_start = gr.Markdown(
|
168 |
+
# "# 完賽獎勵還沒有開放申請,但是就快了,請敬請期待!", visible=False, elem_id="not_start"
|
169 |
+
# )
|
170 |
+
|
171 |
+
# with gr.Row():
|
172 |
+
# already_issued = gr.Image(visible=False)
|
173 |
+
|
174 |
+
# with gr.Row():
|
175 |
+
# player_name_title = gr.Markdown(
|
176 |
+
# "# 選擇玩家暱稱", visible=False, elem_id="player_name_title"
|
177 |
+
# )
|
178 |
+
|
179 |
+
# with gr.Row():
|
180 |
+
# player_name = gr.Textbox(
|
181 |
+
# label="玩家暱稱",
|
182 |
+
# info="請輸入想要用在完賽獎勵上的玩家暱稱,上限為 10 字,獎勵發送後無法更改也無法補發,還請同學們謹慎填寫。",
|
183 |
+
# interactive=True,
|
184 |
+
# elem_id="player_name",
|
185 |
+
# visible=False,
|
186 |
+
# )
|
187 |
+
|
188 |
+
# with gr.Row():
|
189 |
+
# confirm_player_name = gr.Button(
|
190 |
+
# "確認暱稱", elem_id="confirm_player_name", visible=False
|
191 |
+
# )
|
192 |
+
# cancel_player_name = gr.Button(
|
193 |
+
# "取消", elem_id="cancel_player_name", visible=False
|
194 |
+
# )
|
195 |
+
|
196 |
+
# with gr.Row():
|
197 |
+
# player_name_next_step = gr.Button(
|
198 |
+
# "下一步", visible=False, elem_id="player_name_next_step"
|
199 |
+
# )
|
200 |
+
|
201 |
+
# with gr.Row():
|
202 |
+
# story_title = gr.Markdown("# 選擇冒險故事", visible=False, elem_id="story_title")
|
203 |
+
|
204 |
+
# with gr.Row():
|
205 |
+
# story_description = gr.Markdown(
|
206 |
+
# "有五位星際夥伴來為你撰寫專屬於你的冒險故事,每位星際夥伴都會得到同學冒險週記的內容,並寫成一段故事,請同學選擇自己最喜歡的一段故事,這段故事將會被用來印在獎狀上<br><br>小叮嚀:請同學選擇喜歡的故事內容,而不是星際夥伴唷!星際夥伴可是不會和同學們一起冒險的!最後,撰寫故事的過程大概需要幾分鐘的時間,請同學耐心等待",
|
207 |
+
# visible=False,
|
208 |
+
# elem_id="story_description",
|
209 |
+
# )
|
210 |
+
|
211 |
+
# with gr.Row():
|
212 |
+
# openai_description = gr.Markdown(
|
213 |
+
# "# 露米娜", elem_id="openai_description", visible=False
|
214 |
+
# )
|
215 |
+
# aws_description = gr.Markdown(
|
216 |
+
# "# 索拉拉", elem_id="aws_description", visible=False
|
217 |
+
# )
|
218 |
+
# google_description = gr.Markdown(
|
219 |
+
# "# 薇丹特", elem_id="google_description", visible=False
|
220 |
+
# )
|
221 |
+
# mtk_description = gr.Markdown(
|
222 |
+
# "# 蔚藍", elem_id="mtk_description", visible=False
|
223 |
+
# )
|
224 |
+
|
225 |
+
# with gr.Row():
|
226 |
+
# openai_img = gr.Image(
|
227 |
+
# "medias/lumina.png",
|
228 |
+
# visible=False,
|
229 |
+
# elem_id="openai_img",
|
230 |
+
# interactive=False,
|
231 |
+
# show_download_button=False,
|
232 |
+
# )
|
233 |
+
# aws_img = gr.Image(
|
234 |
+
# "medias/solara.png",
|
235 |
+
# visible=False,
|
236 |
+
# elem_id="aws_img",
|
237 |
+
# interactive=False,
|
238 |
+
# show_download_button=False,
|
239 |
+
# )
|
240 |
+
# google_img = gr.Image(
|
241 |
+
# "medias/verdant.png",
|
242 |
+
# visible=False,
|
243 |
+
# elem_id="google_img",
|
244 |
+
# interactive=False,
|
245 |
+
# show_download_button=False,
|
246 |
+
# )
|
247 |
+
# mtk_img = gr.Image(
|
248 |
+
# "medias/azure.png",
|
249 |
+
# visible=False,
|
250 |
+
# elem_id="mtk_img",
|
251 |
+
# interactive=False,
|
252 |
+
# show_download_button=False,
|
253 |
+
# )
|
254 |
+
|
255 |
+
# with gr.Row():
|
256 |
+
# start_generate_story = gr.Button(
|
257 |
+
# "開始寫作故事", visible=False, elem_id="start_generate_story"
|
258 |
+
# )
|
259 |
+
|
260 |
+
# with gr.Row():
|
261 |
+
# bot1 = gr.Chatbot(visible=False)
|
262 |
+
# bot2 = gr.Chatbot(visible=False)
|
263 |
+
# bot3 = gr.Chatbot(visible=False)
|
264 |
+
# bot4 = gr.Chatbot(visible=False)
|
265 |
+
|
266 |
+
# with gr.Row():
|
267 |
+
# select_story = gr.Radio(
|
268 |
+
# ["露米娜", "索拉拉", "薇丹特", "蔚藍"],
|
269 |
+
# interactive=True,
|
270 |
+
# label="選擇故事",
|
271 |
+
# visible=False,
|
272 |
+
# elem_id="select_story",
|
273 |
+
# )
|
274 |
+
|
275 |
+
# with gr.Row():
|
276 |
+
# confirm_story = gr.Button("確認故事", visible=False, elem_id="confirm_story")
|
277 |
+
# cancel_story = gr.Button("取消", visible=False, elem_id="cancel_story")
|
278 |
+
|
279 |
+
# with gr.Row():
|
280 |
+
# start_generate_certificate = gr.Button(
|
281 |
+
# "開始製作完賽獎勵!", visible=False, elem_id="start_generate_certificate"
|
282 |
+
# )
|
283 |
+
# processing = gr.Button(
|
284 |
+
# "製作中...",
|
285 |
+
# visible=False,
|
286 |
+
# elem_id="processing",
|
287 |
+
# size="lg",
|
288 |
+
# interactive=False,
|
289 |
+
# )
|
290 |
+
# complete = gr.Markdown("# 完成!", visible=False, elem_id="complete")
|
291 |
+
|
292 |
+
# with gr.Row():
|
293 |
+
# reward_result = gr.Image(visible=False)
|
294 |
|
295 |
# actions when player login
|
296 |
# define args
|
|
|
301 |
)
|
302 |
|
303 |
player_info_query_btn.click(get_player_info, player_backend_id, player_info).then(
|
|
|
|
|
304 |
render_player_data,
|
305 |
player_info,
|
306 |
[avatar, pet_gallery, badge_gallery, adventure_log, achievements, adventure],
|
|
|
315 |
api_name="pull_newest_player_data",
|
316 |
)
|
317 |
|
318 |
+
# def create_visibility_updates(visible, count):
|
319 |
+
# return tuple(gr.update(visible=visible) for _ in range(count))
|
320 |
+
|
321 |
+
# start_make_reward.click(
|
322 |
+
# check_is_in_completion_reward,
|
323 |
+
# player_backend_id,
|
324 |
+
# [
|
325 |
+
# start_make_reward,
|
326 |
+
# player_name_title,
|
327 |
+
# player_name,
|
328 |
+
# confirm_player_name,
|
329 |
+
# not_participate,
|
330 |
+
# not_start,
|
331 |
+
# already_issued,
|
332 |
+
# ],
|
333 |
+
# queue=False,
|
334 |
+
# )
|
335 |
+
|
336 |
+
# set_player_name_args = dict(
|
337 |
+
# fn=set_player_name,
|
338 |
+
# inputs=[completion_reward, player_name, player_backend_id],
|
339 |
+
# outputs=None,
|
340 |
+
# queue=False,
|
341 |
+
# )
|
342 |
+
|
343 |
+
# confirm_player_name.click(
|
344 |
+
# lambda: (gr.update(interactive=False), gr.update(visible=False)),
|
345 |
+
# None,
|
346 |
+
# [player_name, confirm_player_name],
|
347 |
+
# queue=False,
|
348 |
+
# ).then(
|
349 |
+
# lambda: create_visibility_updates(True, 2),
|
350 |
+
# None,
|
351 |
+
# [cancel_player_name, player_name_next_step],
|
352 |
+
# queue=False,
|
353 |
+
# ).then(
|
354 |
+
# **set_player_name_args
|
355 |
+
# )
|
356 |
+
|
357 |
+
# cancel_player_name.click(
|
358 |
+
# lambda: (gr.update(interactive=True), gr.update(visible=True)),
|
359 |
+
# None,
|
360 |
+
# [player_name, confirm_player_name],
|
361 |
+
# queue=False,
|
362 |
+
# ).then(
|
363 |
+
# lambda: create_visibility_updates(False, 2),
|
364 |
+
# None,
|
365 |
+
# [cancel_player_name, player_name_next_step],
|
366 |
+
# queue=False,
|
367 |
+
# )
|
368 |
+
|
369 |
+
# player_name_next_step.click(
|
370 |
+
# lambda: create_visibility_updates(False, 5),
|
371 |
+
# None,
|
372 |
+
# [
|
373 |
+
# player_name,
|
374 |
+
# player_name_next_step,
|
375 |
+
# confirm_player_name,
|
376 |
+
# player_name_title,
|
377 |
+
# cancel_player_name,
|
378 |
+
# ],
|
379 |
+
# queue=False,
|
380 |
+
# ).then(
|
381 |
+
# lambda: create_visibility_updates(True, 11),
|
382 |
+
# None,
|
383 |
+
# [
|
384 |
+
# openai_img,
|
385 |
+
# aws_img,
|
386 |
+
# google_img,
|
387 |
+
# mtk_img,
|
388 |
+
# story_title,
|
389 |
+
# story_description,
|
390 |
+
# openai_description,
|
391 |
+
# aws_description,
|
392 |
+
# google_description,
|
393 |
+
# mtk_description,
|
394 |
+
# start_generate_story,
|
395 |
+
# ],
|
396 |
+
# queue=False,
|
397 |
+
# )
|
398 |
+
|
399 |
+
# get_llm_response_args = dict(
|
400 |
+
# fn=get_llm_response,
|
401 |
+
# inputs=[completion_reward, player_logs],
|
402 |
+
# outputs=[bot1, bot2, bot3, bot4],
|
403 |
+
# queue=False,
|
404 |
+
# )
|
405 |
+
|
406 |
+
# start_generate_story.click(
|
407 |
+
# lambda: gr.update(visible=False), None, start_generate_story, queue=False
|
408 |
+
# ).then(
|
409 |
+
# lambda: create_visibility_updates(True, 4),
|
410 |
+
# None,
|
411 |
+
# [bot1, bot2, bot3, bot4],
|
412 |
+
# queue=False,
|
413 |
+
# ).then(
|
414 |
+
# **get_llm_response_args
|
415 |
+
# ).then(
|
416 |
+
# lambda: gr.update(visible=True), None, [select_story], queue=False
|
417 |
+
# )
|
418 |
+
|
419 |
+
# select_story.select(
|
420 |
+
# lambda: gr.update(visible=True), None, confirm_story, queue=False
|
421 |
+
# )
|
422 |
+
|
423 |
+
# set_player_selected_character_args = dict(
|
424 |
+
# fn=set_player_selected_character,
|
425 |
+
# inputs=[completion_reward, select_story],
|
426 |
+
# outputs=None,
|
427 |
+
# queue=False,
|
428 |
+
# )
|
429 |
+
|
430 |
+
# confirm_story.click(
|
431 |
+
# lambda: gr.update(interactive=False), None, [select_story], queue=False
|
432 |
+
# ).then(lambda: gr.update(visible=False), None, [confirm_story], queue=False).then(
|
433 |
+
# lambda: (gr.update(visible=True), gr.update(visible=True)),
|
434 |
+
# None,
|
435 |
+
# [start_generate_certificate, cancel_story],
|
436 |
+
# queue=False,
|
437 |
+
# ).then(
|
438 |
+
# **set_player_selected_character_args
|
439 |
+
# )
|
440 |
+
|
441 |
+
# cancel_story.click(
|
442 |
+
# lambda: gr.update(interactive=True), None, [select_story], queue=False
|
443 |
+
# ).then(lambda: gr.update(visible=False), None, [cancel_story], queue=False).then(
|
444 |
+
# lambda: (gr.update(visible=False), gr.update(visible=True)),
|
445 |
+
# None,
|
446 |
+
# [start_generate_certificate, confirm_story],
|
447 |
+
# queue=False,
|
448 |
+
# )
|
449 |
+
|
450 |
+
# create_certificate_args = dict(
|
451 |
+
# fn=create_certificate,
|
452 |
+
# inputs=[completion_reward],
|
453 |
+
# outputs=reward_result,
|
454 |
+
# queue=False,
|
455 |
+
# )
|
456 |
+
|
457 |
+
# complete_reward_args = dict(
|
458 |
+
# fn=complete_reward,
|
459 |
+
# inputs=[completion_reward],
|
460 |
+
# outputs=None,
|
461 |
+
# queue=False,
|
462 |
+
# )
|
463 |
+
|
464 |
+
# start_generate_certificate.click(
|
465 |
+
# lambda: create_visibility_updates(False, 18),
|
466 |
+
# None,
|
467 |
+
# [
|
468 |
+
# openai_img,
|
469 |
+
# aws_img,
|
470 |
+
# google_img,
|
471 |
+
# mtk_img,
|
472 |
+
# story_title,
|
473 |
+
# story_description,
|
474 |
+
# openai_description,
|
475 |
+
# aws_description,
|
476 |
+
# google_description,
|
477 |
+
# mtk_description,
|
478 |
+
# bot1,
|
479 |
+
# bot2,
|
480 |
+
# bot3,
|
481 |
+
# bot4,
|
482 |
+
# select_story,
|
483 |
+
# processing,
|
484 |
+
# cancel_story,
|
485 |
+
# start_generate_certificate,
|
486 |
+
# ],
|
487 |
+
# queue=False,
|
488 |
+
# ).then(lambda: gr.update(visible=True), None, [processing], queue=False).then(
|
489 |
+
# **create_certificate_args
|
490 |
+
# ).then(
|
491 |
+
# lambda: (gr.update(visible=True), gr.update(visible=False)),
|
492 |
+
# None,
|
493 |
+
# [complete, processing],
|
494 |
+
# queue=False,
|
495 |
+
# ).then(
|
496 |
+
# **complete_reward_args
|
497 |
+
# )
|
498 |
|
499 |
if __name__ == "__main__":
|
500 |
demo.launch()
|