rodrigomasini commited on
Commit
3e4c70d
·
verified ·
1 Parent(s): 447cb59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -14
app.py CHANGED
@@ -192,22 +192,51 @@ def display(x, y):
192
  return subset_df
193
 
194
  INTRODUCTION_TEXT = """
195
- This is a copied space from Open Source LLM leaderboard. Instead of displaying
196
- the results as table the space simply provides a gradio API interface to access
197
- the full leaderboard data easily.
198
- Example python on how to access the data:
199
  ```python
 
200
  from gradio_client import Client
201
- import json
202
- client = Client("https://felixz-open-llm-leaderboard.hf.space/")
203
- json_data = client.predict("","", api_name='/predict')
204
- with open(json_data, 'r') as file:
205
- file_data = file.read()
206
- # Load the JSON data
207
- data = json.loads(file_data)
208
- # Get the headers and the data
209
- headers = data['headers']
210
- data = data['data']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  ```
212
  """
213
 
 
192
  return subset_df
193
 
194
  INTRODUCTION_TEXT = """
195
+ This is a copied space from Enterprise Scenarios Leaderboard. Instead of displaying
196
+ the results as table this space was modified to simply provides a gradio API interface.
197
+ Using the following python script below, users can access the full leaderboard data easily.
198
+ Python on how to access the data:
199
  ```python
200
+ # Import dependencies
201
  from gradio_client import Client
202
+
203
+ # Initialize the Gradio client with the API URL
204
+ client = Client("https://rodrigomasini-data-only-enterprise-scenarios-leaderboard.hf.space/")
205
+
206
+ try:
207
+ # Perform the API call
208
+ response = client.predict("","", api_name='/predict')
209
+
210
+ # Check if response it's directly accessible
211
+ if len(response) > 0:
212
+ print("Response received!")
213
+ headers = response.get('headers', [])
214
+ data = response.get('data', [])
215
+
216
+ print(headers)
217
+
218
+ # Remove commenst if you want to download the dataset and save in csv format
219
+ # Specify the path to your CSV file
220
+ #csv_file_path = 'enterprise-scenarios-benchmark.csv'
221
+
222
+ # Open the CSV file for writing
223
+ #with open(csv_file_path, mode='w', newline='', encoding='utf-8') as file:
224
+ # writer = csv.writer(file)
225
+
226
+ # Write the headers
227
+ # writer.writerow(headers)
228
+
229
+ # Write the data
230
+ # for row in data:
231
+ # writer.writerow(row)
232
+
233
+ #print(f"Results saved to {csv_file_path}")
234
+
235
+ # If the above line prints a string that looks like JSON, you can parse it with json.loads(response)
236
+ # Otherwise, you might need to adjust based on the actual structure of `response`
237
+
238
+ except Exception as e:
239
+ print(f"An error occurred: {e}")
240
  ```
241
  """
242