Spaces:
Runtime error
Runtime error
import gradio as gr | |
import pandas as pd | |
import numpy as np | |
# ๋ฐ์ดํฐ ์ ์ (ํ๋์ฝ๋ฉ) | |
data = { | |
"Company/Model": [ | |
"Anthropic/Claude 3 Opus", | |
"OpenAI/GPT-4", | |
"Google/Gemini Ultra", | |
"Cohere/Command R+", | |
"Naver/HyperCLOVA X", | |
"Kakao/KoGPT" | |
], | |
"URL": [ | |
"https://www.anthropic.com/claude", | |
"https://openai.com/gpt-4", | |
"https://deepmind.google/technologies/gemini/", | |
"https://cohere.com/models/command-r-plus", | |
"https://clova.ai/hyperclova", | |
"https://kogpt.ai/" | |
], | |
"Korean Bar Exam (๋ณํธ์ฌ)": [85, 82, 80, 75, 79, 77], | |
"Senior Civil Service Examination (๊ตญ๊ฐ์ง 5๊ธ)": [88, 84, 83, 76, 81, 78] | |
} | |
# DataFrame ์์ฑ | |
df = pd.DataFrame(data) | |
# Average ์ ์ ๊ณ์ฐ | |
exam_columns = ["Korean Bar Exam (๋ณํธ์ฌ)", "Senior Civil Service Examination (๊ตญ๊ฐ์ง 5๊ธ)"] | |
df["Average"] = df[exam_columns].mean(axis=1).round(1) | |
# ์ด ์์ ์ฌ๋ฐฐ์น (Company/Model, URL, Average, ๊ทธ ๋ค์ ๊ฐ ์ํ) | |
cols = ["Company/Model", "URL", "Average"] + exam_columns | |
df = df[cols] | |
# HTML๋ก ๋ ๋๋งํ๊ธฐ ์ํ ํจ์ (URL์ ํด๋ฆญ ๊ฐ๋ฅํ ๋งํฌ๋ก ๋ณํ) | |
def format_df_as_html(df): | |
# DataFrame ๋ณต์ฌ๋ณธ ์์ฑ | |
display_df = df.copy() | |
# URL ์ด์ ํด๋ฆญ ๊ฐ๋ฅํ ๋งํฌ๋ก ๋ณํ | |
for i, url in enumerate(display_df["URL"]): | |
model_name = display_df.iloc[i]["Company/Model"] | |
display_df.at[i, "Company/Model"] = f'<a href="{url}" target="_blank">{model_name}</a>' | |
# URL ์ด ์ ๊ฑฐ (์ด๋ฏธ Company/Model์ ๋งํฌ๋ก ํตํฉ) | |
display_df = display_df.drop("URL", axis=1) | |
# ํ ์คํ์ผ ์ถ๊ฐ | |
styled_html = """ | |
<style> | |
table { | |
width: 100%; | |
border-collapse: collapse; | |
font-family: Arial, sans-serif; | |
} | |
th { | |
background-color: #4CAF50; | |
color: white; | |
font-weight: bold; | |
text-align: left; | |
padding: 12px; | |
} | |
td { | |
padding: 10px; | |
border-bottom: 1px solid #ddd; | |
} | |
tr:nth-child(even) { | |
background-color: #f2f2f2; | |
} | |
tr:hover { | |
background-color: #ddd; | |
} | |
.header { | |
text-align: center; | |
font-size: 24px; | |
font-weight: bold; | |
margin-bottom: 20px; | |
color: #333; | |
} | |
</style> | |
<div class="header">Korean Exam Leaderboard</div> | |
""" | |
# DataFrame์ HTML๋ก ๋ณํํ๊ณ ์คํ์ผ ์ ์ฉ | |
html_table = display_df.to_html(index=False, escape=False) | |
return styled_html + html_table | |
# Gradio ์ธํฐํ์ด์ค | |
def show_leaderboard(): | |
html_content = format_df_as_html(df) | |
return html_content | |
# ์ธํฐํ์ด์ค ์์ฑ | |
demo = gr.Interface( | |
fn=show_leaderboard, | |
inputs=None, | |
outputs=gr.HTML(), | |
title="Korean Exam Leaderboard", | |
description="์ฑ๋ฅ ๋น๊ต: ํ๊ตญ ๋ฒํ ๋ฐ ํ์ ๊ณ ์ ์ํ์์์ AI ๋ชจ๋ธ ์ ์" | |
) | |
# ์ฑ ์คํ | |
if __name__ == "__main__": | |
demo.launch() |