|
import pandas as pd |
|
import gradio as gr |
|
import os |
|
from gradio_rangeslider import RangeSlider |
|
|
|
from utils.filter_utils import filter |
|
|
|
|
|
|
|
|
|
text_leaderboard = pd.read_csv(os.path.join('src', 'main_df.csv')) |
|
text = "## The range is: {min} to {max}" |
|
|
|
|
|
short_leaderboard = text_leaderboard[[ |
|
'model_name', |
|
'input_price', |
|
'output_price', |
|
'release_date', |
|
'context_size', |
|
'average_clemscore', |
|
'average_latency', |
|
'parameter_size', |
|
]] |
|
|
|
|
|
langs = [] |
|
for i in range(len(text_leaderboard)): |
|
lang_splits = text_leaderboard.iloc[i]['languages'].split(',') |
|
lang_splits = [s.strip() for s in lang_splits] |
|
langs += lang_splits |
|
langs = list(set(langs)) |
|
langs.sort() |
|
|
|
|
|
ip_prices = [] |
|
op_prices = [] |
|
for i in range(len(text_leaderboard)): |
|
ip_prices.append(text_leaderboard.iloc[i]['input_price']) |
|
op_prices.append(text_leaderboard.iloc[i]['output_price']) |
|
|
|
max_input_price = max(ip_prices) |
|
max_output_price = max(op_prices) |
|
|
|
|
|
llm_calc_app = gr.Blocks() |
|
with llm_calc_app: |
|
|
|
with gr.Row(): |
|
""" |
|
Main Filters Row |
|
""" |
|
|
|
|
|
with gr.Row(): |
|
lang_dropdown = gr.Dropdown( |
|
choices=langs, |
|
value=[], |
|
multiselect=True, |
|
label="Select Languages 🕹️" |
|
) |
|
|
|
clemscore_slider = RangeSlider( |
|
minimum=0, |
|
maximum=100, |
|
value=(0, 100), |
|
label="Select Clemscore range" |
|
) |
|
|
|
input_pricing_slider = RangeSlider( |
|
minimum=0, |
|
maximum=max_input_price, |
|
value=(0, max_input_price), |
|
label="Select Price range /1M input tokens" |
|
) |
|
|
|
output_pricing_slider = RangeSlider( |
|
minimum=0, |
|
maximum=max_output_price, |
|
value=(0, max_output_price), |
|
label="Select Price range /1M output tokens" |
|
) |
|
|
|
|
|
|
|
with gr.Row(): |
|
""" |
|
Main Leaderboard Row |
|
""" |
|
|
|
leaderboard_table = gr.Dataframe( |
|
value=short_leaderboard, |
|
elem_id="text-leaderboard-table", |
|
interactive=False, |
|
visible=True, |
|
height=800 |
|
) |
|
|
|
|
|
dummy_leaderboard_table = gr.Dataframe( |
|
value=text_leaderboard, |
|
elem_id="dummy-leaderboard-table", |
|
interactive=False, |
|
visible=False |
|
) |
|
|
|
lang_dropdown.change( |
|
filter, |
|
[dummy_leaderboard_table, lang_dropdown, clemscore_slider, |
|
input_pricing_slider, output_pricing_slider], |
|
[leaderboard_table], |
|
queue=True |
|
) |
|
|
|
clemscore_slider.change( |
|
filter, |
|
[dummy_leaderboard_table, lang_dropdown, clemscore_slider, |
|
input_pricing_slider, output_pricing_slider], |
|
[leaderboard_table], |
|
queue=True |
|
) |
|
|
|
input_pricing_slider.change( |
|
filter, |
|
[dummy_leaderboard_table, lang_dropdown, clemscore_slider, |
|
input_pricing_slider, output_pricing_slider], |
|
[leaderboard_table], |
|
queue=True |
|
) |
|
|
|
output_pricing_slider.change( |
|
filter, |
|
[dummy_leaderboard_table, lang_dropdown, clemscore_slider, |
|
input_pricing_slider, output_pricing_slider], |
|
[leaderboard_table], |
|
queue=True |
|
) |
|
|
|
llm_calc_app.load() |
|
llm_calc_app.queue() |
|
llm_calc_app.launch() |
|
|
|
|
|
|
|
""" |
|
model_name, input_price, output_price, |
|
multimodality_image,multimodality_multiple_image,multimodality_audio,multimodality_video, |
|
source,licence_name,licence_url,languages,release_date, |
|
parameters_estimated,parameters_actual, |
|
|
|
open_weight,context, |
|
|
|
additional_prices_context_caching, |
|
additional_prices_context_storage, |
|
additional_prices_image_input,additional_prices_image_output,additional_prices_video_input,additional_prices_video_output,additional_prices_audio_input,additional_prices_audio_output,clemscore_v1.6.5_multimodal,clemscore_v1.6.5_ascii,clemscore_v1.6,latency_v1.6,latency_v1.6.5_multimodal,latency_v1.6.5_ascii, |
|
|
|
average_clemscore,average_latency,parameters |
|
|
|
Final list |
|
|
|
model_name, input_price, output_price, |
|
multimodality_image,multimodality_multiple_image,multimodality_audio,multimodality_video, |
|
source,licence_name,licence_url,languages,release_date, open_weight,context, average_clemscore,average_latency,parameters |
|
|
|
|
|
Filter |
|
multimodality_image,multimodality_multiple_image,multimodality_audio,multimodality_video, |
|
licence_name+licence_url, languages, release_date, open_weight |
|
|
|
RR |
|
model_name, input_price, output_price, |
|
source, release_date |
|
|
|
""" |
|
|