Clémentine commited on
Commit
784d3ed
1 Parent(s): 23f614e

test 1 with webhooks

Browse files
Files changed (2) hide show
  1. README.md +1 -0
  2. app.py +23 -1
README.md CHANGED
@@ -15,6 +15,7 @@ space_ci:
15
  private: true
16
  secrets:
17
  - HF_TOKEN
 
18
  tags:
19
  - leaderboard
20
  short_description: Track, rank and evaluate open LLMs and chatbots
 
15
  private: true
16
  secrets:
17
  - HF_TOKEN
18
+ - WEBHOOK_SECRET
19
  tags:
20
  - leaderboard
21
  short_description: Track, rank and evaluate open LLMs and chatbots
app.py CHANGED
@@ -3,7 +3,7 @@ import logging
3
  import time
4
  import gradio as gr
5
  import datasets
6
- from huggingface_hub import snapshot_download
7
  from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
8
  from gradio_space_ci import enable_space_ci
9
 
@@ -290,4 +290,26 @@ with demo:
290
  show_copy_button=True,
291
  )
292
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  demo.queue(default_concurrency_limit=40).launch()
 
3
  import time
4
  import gradio as gr
5
  import datasets
6
+ from huggingface_hub import snapshot_download, webhook_endpoint, WebhookPayload
7
  from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
8
  from gradio_space_ci import enable_space_ci
9
 
 
290
  show_copy_button=True,
291
  )
292
 
293
+ @webhook_endpoint
294
+ async def update_leaderboard(payload: WebhookPayload) -> None:
295
+ if payload.repo.type == "dataset" and payload.event.action == "update":
296
+ leaderboard_dataset = datasets.load_dataset(AGGREGATED_REPO, "default", split="train", cache_dir=HF_HOME)
297
+ leaderboard_df = get_leaderboard_df(
298
+ leaderboard_dataset=leaderboard_dataset,
299
+ cols=COLS,
300
+ benchmark_cols=BENCHMARK_COLS,
301
+ )
302
+ leaderboard.value = leaderboard_df
303
+
304
+ @webhook_endpoint
305
+ async def update_queue(payload: WebhookPayload) -> None:
306
+ if payload.repo.type == "dataset" and payload.event.action == "update":
307
+ download_dataset(QUEUE_REPO, EVAL_REQUESTS_PATH)
308
+ eval_queue_dfs = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
309
+ finished_eval_queue_df, running_eval_queue_df, pending_eval_queue_df = eval_queue_dfs
310
+
311
+ finished_eval_table.value = finished_eval_queue_df
312
+ running_eval_table.value = running_eval_queue_df
313
+ pending_eval_table.value = pending_eval_queue_df
314
+
315
  demo.queue(default_concurrency_limit=40).launch()