oscarwang2 commited on
Commit
b28269b
1 Parent(s): e3ba515

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -4,8 +4,8 @@ import time
4
  from threading import Thread
5
 
6
  # Initialize clients
7
- client1 = Client("orionai/training-data-collection_2")
8
- client2 = Client("orionai/training-data-collection_3")
9
  client3 = Client("orionai/training-data-collection")
10
 
11
  state = {
@@ -52,18 +52,23 @@ Thread(target=monitor_growth, daemon=True).start()
52
  def get_dashboard_metrics():
53
  return state["prev_total_tokens"], state["total_growth_speed"]
54
 
 
 
 
 
55
  # Create Gradio Interface
56
  with gr.Blocks() as demo:
57
  gr.Markdown("# Token Count Dashboard")
 
58
  total_tokens = gr.Number(label="Total Token Count", value=0)
59
  growth_speed = gr.Number(label="Total Growth Speed", value=0)
60
 
61
- def update_dashboard():
62
- tokens, speed = get_dashboard_metrics()
63
  total_tokens.update(value=tokens)
64
  growth_speed.update(value=speed)
65
 
66
- # Automatically update the metrics every 5 seconds
67
- gr.Timer(5, update_dashboard)
68
-
69
  demo.launch()
 
4
  from threading import Thread
5
 
6
  # Initialize clients
7
+ client1 = Client("orionai/training-data-collection-2")
8
+ client2 = Client("orionai/training-data-collection-3")
9
  client3 = Client("orionai/training-data-collection")
10
 
11
  state = {
 
52
  def get_dashboard_metrics():
53
  return state["prev_total_tokens"], state["total_growth_speed"]
54
 
55
+ def update_dashboard():
56
+ tokens, speed = get_dashboard_metrics()
57
+ return tokens, speed
58
+
59
  # Create Gradio Interface
60
  with gr.Blocks() as demo:
61
  gr.Markdown("# Token Count Dashboard")
62
+
63
  total_tokens = gr.Number(label="Total Token Count", value=0)
64
  growth_speed = gr.Number(label="Total Growth Speed", value=0)
65
 
66
+ def refresh_metrics():
67
+ tokens, speed = update_dashboard()
68
  total_tokens.update(value=tokens)
69
  growth_speed.update(value=speed)
70
 
71
+ update_button = gr.Button("Update Stats")
72
+ update_button.click(refresh_metrics)
73
+
74
  demo.launch()