rodrigomasini commited on
Commit
413ba3e
1 Parent(s): 97453a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -30
app.py CHANGED
@@ -224,44 +224,53 @@ def display(x, y):
224
  leaderboard_df[column] = leaderboard_df[column].apply(remove_invalid_unicode)
225
 
226
  subset_df = leaderboard_df[COLS]
227
- # Ensure the output directory exists
228
- #output_dir = 'output'
229
- #if not os.path.exists(output_dir):
230
- # os.makedirs(output_dir)
231
- #
232
- ## Save JSON to a file in the output directory
233
- #output_file_path = os.path.join(output_dir, 'output.json')
234
- #with open(output_file_path, 'w') as file:
235
- # file.write(subset_df.to_json(orient='records'))
236
-
237
- #first_50_rows = subset_df.head(50)
238
- #print(first_50_rows.to_string())
239
- #json_data = first_50_rows.to_json(orient='records')
240
- #print(json_data) # Print JSON representation
241
  return subset_df
242
 
243
  INTRODUCTION_TEXT = """
244
- This is a copied space from Open Source LLM leaderboard. Instead of displaying
245
- the results as table the space simply provides a gradio API interface to access
246
- the full leaderboard data easily.
247
-
248
- Example python on how to access the data:
249
- ```python
250
  from gradio_client import Client
251
- import json
252
- client = Client("https://felixz-open-llm-leaderboard.hf.space/")
253
 
254
- json_data = client.predict("","", api_name='/predict')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
 
256
- with open(json_data, 'r') as file:
257
- file_data = file.read()
258
 
259
- # Load the JSON data
260
- data = json.loads(file_data)
261
 
262
- # Get the headers and the data
263
- headers = data['headers']
264
- data = data['data']
265
  ```
266
 
267
  """
 
224
  leaderboard_df[column] = leaderboard_df[column].apply(remove_invalid_unicode)
225
 
226
  subset_df = leaderboard_df[COLS]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  return subset_df
228
 
229
  INTRODUCTION_TEXT = """
230
+ This is a copied space from Enterprise Scenarios Leaderboard. Instead of displaying
231
+ the results as table this space was modified to simply provides a gradio API interface.
232
+ Using the following python script below, users can access the full leaderboard data easily.
233
+ Python on how to access the data:
234
+ # Import dependencies
 
235
  from gradio_client import Client
 
 
236
 
237
+ # Initialize the Gradio client with the API URL
238
+ client = Client("https://rodrigomasini-data-only-enterprise-scenarios-leaderboard.hf.space/")
239
+
240
+ try:
241
+ # Perform the API call
242
+ response = client.predict("","", api_name='/predict')
243
+
244
+ # Check if response it's directly accessible
245
+ if len(response) > 0:
246
+ print("Response received!")
247
+ headers = response.get('headers', [])
248
+ data = response.get('data', [])
249
+
250
+ print(headers)
251
+
252
+ # Remove commenst if you want to download the dataset and save in csv format
253
+ # Specify the path to your CSV file
254
+ #csv_file_path = 'enterprise-scenarios-benchmark.csv'
255
+
256
+ # Open the CSV file for writing
257
+ #with open(csv_file_path, mode='w', newline='', encoding='utf-8') as file:
258
+ # writer = csv.writer(file)
259
+
260
+ # Write the headers
261
+ # writer.writerow(headers)
262
+
263
+ # Write the data
264
+ # for row in data:
265
+ # writer.writerow(row)
266
 
267
+ #print(f"Results saved to {csv_file_path}")
 
268
 
269
+ # If the above line prints a string that looks like JSON, you can parse it with json.loads(response)
270
+ # Otherwise, you might need to adjust based on the actual structure of `response`
271
 
272
+ except Exception as e:
273
+ print(f"An error occurred: {e}")
 
274
  ```
275
 
276
  """