rodrigomasini commited on
Commit
5dc37c0
·
verified ·
1 Parent(s): 8dab3d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -10
app.py CHANGED
@@ -204,17 +204,48 @@ the results as table the space simply provides a gradio API interface to access
204
  the full leaderboard data easily.
205
  Example python on how to access the data:
206
  ```python
 
207
  from gradio_client import Client
208
- import json
209
- client = Client("https://felixz-open-llm-leaderboard.hf.space/")
210
- json_data = client.predict("","", api_name='/predict')
211
- with open(json_data, 'r') as file:
212
- file_data = file.read()
213
- # Load the JSON data
214
- data = json.loads(file_data)
215
- # Get the headers and the data
216
- headers = data['headers']
217
- data = data['data']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  ```
219
  """
220
 
 
204
  the full leaderboard data easily.
205
  Example python on how to access the data:
206
  ```python
207
+ # Import dependencies
208
  from gradio_client import Client
209
+
210
+ # Initialize the Gradio client with the API URL
211
+ client = Client("https://rodrigomasini-data-only-llm-trustworthy-leaderboard.hf.space/")
212
+
213
+ try:
214
+ # Perform the API call
215
+ response = client.predict("","", api_name='/predict')
216
+
217
+ # Check if response it's directly accessible
218
+ if len(response) > 0:
219
+ print("Response received!")
220
+ headers = response.get('headers', [])
221
+ data = response.get('data', [])
222
+
223
+ print(headers)
224
+
225
+ # Remove commenst if you want to download the dataset and save in csv format
226
+ # Specify the path to your CSV file
227
+ #csv_file_path = 'llm-trustworthy-benchmark.csv'
228
+
229
+ # Open the CSV file for writing
230
+ #with open(csv_file_path, mode='w', newline='', encoding='utf-8') as file:
231
+ # writer = csv.writer(file)
232
+
233
+ # Write the headers
234
+ # writer.writerow(headers)
235
+
236
+ # Write the data
237
+ # for row in data:
238
+ # writer.writerow(row)
239
+
240
+ #print(f"Results saved to {csv_file_path}")
241
+
242
+ # If the above line prints a string that looks like JSON, you can parse it with json.loads(response)
243
+ # Otherwise, you might need to adjust based on the actual structure of `response`
244
+
245
+ except Exception as e:
246
+ print(f"An error occurred: {e}")
247
+ ```
248
+ """
249
  ```
250
  """
251