zhimin-z commited on
Commit
a3a4515
·
1 Parent(s): 62e480e
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -29,6 +29,12 @@ api_key = os.getenv("API_KEY")
29
  base_url = "https://api.pandalla.ai/v1"
30
  openai_client = OpenAI(api_key=api_key, base_url=base_url)
31
 
 
 
 
 
 
 
32
  # Timeout in seconds for model responses
33
  TIMEOUT = 90
34
 
@@ -350,7 +356,7 @@ def is_file_within_time_frame(file_path, days):
350
  return False
351
 
352
 
353
- def load_content_from_hf(repo_name="SWE-Arena/vote_data"):
354
  """
355
  Read feedback content from a Hugging Face repository within the last LEADERBOARD_UPDATE_TIME_FRAME_DAYS days.
356
 
@@ -387,8 +393,8 @@ def get_leaderboard_data(vote_entry=None, use_cache=True):
387
  if use_cache:
388
  try:
389
  cached_path = hf_hub_download(
390
- repo_id="SWE-Arena/leaderboard_data",
391
- filename="swe-model-arena.json",
392
  repo_type="dataset",
393
  )
394
  with open(cached_path, "r") as f:
@@ -437,7 +443,7 @@ def get_leaderboard_data(vote_entry=None, use_cache=True):
437
  )
438
 
439
  # Load conversation data from the Hugging Face repository
440
- conversation_data = load_content_from_hf("SWE-Arena/conversation_data")
441
  conversation_df = pd.DataFrame(conversation_data)
442
 
443
  # Merge vote data with conversation data
@@ -611,8 +617,8 @@ def get_leaderboard_data(vote_entry=None, use_cache=True):
611
 
612
  upload_file(
613
  path_or_fileobj=file_like_object,
614
- path_in_repo="swe-model-arena.json",
615
- repo_id="SWE-Arena/leaderboard_data",
616
  repo_type="dataset",
617
  token=HfApi().token,
618
  )
@@ -1429,7 +1435,7 @@ with gr.Blocks(title="SWE-Model-Arena", theme=gr.themes.Soft()) as app:
1429
 
1430
  # Save feedback back to the Hugging Face dataset
1431
  save_content_to_hf(
1432
- vote_entry, "SWE-Arena/vote_data", file_name, token
1433
  )
1434
 
1435
  conversation_state["right_chat"][0]["content"] = conversation_state[
@@ -1442,7 +1448,7 @@ with gr.Blocks(title="SWE-Model-Arena", theme=gr.themes.Soft()) as app:
1442
  # Save conversations back to the Hugging Face dataset
1443
  save_content_to_hf(
1444
  conversation_state,
1445
- "SWE-Arena/conversation_data",
1446
  file_name,
1447
  token,
1448
  )
 
29
  base_url = "https://api.pandalla.ai/v1"
30
  openai_client = OpenAI(api_key=api_key, base_url=base_url)
31
 
32
+ # Hugging Face repository names for data storage
33
+ LEADERBOARD_REPO = "SWE-Arena/leaderboard_data"
34
+ VOTE_REPO = "SWE-Arena/vote_data"
35
+ CONVERSATION_REPO = "SWE-Arena/conversation_data"
36
+ LEADERBOARD_FILE = "model-arena.json"
37
+
38
  # Timeout in seconds for model responses
39
  TIMEOUT = 90
40
 
 
356
  return False
357
 
358
 
359
+ def load_content_from_hf(repo_name):
360
  """
361
  Read feedback content from a Hugging Face repository within the last LEADERBOARD_UPDATE_TIME_FRAME_DAYS days.
362
 
 
393
  if use_cache:
394
  try:
395
  cached_path = hf_hub_download(
396
+ repo_id=LEADERBOARD_REPO,
397
+ filename=LEADERBOARD_FILE,
398
  repo_type="dataset",
399
  )
400
  with open(cached_path, "r") as f:
 
443
  )
444
 
445
  # Load conversation data from the Hugging Face repository
446
+ conversation_data = load_content_from_hf(CONVERSATION_REPO)
447
  conversation_df = pd.DataFrame(conversation_data)
448
 
449
  # Merge vote data with conversation data
 
617
 
618
  upload_file(
619
  path_or_fileobj=file_like_object,
620
+ path_in_repo=LEADERBOARD_FILE,
621
+ repo_id=LEADERBOARD_REPO,
622
  repo_type="dataset",
623
  token=HfApi().token,
624
  )
 
1435
 
1436
  # Save feedback back to the Hugging Face dataset
1437
  save_content_to_hf(
1438
+ vote_entry, VOTE_REPO, file_name, token
1439
  )
1440
 
1441
  conversation_state["right_chat"][0]["content"] = conversation_state[
 
1448
  # Save conversations back to the Hugging Face dataset
1449
  save_content_to_hf(
1450
  conversation_state,
1451
+ CONVERSATION_REPO,
1452
  file_name,
1453
  token,
1454
  )