JarvisKi commited on
Commit
df86ac1
1 Parent(s): 753c55e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -54,7 +54,7 @@ def generate_table(data):
54
  protected_methods = ["GPT-4-Turbo-Preview (DFS)", "GPT-3.5-Turbo-1106 (DFS)", "GPT-4-0613 (DFS)", "GPT-3.5-Turbo-0613 (DFS)", "GPT-4-Turbo-Preview (CoT)", "ToolLLaMA v2 (DFS)", "GPT-4-0613 (CoT)", "GPT-3.5-Turbo-1106 (CoT)", "GPT-3.5-Turbo-0613 (CoT)", "ToolLLaMA v2 (CoT)"]
55
 
56
  # 合并上传的数据到已有的数据中
57
- def merge_data(uploaded_data_json, existing_data):
58
  # No need to call json.loads here because uploaded_data is already a Python dict
59
  new_data = uploaded_data_json
60
  with scheduler.lock: # 确保文件操作的线程安全
@@ -94,17 +94,18 @@ def merge_data(uploaded_data_json, existing_data):
94
  # No need to sort here since we're doing it in the generate_table function
95
  return existing_data
96
 
97
- def process_file(file_info, existing_data):
98
  if file_info is not None:
99
  # 如果 file_info 是文件的路径字符串,需要使用 'open' 来读取文件
100
  with open(file_info, "r") as uploaded_file:
101
  data_content = uploaded_file.read()
102
  uploaded_data_json = json.loads(data_content)
103
  # Merge the uploaded data
104
- existing_data = merge_data(uploaded_data_json)
105
  scheduler.commit() # Trigger manual commit after processing
106
  # If we don't return anything here, gradio will not update the table
107
  # We need to return the new data for the table if it's interactive
 
108
  pass_rate_table = generate_table(existing_data["SolvablePassRateScores"])[1]
109
  win_rate_table = generate_table(existing_data["SolvableWinRateScores"])[1]
110
  return pass_rate_table, win_rate_table
@@ -228,7 +229,7 @@ with gr.Blocks() as app:
228
 
229
  submit_button.click(
230
  fn=process_file,
231
- inputs= [upload_component,existing_data],
232
  outputs=[table1, table2]
233
  )
234
 
 
54
  protected_methods = ["GPT-4-Turbo-Preview (DFS)", "GPT-3.5-Turbo-1106 (DFS)", "GPT-4-0613 (DFS)", "GPT-3.5-Turbo-0613 (DFS)", "GPT-4-Turbo-Preview (CoT)", "ToolLLaMA v2 (DFS)", "GPT-4-0613 (CoT)", "GPT-3.5-Turbo-1106 (CoT)", "GPT-3.5-Turbo-0613 (CoT)", "ToolLLaMA v2 (CoT)"]
55
 
56
  # 合并上传的数据到已有的数据中
57
+ def merge_data(uploaded_data_json):
58
  # No need to call json.loads here because uploaded_data is already a Python dict
59
  new_data = uploaded_data_json
60
  with scheduler.lock: # 确保文件操作的线程安全
 
94
  # No need to sort here since we're doing it in the generate_table function
95
  return existing_data
96
 
97
+ def process_file(file_info):
98
  if file_info is not None:
99
  # 如果 file_info 是文件的路径字符串,需要使用 'open' 来读取文件
100
  with open(file_info, "r") as uploaded_file:
101
  data_content = uploaded_file.read()
102
  uploaded_data_json = json.loads(data_content)
103
  # Merge the uploaded data
104
+ merge_data(uploaded_data_json)
105
  scheduler.commit() # Trigger manual commit after processing
106
  # If we don't return anything here, gradio will not update the table
107
  # We need to return the new data for the table if it's interactive
108
+ existing_data = load_data()
109
  pass_rate_table = generate_table(existing_data["SolvablePassRateScores"])[1]
110
  win_rate_table = generate_table(existing_data["SolvableWinRateScores"])[1]
111
  return pass_rate_table, win_rate_table
 
229
 
230
  submit_button.click(
231
  fn=process_file,
232
+ inputs= upload_component,
233
  outputs=[table1, table2]
234
  )
235