import gradio as gr from data_loader import CATEGORIES, DESCRIPTION_HTML, CARDS from visualization import ( get_performance_chart, get_performance_cost_chart, ) from utils import ( get_rank_badge, get_score_bar, get_type_badge, ) def filter_leaderboard(df, model_type, category, sort_by): filtered_df = df.copy() if model_type != "All": filtered_df = filtered_df[filtered_df["Model Type"].str.strip() == model_type] dataset_columns = CATEGORIES.get(category, ["Model Avg"]) filtered_df["Category Score"] = filtered_df[dataset_columns].mean(axis=1) if sort_by == "Performance": filtered_df = filtered_df.sort_values(by="Category Score", ascending=False) else: filtered_df = filtered_df.sort_values(by="IO Cost", ascending=True) filtered_df["Rank"] = range(1, len(filtered_df) + 1) perf_chart = get_performance_chart(filtered_df, category) cost_chart = get_performance_cost_chart(filtered_df, category) # Generate styled table HTML table_html = f"""
Note: API pricing for sorting by cost uses a 3-to-1 input/output ratio calculation. DeepSeek V3 and R1 were excluded from rankings due to limited function support. Pricing for Gemini models shown reflects Vertex AI. Google AI Studio offers Gemini API Access at a lower cost with an API Key.
Rank | Model | Type | Vendor | Cost (I/O) | Avg Category Score (TSQ) |
---|---|---|---|---|---|
{get_rank_badge(row['Rank'])} | {row['Model']} | {get_type_badge(row['Model Type'])} | {row['Vendor']} | ${row['Input cost per million token']:.2f}/${row['Output cost per million token']:.2f} | {get_score_bar(row['Category Score'])} |