File size: 2,946 Bytes
41302a5 8c89a6d 6a914f4 3788f63 bcc3eb3 3788f63 293121e 83b66cb 08dccaf 71d997f bcd8088 b62bff0 d2654c4 b62bff0 7368e62 bcd8088 7368e62 41302a5 7368e62 41302a5 7368e62 2b8f77a 7368e62 83b66cb 35b35ab f5e6a19 b4a4ef7 f5e6a19 feb488c 35b35ab be31a1d 3996319 04484c3 35b35ab b4a4ef7 35b35ab feb488c |
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# coding: utf-8
# Author: Du Mingzhe ([email protected])
# Date: 2025-04-01
import json
import random
import pandas as pd
import streamlit as st
from datasets import load_dataset
st.title("Code Arena")
with st.spinner("Loading data...", show_time=True):
problem_dict = dict()
ds = load_dataset("Elfsong/leetcode_data", split='train')
for problem in ds:
problem_id = problem["problem_id"]
problem_dict[problem_id] = problem
if "problem" in st.query_params:
problem_id = int(st.query_params["problem"])
problem_instance = problem_dict[problem_id]
with st.container(border=True):
st.write(f"Problem [{problem_id}]")
with st.expander("Problem Description"):
st.markdown(problem_instance["question_content"])
with st.expander("Test Cases"):
test_cases = json.loads(problem_instance["test_cases"])
df = pd.DataFrame(
{
"input": [test_case['input'] for test_case in test_cases],
"output": [test_case['output'] for test_case in test_cases],
}
)
st.dataframe(
df,
column_config={
"input": st.column_config.TextColumn("Input"),
"output": st.column_config.TextColumn("Output"),
},
column_order=("input", "output"),
)
else:
tab_problem, tab_submission, tab_model = st.tabs(["Problems", "Submissions", "Models"])
with tab_problem:
with st.spinner("Loading Framework...", show_time=True):
df = pd.DataFrame(
{
"problem_id": [int(problem['problem_id']) for problem in ds],
"problem_link": ["https://huggingface.co/spaces/Elfsong/CodeArena/?problem=" + str(problem['problem_id']) for problem in ds],
"dynamic_point": [[random.randint(0, 5000) for _ in range(30)] for problem in ds],
}
)
st.dataframe(
df,
column_config={
"problem_id": st.column_config.NumberColumn("Problem ID"),
"dynamic_point": st.column_config.LineChartColumn("Dynamic Point", y_min=0, y_max=5000),
"problem_link": st.column_config.LinkColumn("Link", display_text="Open"),
},
column_order=("problem_id", "dynamic_point", "problem_link"),
hide_index=True,
)
with tab_submission:
st.header("Submissions")
with tab_model:
model_list = ['llama-3.3', 'qwen-2.5', "openai-GPT4o"]
df = pd.DataFrame(
{
"model_name": [model_name for model_name in model_list],
}
)
st.dataframe(
df,
column_config={
"model_name": st.column_config.TextColumn("Problem ID"),
},
column_order=("model_name",),
hide_index=True,
)
|