Spaces:
Sleeping
Sleeping
| """ | |
| Streamlit dashboard for the Dippy Roleplay Subnet Leaderboard | |
| """ | |
| import requests | |
| import streamlit as st | |
| import pandas as pd | |
| def leaderboard_dashboard(): | |
| st.image("../assests/banner.png") | |
| 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() |