benediktstroebl commited on
Commit
356b0eb
·
1 Parent(s): f3c84ab
Files changed (3) hide show
  1. about.md +4 -0
  2. app.py +1 -1
  3. docs.md +0 -474
about.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+
2
+ # Agent leaderboard
3
+
4
+ Coming soon...
app.py CHANGED
@@ -51,7 +51,7 @@ with gr.Blocks() as demo:
51
  "results_cost": 20},
52
  )
53
  with gr.Tab("About"):
54
- gr.Markdown((Path(__file__).parent / "docs.md").read_text())
55
 
56
  if __name__ == "__main__":
57
  demo.launch()
 
51
  "results_cost": 20},
52
  )
53
  with gr.Tab("About"):
54
+ gr.Markdown((Path(__file__).parent / "about.md").read_text())
55
 
56
  if __name__ == "__main__":
57
  demo.launch()
docs.md DELETED
@@ -1,474 +0,0 @@
1
-
2
- # gradio_leaderboard
3
-
4
- ## 🔋⚡️🥇 Super fast, batteries included Leaderboards with minimal code.
5
- <img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.9%20-%20orange">
6
-
7
-
8
- The `gradio_leaderboard` package helps you build fully functional and performant leaderboard demos with `gradio`.
9
-
10
- Place the `gradio_leaderboard.Leaderboard` component anywhere in your Gradio application (and optionally pass in some configuration). That's it!
11
-
12
- For example usage, please see the [Usage](#usage) section.
13
-
14
- For details on configuration, please see the [Configuration](#configuration) section.
15
-
16
- For the API reference, see the [Initialization](#initialization) section.
17
-
18
- ## Installation
19
-
20
- ```bash
21
- pip install gradio_leaderboard
22
- ```
23
-
24
- or add `gradio_leaderboard` to your `requirements.txt`.
25
-
26
- ## Usage
27
-
28
- ```python
29
-
30
- import gradio as gr
31
- from gradio_leaderboard import Leaderboard
32
- from pathlib import Path
33
- import pandas as pd
34
-
35
- abs_path = Path(__file__).parent
36
-
37
- # Any pandas-compatible data
38
- df = pd.read_json(str(abs_path / "leaderboard_data.json"))
39
-
40
- with gr.Blocks() as demo:
41
- gr.Markdown("""
42
- # 🥇 Leaderboard Component
43
- """)
44
- Leaderboard(
45
- value=df,
46
- select_columns=["T", "Model", "Average ⬆️", "ARC",
47
- "HellaSwag", "MMLU", "TruthfulQA",
48
- "Winogrande", "GSM8K"],
49
- search_columns=["model_name_for_query", "Type"],
50
- hide_columns=["model_name_for_query", "Model Size"],
51
- filter_columns=["T", "Precision", "Model Size"],
52
- )
53
-
54
- if __name__ == "__main__":
55
- demo.launch()
56
- ```
57
-
58
- ## Configuration
59
-
60
- ### Selecting
61
-
62
- When column selection is enabled, a checkboxgroup will be displayed in the top left corner of the leaderboard that lets users
63
- select which columns are displayed.
64
-
65
- You can disable/configure the column selection behavior of the `Leaderboard` with the `select_columns` parameter.
66
- It's value can be:
67
-
68
- * `None`: Column selection is not allowed and all of the columns are displayed when the leaderboard loads.
69
- * `list of column names`: All columns can be selected and the elements of this list correspond to the initial set of selected columns.
70
- * `SelectColumns instance`: You can import `SelectColumns` from `gradio_leaderboard` for full control of the column selection behavior as well as the checkboxgroup appearance. See an example below.
71
-
72
- #### Demo
73
-
74
- ```python
75
- import pandas as pd
76
- import gradio as gr
77
- from gradio_leaderboard import Leaderboard, SelectColumns
78
-
79
- with gr.Blocks() as demo:
80
- Leaderboard(
81
- value=pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]}),
82
- select_columns=SelectColumns(default_selection=["a", "b"],
83
- cant_deselect="a",
84
- label="Select The Columns",
85
- info="Helpful information")
86
- )
87
-
88
- demo.launch()
89
- ```
90
-
91
- ![](https://github.com/freddyaboulton/gradio-leaderboard/assets/41651716/ea073681-c01e-4d40-814c-1f3cd56ef292)
92
-
93
-
94
- ### Searching
95
-
96
- When searching is enabled, a textbox will appear in the top left corner of the leaderboard.
97
- Users will be able to display rows that match their search query.
98
-
99
- Searching follows the following rules:
100
-
101
- 1. Multiple queries can be separated by a semicolon `;`.
102
- 2. Any subquery is matched against the `primary search column` by default.
103
- 3. To match against a `secondary search column`, the query must be preceded by the column name and a colon (`:`), e.g. `Name: Maria`.
104
- 4. The returned rows are those that match against `ANY` primary search column and `ALL` secondary search columns.
105
-
106
- You can configure searching with the `search_columns` parameter. It's value can be:
107
- * `a list`: In which case the first element is the `primary search column` and the remaining are the `secondary search columns`.
108
- * A `SearchColumns` instance. This lets you specify the primary and secondary columns explicitly as well as customize the search textbox appearance.
109
-
110
-
111
- #### Demo
112
-
113
- ```python
114
- import pandas as pd
115
- import gradio as gr
116
- from gradio_leaderboard import Leaderboard, SearchColumns
117
-
118
- with gr.Blocks() as demo:
119
- Leaderboard(
120
- value=pd.DataFrame({"name": ["Freddy", "Maria", "Mark"], "country": ["USA", "Mexico", "USA"]}),
121
- search_columns=SearchColumns(primary_column="name", secondary_columns="country",
122
- placeholder="Search by name or country. To search by country, type 'country:<query>'",
123
- label="Search"),
124
- )
125
-
126
- demo.launch()
127
- ```
128
-
129
- ![colum_search_gif](https://github.com/freddyaboulton/gradio-leaderboard/assets/41651716/4725f812-ffca-4ef9-951f-77574accd159)
130
-
131
-
132
- ### Filtering
133
-
134
- You can let users filter out rows from the leaderboard with the `filter_columns` parameter.
135
- This will display a series of form elements that users can use to select/deselect which rows are displayed.
136
-
137
- This parameter must be a `list` but it's elements must be:
138
-
139
- * `a string`: Corresponding to the column name you'd like to add a filter for
140
- * `a ColumnFilter`: A special class for full control of the filter's type, e.g. `checkboxgroup`, `boolean`, `slider`, or `dropdown`, as well as it's appearance in the UI.
141
-
142
- If the `type` of the `ColumnFilter` is not specified, a heuristic will be used to choose the most appropriate type. If the data in the column is boolean-valued, a `boolean` type will be used. If it is numeric, a slider will be used. For all others, a `checkboxgroup` will be used.
143
-
144
- All `ColumnFilters` of type `boolean` will be displayed together in a checkbox group. When a `checkbox` in that group is selected, only those rows that have a true value for that column will be displayed. When it is deselected, the table will not be filtered by that column.
145
- You can add a label to the `boolean` `checkboxgroup` with the `bool_checkboxgroup_label` parameter.
146
-
147
-
148
- #### Demo
149
-
150
- ```python
151
- import pandas as pd
152
- import gradio as gr
153
- from gradio_leaderboard import Leaderboard, ColumnFilter
154
-
155
- with gr.Blocks() as demo:
156
- Leaderboard(
157
- value=pd.DataFrame({"name": ["Freddy", "Maria", "Mark"], "country": ["USA", "Mexico", "USA"],
158
- "age": [25, 30, 35], "score": [100, 200, 300],
159
- "registered": [True, False, True]}),
160
- filter_columns=[
161
- "name",
162
- ColumnFilter("country", type="dropdown", label="Select Country 🇺🇸🇲🇽"),
163
- ColumnFilter("age", type="slider", min=20, max=40),
164
- ColumnFilter("score", type="slider", min=50, max=350),
165
- "registered"],
166
- bool_checkboxgroup_label="Only show registered"
167
- )
168
-
169
- demo.launch()
170
- ```
171
-
172
- ![filter_columns_gif](https://github.com/freddyaboulton/gradio-leaderboard/assets/41651716/07dc39a5-687c-414b-b96e-777fd01ebe00)
173
-
174
-
175
- ## `Leaderboard`
176
-
177
- ### Initialization
178
-
179
- <table>
180
- <thead>
181
- <tr>
182
- <th align="left">name</th>
183
- <th align="left" style="width: 25%;">type</th>
184
- <th align="left">default</th>
185
- <th align="left">description</th>
186
- </tr>
187
- </thead>
188
- <tbody>
189
- <tr>
190
- <td align="left"><code>value</code></td>
191
- <td align="left" style="width: 25%;">
192
-
193
- ```python
194
- pd.DataFrame | None
195
- ```
196
-
197
- </td>
198
- <td align="left"><code>None</code></td>
199
- <td align="left">Default value to display in the DataFrame. If a Styler is provided, it will be used to set the displayed value in the DataFrame (e.g. to set precision of numbers) if the `interactive` is False. If a Callable function is provided, the function will be called whenever the app loads to set the initial value of the component.</td>
200
- </tr>
201
-
202
- <tr>
203
- <td align="left"><code>datatype</code></td>
204
- <td align="left" style="width: 25%;">
205
-
206
- ```python
207
- str | list[str]
208
- ```
209
-
210
- </td>
211
- <td align="left"><code>"str"</code></td>
212
- <td align="left">Datatype of values in sheet. Can be provided per column as a list of strings, or for the entire sheet as a single string. Valid datatypes are "str", "number", "bool", "date", and "markdown".</td>
213
- </tr>
214
-
215
- <tr>
216
- <td align="left"><code>search_columns</code></td>
217
- <td align="left" style="width: 25%;">
218
-
219
- ```python
220
- list[str] | SearchColumns
221
- ```
222
-
223
- </td>
224
- <td align="left"><code>None</code></td>
225
- <td align="left">See Configuration section of docs for details.</td>
226
- </tr>
227
-
228
- <tr>
229
- <td align="left"><code>select_columns</code></td>
230
- <td align="left" style="width: 25%;">
231
-
232
- ```python
233
- list[str] | SelectColumns
234
- ```
235
-
236
- </td>
237
- <td align="left"><code>None</code></td>
238
- <td align="left">See Configuration section of docs for details.</td>
239
- </tr>
240
-
241
- <tr>
242
- <td align="left"><code>filter_columns</code></td>
243
- <td align="left" style="width: 25%;">
244
-
245
- ```python
246
- list[str | ColumnFilter] | None
247
- ```
248
-
249
- </td>
250
- <td align="left"><code>None</code></td>
251
- <td align="left">See Configuration section of docs for details.</td>
252
- </tr>
253
-
254
- <tr>
255
- <td align="left"><code>bool_checkboxgroup_label</code></td>
256
- <td align="left" style="width: 25%;">
257
-
258
- ```python
259
- str | None
260
- ```
261
-
262
- </td>
263
- <td align="left"><code>None</code></td>
264
- <td align="left">Label for the checkboxgroup filter for boolean columns.</td>
265
- </tr>
266
-
267
- <tr>
268
- <td align="left"><code>hide_columns</code></td>
269
- <td align="left" style="width: 25%;">
270
-
271
- ```python
272
- list[str] | None
273
- ```
274
-
275
- </td>
276
- <td align="left"><code>None</code></td>
277
- <td align="left">List of columns to hide by default. They will not be displayed in the table but they can still be used for searching, filtering.</td>
278
- </tr>
279
-
280
- <tr>
281
- <td align="left"><code>latex_delimiters</code></td>
282
- <td align="left" style="width: 25%;">
283
-
284
- ```python
285
- list[dict[str, str | bool]] | None
286
- ```
287
-
288
- </td>
289
- <td align="left"><code>None</code></td>
290
- <td align="left">A list of dicts of the form {"left": open delimiter (str), "right": close delimiter (str), "display": whether to display in newline (bool)} that will be used to render LaTeX expressions. If not provided, `latex_delimiters` is set to `[{ "left": "$$", "right": "$$", "display": True }]`, so only expressions enclosed in $$ delimiters will be rendered as LaTeX, and in a new line. Pass in an empty list to disable LaTeX rendering. For more information, see the [KaTeX documentation](https://katex.org/docs/autorender.html). Only applies to columns whose datatype is "markdown".</td>
291
- </tr>
292
-
293
- <tr>
294
- <td align="left"><code>label</code></td>
295
- <td align="left" style="width: 25%;">
296
-
297
- ```python
298
- str | None
299
- ```
300
-
301
- </td>
302
- <td align="left"><code>None</code></td>
303
- <td align="left">The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.</td>
304
- </tr>
305
-
306
- <tr>
307
- <td align="left"><code>show_label</code></td>
308
- <td align="left" style="width: 25%;">
309
-
310
- ```python
311
- bool | None
312
- ```
313
-
314
- </td>
315
- <td align="left"><code>None</code></td>
316
- <td align="left">if True, will display label.</td>
317
- </tr>
318
-
319
- <tr>
320
- <td align="left"><code>every</code></td>
321
- <td align="left" style="width: 25%;">
322
-
323
- ```python
324
- float | None
325
- ```
326
-
327
- </td>
328
- <td align="left"><code>None</code></td>
329
- <td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
330
- </tr>
331
-
332
- <tr>
333
- <td align="left"><code>height</code></td>
334
- <td align="left" style="width: 25%;">
335
-
336
- ```python
337
- int
338
- ```
339
-
340
- </td>
341
- <td align="left"><code>500</code></td>
342
- <td align="left">The maximum height of the dataframe, specified in pixels if a number is passed, or in CSS units if a string is passed. If more rows are created than can fit in the height, a scrollbar will appear.</td>
343
- </tr>
344
-
345
- <tr>
346
- <td align="left"><code>scale</code></td>
347
- <td align="left" style="width: 25%;">
348
-
349
- ```python
350
- int | None
351
- ```
352
-
353
- </td>
354
- <td align="left"><code>None</code></td>
355
- <td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
356
- </tr>
357
-
358
- <tr>
359
- <td align="left"><code>min_width</code></td>
360
- <td align="left" style="width: 25%;">
361
-
362
- ```python
363
- int
364
- ```
365
-
366
- </td>
367
- <td align="left"><code>160</code></td>
368
- <td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
369
- </tr>
370
-
371
- <tr>
372
- <td align="left"><code>interactive</code></td>
373
- <td align="left" style="width: 25%;">
374
-
375
- ```python
376
- bool | None
377
- ```
378
-
379
- </td>
380
- <td align="left"><code>None</code></td>
381
- <td align="left">if True, will allow users to edit the dataframe; if False, can only be used to display data. If not provided, this is inferred based on whether the component is used as an input or output.</td>
382
- </tr>
383
-
384
- <tr>
385
- <td align="left"><code>visible</code></td>
386
- <td align="left" style="width: 25%;">
387
-
388
- ```python
389
- bool
390
- ```
391
-
392
- </td>
393
- <td align="left"><code>True</code></td>
394
- <td align="left">If False, component will be hidden.</td>
395
- </tr>
396
-
397
- <tr>
398
- <td align="left"><code>elem_id</code></td>
399
- <td align="left" style="width: 25%;">
400
-
401
- ```python
402
- str | None
403
- ```
404
-
405
- </td>
406
- <td align="left"><code>None</code></td>
407
- <td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
408
- </tr>
409
-
410
- <tr>
411
- <td align="left"><code>elem_classes</code></td>
412
- <td align="left" style="width: 25%;">
413
-
414
- ```python
415
- list[str] | str | None
416
- ```
417
-
418
- </td>
419
- <td align="left"><code>None</code></td>
420
- <td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
421
- </tr>
422
-
423
- <tr>
424
- <td align="left"><code>render</code></td>
425
- <td align="left" style="width: 25%;">
426
-
427
- ```python
428
- bool
429
- ```
430
-
431
- </td>
432
- <td align="left"><code>True</code></td>
433
- <td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
434
- </tr>
435
-
436
- <tr>
437
- <td align="left"><code>wrap</code></td>
438
- <td align="left" style="width: 25%;">
439
-
440
- ```python
441
- bool
442
- ```
443
-
444
- </td>
445
- <td align="left"><code>False</code></td>
446
- <td align="left">If True, the text in table cells will wrap when appropriate. If False and the `column_width` parameter is not set, the column widths will expand based on the cell contents and the table may need to be horizontally scrolled. If `column_width` is set, then any overflow text will be hidden.</td>
447
- </tr>
448
-
449
- <tr>
450
- <td align="left"><code>line_breaks</code></td>
451
- <td align="left" style="width: 25%;">
452
-
453
- ```python
454
- bool
455
- ```
456
-
457
- </td>
458
- <td align="left"><code>True</code></td>
459
- <td align="left">If True (default), will enable Github-flavored Markdown line breaks in chatbot messages. If False, single new lines will be ignored. Only applies for columns of type "markdown."</td>
460
- </tr>
461
-
462
- <tr>
463
- <td align="left"><code>column_widths</code></td>
464
- <td align="left" style="width: 25%;">
465
-
466
- ```python
467
- list[str | int] | None
468
- ```
469
-
470
- </td>
471
- <td align="left"><code>None</code></td>
472
- <td align="left">An optional list representing the width of each column. The elements of the list should be in the format "100px" (ints are also accepted and converted to pixel values) or "10%". If not provided, the column widths will be automatically determined based on the content of the cells. Setting this parameter will cause the browser to try to fit the table within the page width.</td>
473
- </tr>
474
- </tbody></table>