ChenyuRabbitLove commited on
Commit
2462492
1 Parent(s): 8f7267a

bugfix: fix minor bugs

Browse files
Files changed (2) hide show
  1. app.py +60 -60
  2. utils/completion_reward.py +9 -9
app.py CHANGED
@@ -74,7 +74,7 @@ def init_reward():
74
  with gr.Blocks(theme=seafoam, css=get_content("css/style.css")) as demo:
75
  player_info = gr.State()
76
  player_logs = gr.State()
77
- #completion_reward = gr.State(init_reward)
78
  player_activity_tracker = gr.State(create_new_player_activity)
79
 
80
  with gr.Tab("個人化戰報"):
@@ -293,65 +293,65 @@ with gr.Blocks(theme=seafoam, css=get_content("css/style.css")) as demo:
293
 
294
  # actions when player login
295
  # define args
296
- send_player_login_info = dict(
297
- fn=render_finished,
298
- inputs=[player_activity_tracker, player_info],
299
- outputs=None,
300
- )
301
-
302
- player_info_query_btn.click(get_player_info, player_backend_id, player_info).then(
303
- render_player_data,
304
- player_info,
305
- [avatar, pet_gallery, badge_gallery, adventure_log, achievements, adventure],
306
- ).then(
307
- **send_player_login_info
308
- )
309
-
310
- pull_newest_player_data.submit(
311
- save_latest_player_data,
312
- None,
313
- update_status,
314
- api_name="pull_newest_player_data",
315
- )
316
-
317
- def create_visibility_updates(visible, count):
318
- return tuple(gr.update(visible=visible) for _ in range(count))
319
-
320
- start_make_reward.click(
321
- check_is_in_completion_reward,
322
- player_backend_id,
323
- [
324
- start_make_reward,
325
- player_name_title,
326
- player_name,
327
- confirm_player_name,
328
- not_participate,
329
- not_start,
330
- already_issued,
331
- ],
332
- queue=False,
333
- )
334
-
335
- set_player_name_args = dict(
336
- fn=set_player_name,
337
- inputs=[completion_reward, player_name, player_backend_id],
338
- outputs=None,
339
- queue=False,
340
- )
341
-
342
- confirm_player_name.click(
343
- lambda: (gr.update(interactive=False), gr.update(visible=False)),
344
- None,
345
- [player_name, confirm_player_name],
346
- queue=False,
347
- ).then(
348
- lambda: create_visibility_updates(True, 2),
349
- None,
350
- [cancel_player_name, player_name_next_step],
351
- queue=False,
352
- ).then(
353
- **set_player_name_args
354
- )
355
 
356
  # cancel_player_name.click(
357
  # lambda: (gr.update(interactive=True), gr.update(visible=True)),
 
74
  with gr.Blocks(theme=seafoam, css=get_content("css/style.css")) as demo:
75
  player_info = gr.State()
76
  player_logs = gr.State()
77
+ completion_reward = gr.State(init_reward)
78
  player_activity_tracker = gr.State(create_new_player_activity)
79
 
80
  with gr.Tab("個人化戰報"):
 
293
 
294
  # actions when player login
295
  # define args
296
+ # send_player_login_info = dict(
297
+ # fn=render_finished,
298
+ # inputs=[player_activity_tracker, player_info],
299
+ # outputs=None,
300
+ # )
301
+
302
+ # player_info_query_btn.click(get_player_info, player_backend_id, player_info).then(
303
+ # render_player_data,
304
+ # player_info,
305
+ # [avatar, pet_gallery, badge_gallery, adventure_log, achievements, adventure],
306
+ # ).then(
307
+ # **send_player_login_info
308
+ # )
309
+
310
+ # pull_newest_player_data.submit(
311
+ # save_latest_player_data,
312
+ # None,
313
+ # update_status,
314
+ # api_name="pull_newest_player_data",
315
+ # )
316
+
317
+ # def create_visibility_updates(visible, count):
318
+ # return tuple(gr.update(visible=visible) for _ in range(count))
319
+
320
+ # start_make_reward.click(
321
+ # check_is_in_completion_reward,
322
+ # player_backend_id,
323
+ # [
324
+ # start_make_reward,
325
+ # player_name_title,
326
+ # player_name,
327
+ # confirm_player_name,
328
+ # not_participate,
329
+ # not_start,
330
+ # already_issued,
331
+ # ],
332
+ # queue=False,
333
+ # )
334
+
335
+ # set_player_name_args = dict(
336
+ # fn=set_player_name,
337
+ # inputs=[completion_reward, player_name, player_backend_id],
338
+ # outputs=None,
339
+ # queue=False,
340
+ # )
341
+
342
+ # confirm_player_name.click(
343
+ # lambda: (gr.update(interactive=False), gr.update(visible=False)),
344
+ # None,
345
+ # [player_name, confirm_player_name],
346
+ # queue=False,
347
+ # ).then(
348
+ # lambda: create_visibility_updates(True, 2),
349
+ # None,
350
+ # [cancel_player_name, player_name_next_step],
351
+ # queue=False,
352
+ # ).then(
353
+ # **set_player_name_args
354
+ # )
355
 
356
  # cancel_player_name.click(
357
  # lambda: (gr.update(interactive=True), gr.update(visible=True)),
utils/completion_reward.py CHANGED
@@ -48,15 +48,15 @@ class CompletionReward:
48
  "mtk": self.paragraph_mtk,
49
  }
50
  SERVICE_ACCOUNT_INFO = os.getenv("GBQ_TOKEN")
51
- service_account_info_dict = json.loads(SERVICE_ACCOUNT_INFO)
52
-
53
- creds = Credentials.from_service_account_info(service_account_info_dict)
54
- self.gbq_client = bigquery.Client(
55
- credentials=creds, project=service_account_info_dict["project_id"]
56
- )
57
- self.gcs_client = storage.Client(
58
- credentials=creds, project=service_account_info_dict["project_id"]
59
- )
60
 
61
  def get_llm_response(self, player_logs):
62
  agents_responses = {
 
48
  "mtk": self.paragraph_mtk,
49
  }
50
  SERVICE_ACCOUNT_INFO = os.getenv("GBQ_TOKEN")
51
+ # service_account_info_dict = json.loads(SERVICE_ACCOUNT_INFO)
52
+
53
+ # creds = Credentials.from_service_account_info(service_account_info_dict)
54
+ # self.gbq_client = bigquery.Client(
55
+ # credentials=creds, project=service_account_info_dict["project_id"]
56
+ # )
57
+ # self.gcs_client = storage.Client(
58
+ # credentials=creds, project=service_account_info_dict["project_id"]
59
+ # )
60
 
61
  def get_llm_response(self, player_logs):
62
  agents_responses = {