Spaces:
Sleeping
Sleeping
Commit
·
96a04e2
1
Parent(s):
d2d70ce
bugfix: fix minor bugs
Browse files- utils/completion_reward.py +14 -13
utils/completion_reward.py
CHANGED
|
@@ -22,6 +22,18 @@ from google import auth
|
|
| 22 |
from google.cloud import bigquery
|
| 23 |
from google.cloud import storage
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
class CompletionReward:
|
| 27 |
def __init__(self):
|
|
@@ -47,17 +59,6 @@ class CompletionReward:
|
|
| 47 |
"google": self.paragraph_google,
|
| 48 |
"mtk": self.paragraph_mtk,
|
| 49 |
}
|
| 50 |
-
SERVICE_ACCOUNT_INFO = os.getenv("GBQ_TOKEN")
|
| 51 |
-
SCOPES = ["https://www.googleapis.com/auth/cloud-platform"]
|
| 52 |
-
service_account_info_dict = json.loads(SERVICE_ACCOUNT_INFO)
|
| 53 |
-
|
| 54 |
-
creds = Credentials.from_service_account_info(service_account_info_dict, scopes=SCOPES)
|
| 55 |
-
self.gbq_client = bigquery.Client(
|
| 56 |
-
credentials=creds, project=service_account_info_dict["project_id"]
|
| 57 |
-
)
|
| 58 |
-
# self.gcs_client = storage.Client(
|
| 59 |
-
# credentials=creds, project=service_account_info_dict["project_id"]
|
| 60 |
-
# )
|
| 61 |
|
| 62 |
def get_llm_response(self, player_logs):
|
| 63 |
agents_responses = {
|
|
@@ -163,7 +164,7 @@ class CompletionReward:
|
|
| 163 |
):
|
| 164 |
insert_row = self.to_dict()
|
| 165 |
self.insert_data_into_bigquery(
|
| 166 |
-
|
| 167 |
)
|
| 168 |
logging.info(
|
| 169 |
f"Player {insert_row['player_backend_user_id']} rendered successfully."
|
|
@@ -184,7 +185,7 @@ class CompletionReward:
|
|
| 184 |
):
|
| 185 |
"""Uploads a file to the bucket and makes it publicly accessible."""
|
| 186 |
# Initialize a storage client
|
| 187 |
-
bucket =
|
| 188 |
blob = bucket.blob(destination_blob_name)
|
| 189 |
|
| 190 |
# Upload the file
|
|
|
|
| 22 |
from google.cloud import bigquery
|
| 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"]
|
| 33 |
+
)
|
| 34 |
+
gcs_client = storage.Client(
|
| 35 |
+
credentials=creds, project=service_account_info_dict["project_id"]
|
| 36 |
+
)
|
| 37 |
|
| 38 |
class CompletionReward:
|
| 39 |
def __init__(self):
|
|
|
|
| 59 |
"google": self.paragraph_google,
|
| 60 |
"mtk": self.paragraph_mtk,
|
| 61 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
def get_llm_response(self, player_logs):
|
| 64 |
agents_responses = {
|
|
|
|
| 164 |
):
|
| 165 |
insert_row = self.to_dict()
|
| 166 |
self.insert_data_into_bigquery(
|
| 167 |
+
gbq_client, "streaming_log", "log_mes_completion_rewards", [insert_row]
|
| 168 |
)
|
| 169 |
logging.info(
|
| 170 |
f"Player {insert_row['player_backend_user_id']} rendered successfully."
|
|
|
|
| 185 |
):
|
| 186 |
"""Uploads a file to the bucket and makes it publicly accessible."""
|
| 187 |
# Initialize a storage client
|
| 188 |
+
bucket = gcs_client.bucket(bucket_name)
|
| 189 |
blob = bucket.blob(destination_blob_name)
|
| 190 |
|
| 191 |
# Upload the file
|