winglian commited on
Commit
14031c6
1 Parent(s): 2c41f4b

markdown table

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -205,9 +205,27 @@ chosen_one_second = functools.partial(chosen_one, 2)
205
  chosen_one_tie = functools.partial(chosen_one, 0)
206
  chosen_one_suck = functools.partial(chosen_one, 1)
207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  elo_scores = load_dataset("openaccess-ai-collective/chatbot-arena-elo-scores")
209
  elo_scores = elo_scores.sort("elo_score")
210
 
 
211
  with gr.Blocks() as arena:
212
  with gr.Row():
213
  with gr.Column():
@@ -258,10 +276,10 @@ with gr.Blocks() as arena:
258
  with gr.Tab("Leaderboard"):
259
  with gr.Column():
260
  gr.Markdown(f"""
261
- ### TBD
262
- - This is very much a work-in-progress, if you'd like to help build this out, join us on [Discord](https://discord.gg/QYF8QrtEUm)
263
- """)
264
- gr.DataFrame(elo_scores)
265
  state = gr.State({})
266
 
267
  clear.click(lambda: None, None, chatbot1, queue=False)
 
205
  chosen_one_tie = functools.partial(chosen_one, 0)
206
  chosen_one_suck = functools.partial(chosen_one, 1)
207
 
208
+
209
+ def dataset_to_markdown(dataset):
210
+ # Get column names (dataset features)
211
+ columns = list(dataset.features.keys())
212
+ # Start markdown string with table headers
213
+ markdown_string = "| " + " | ".join(columns) + " |\n"
214
+ # Add markdown table row separator for headers
215
+ markdown_string += "| " + " | ".join("---" for _ in columns) + " |\n"
216
+
217
+ # Add each row from dataset to the markdown string
218
+ for i in range(len(dataset)):
219
+ row = dataset[i]
220
+ markdown_string += "| " + " | ".join(str(row[column]) for column in columns) + " |\n"
221
+
222
+ return markdown_string
223
+
224
+
225
  elo_scores = load_dataset("openaccess-ai-collective/chatbot-arena-elo-scores")
226
  elo_scores = elo_scores.sort("elo_score")
227
 
228
+
229
  with gr.Blocks() as arena:
230
  with gr.Row():
231
  with gr.Column():
 
276
  with gr.Tab("Leaderboard"):
277
  with gr.Column():
278
  gr.Markdown(f"""
279
+ ### TBD
280
+ - This is very much a work-in-progress, if you'd like to help build this out, join us on [Discord](https://discord.gg/QYF8QrtEUm)
281
+ {dataset_to_markdown(elo_scores)}
282
+ """)
283
  state = gr.State({})
284
 
285
  clear.click(lambda: None, None, chatbot1, queue=False)