File size: 1,477 Bytes
996a1a8
 
 
 
 
 
 
d6096b9
 
996a1a8
 
 
d6096b9
 
 
 
 
 
 
 
996a1a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
MatVerse WebX Dashboard

A simple Gradio demo that exposes placeholder values for Ω (Omega), Ψ (Psi), Θ (Theta) and CVaR metrics.
Replace the `show_metrics` function with your own logic to fetch real metrics from your ledger or database.
"""
import gradio as gr
import requests


# Placeholder function to return sample metrics; replace with real data retrieval.
def show_metrics():
    url = "https://raw.githubusercontent.com/matverse-acoa/core/main/dashboard/metrics.json"
    try:
        resp = requests.get(url, timeout=10)
        resp.raise_for_status()
        return resp.json()
    except Exception as e:
        return {"error": str(e)}


with gr.Blocks(title="MatVerse WebX Dashboard") as demo:
    gr.Markdown("""# MatVerse WebX Dashboard
    
    This dashboard shows key metrics (Ω, Ψ, Θ, CVaR) for the WebX/MatVerse system. The values below are placeholders – you should connect this app to your
    backend or ledger to fetch live metrics.
    """)
    # Display metrics as a JSON-like view using a JSON component
    metrics_output = gr.JSON(label="Current Metrics")
    refresh_btn = gr.Button("Refresh Metrics")
    refresh_btn.click(fn=show_metrics, inputs=None, outputs=metrics_output)

# When this script is run directly (e.g. locally), launch the Gradio interface.
# On Hugging Face Spaces with sdk: gradio, this line is optional because the Space runtime will call demo.launch() automatically.
if __name__ == "__main__":
    demo.launch()