ChenyuRabbitLove commited on
Commit
90437ed
1 Parent(s): e740f9e

bugfix: fix minor bugs

Browse files
Files changed (2) hide show
  1. app.py +14 -0
  2. utils/completion_reward.py +6 -5
app.py CHANGED
@@ -35,6 +35,20 @@ def get_player_info(player_backend_user_id):
35
  save_latest_player_data()
36
  with open("latest_player_data.json", "r", encoding="utf-8") as file:
37
  player_info = json.load(file)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  if player_backend_user_id in player_info:
40
  return player_info[player_backend_user_id]
 
35
  save_latest_player_data()
36
  with open("latest_player_data.json", "r", encoding="utf-8") as file:
37
  player_info = json.load(file)
38
+ with open('latest_player_data.json', 'r') as f:
39
+ datas = json.load(f)
40
+
41
+ processed_datas = {}
42
+
43
+ for k, v in datas.items():
44
+ log = v['adventure_logs']
45
+ filtered_log = [record for record in log if not record.startswith("恭喜")]
46
+ processed_log = [record.rsplit(',', 1)[0] for record in filtered_log]
47
+ concat_log = ' '.join(processed_log)
48
+ processed_datas[k] = concat_log
49
+
50
+ with open('processed_adventure_logs.json', 'w') as f:
51
+ json.dump(processed_datas, f)
52
 
53
  if player_backend_user_id in player_info:
54
  return player_info[player_backend_user_id]
utils/completion_reward.py CHANGED
@@ -23,9 +23,10 @@ from google.cloud import bigquery
23
  from google.cloud import storage
24
 
25
  SERVICE_ACCOUNT_INFO = os.getenv("GBQ_TOKEN")
 
26
  service_account_info_dict = json.loads(SERVICE_ACCOUNT_INFO)
27
 
28
- creds = Credentials.from_service_account_info(service_account_info_dict)
29
 
30
  gbq_client = bigquery.Client(
31
  credentials=creds, project=service_account_info_dict["project_id"]
@@ -251,7 +252,7 @@ class OpenAIAgent:
251
 
252
  except Exception as e:
253
  retry_attempts += 1
254
- logging.error(f"Attempt {retry_attempts}: {e}")
255
  time.sleep(1 * retry_attempts)
256
 
257
  def get_background(self):
@@ -312,7 +313,7 @@ class AWSAgent:
312
 
313
  except Exception as e:
314
  retry_attempts += 1
315
- logging.error(f"Attempt {retry_attempts}: {e}")
316
  time.sleep(1 * retry_attempts)
317
 
318
 
@@ -374,7 +375,7 @@ class GoogleAgent:
374
 
375
  except Exception as e:
376
  retry_attempts += 1
377
- logging.error(f"Attempt {retry_attempts}: {e}")
378
  time.sleep(1 * retry_attempts)
379
 
380
 
@@ -444,7 +445,7 @@ class MTKAgent:
444
 
445
  except Exception as e:
446
  retry_attempts += 1
447
- logging.error(f"Attempt {retry_attempts}: {e}")
448
  time.sleep(1 * retry_attempts)
449
 
450
 
 
23
  from google.cloud import storage
24
 
25
  SERVICE_ACCOUNT_INFO = os.getenv("GBQ_TOKEN")
26
+ SCOPES = ["https://www.googleapis.com/auth/cloud-platform"]
27
  service_account_info_dict = json.loads(SERVICE_ACCOUNT_INFO)
28
 
29
+ creds = Credentials.from_service_account_info(service_account_info_dict, scopes=SCOPES)
30
 
31
  gbq_client = bigquery.Client(
32
  credentials=creds, project=service_account_info_dict["project_id"]
 
252
 
253
  except Exception as e:
254
  retry_attempts += 1
255
+ logging.error(f"OpenAI Attempt {retry_attempts}: {e}")
256
  time.sleep(1 * retry_attempts)
257
 
258
  def get_background(self):
 
313
 
314
  except Exception as e:
315
  retry_attempts += 1
316
+ logging.error(f"AWS Attempt {retry_attempts}: {e}")
317
  time.sleep(1 * retry_attempts)
318
 
319
 
 
375
 
376
  except Exception as e:
377
  retry_attempts += 1
378
+ logging.error(f"Google Attempt {retry_attempts}: {e}")
379
  time.sleep(1 * retry_attempts)
380
 
381
 
 
445
 
446
  except Exception as e:
447
  retry_attempts += 1
448
+ logging.error(f"MTK Attempt {retry_attempts}: {e}")
449
  time.sleep(1 * retry_attempts)
450
 
451