File size: 1,708 Bytes
1629593
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
"""
Streamlit dashboard for the Dippy Roleplay Subnet Leaderboard
"""
import requests
import streamlit as st
import pandas as pd

def leaderboard_dashboard():
    # st.image("banner.jpg")
    st.markdown("<h1 style='text-align: center;'>SN11-Dippy-Roleplay Leaderboard</h1>", unsafe_allow_html=True)
    st.markdown("<div style='text-align: center;'>This is the leaderboard for the Dippy validation API hosted by SN11.</div>", unsafe_allow_html=True)
    st.markdown("---")
    
    # Add emojis based on the status
    status_emojis = {
        'COMPLETED': '✅COMPLETED',
        'FAILED': '❌FAILED',
        'QUEUED': '🕒QUEUED',
        'RUNNING': '🏃RUNNING'
    }

    # Get the leaderboard data from the API
    response = requests.get("http://34.41.206.211:8000/leaderboard")
    if response.status_code != 200:
        st.error("Failed to fetch leaderboard data.")
        return
    
    # Parse the response JSON data
    leaderboard_data = response.json()
    # Convert the data to a DataFrame
    leaderboard = pd.DataFrame(leaderboard_data)

    leaderboard['status'] = leaderboard['status'].map(lambda status: status_emojis.get(status, status))
    # Sort the leaderboard by the total_score column
    leaderboard = leaderboard.sort_values(by='total_score', ascending=False, ignore_index=True)

    front_order = ['repo_namespace', 'repo_name', 'total_score', 'status', 'chat_template_type', 'hash']

    # move status column to the front
    column_order = front_order + [column for column in leaderboard.columns if column not in front_order]

    leaderboard = leaderboard[column_order]

    st.dataframe(leaderboard, width=900)

if __name__ == '__main__':
    leaderboard_dashboard()