rodrigomasini
commited on
Update app.py
Browse files
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 |
-
|
209 |
-
client
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
#
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|