Spaces:
Running
Running
Modify UI
#8
by
SmileXing
- opened
- app.py +8 -1
- app/backend/data_engine.py +17 -30
- app/backend/data_page.py +109 -46
- utils/cache_decorator.py +1 -1
app.py
CHANGED
|
@@ -26,6 +26,13 @@ nav = get_nav_from_toml(
|
|
| 26 |
# Add custom CSS
|
| 27 |
css = "\n".join(LI_CSS)
|
| 28 |
st.markdown(f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
<style>
|
| 30 |
{css}
|
| 31 |
</style>
|
|
@@ -34,6 +41,6 @@ st.markdown(f"""
|
|
| 34 |
|
| 35 |
pg = st.navigation(nav)
|
| 36 |
|
| 37 |
-
add_page_title(pg)
|
| 38 |
|
| 39 |
pg.run()
|
|
|
|
| 26 |
# Add custom CSS
|
| 27 |
css = "\n".join(LI_CSS)
|
| 28 |
st.markdown(f"""
|
| 29 |
+
<style>
|
| 30 |
+
|
| 31 |
+
div[data-testid="stToolbar"] {{visibility: hidden; height: 0px;}}
|
| 32 |
+
|
| 33 |
+
footer {{visibility: hidden;}}
|
| 34 |
+
</style>
|
| 35 |
+
|
| 36 |
<style>
|
| 37 |
{css}
|
| 38 |
</style>
|
|
|
|
| 41 |
|
| 42 |
pg = st.navigation(nav)
|
| 43 |
|
| 44 |
+
# add_page_title(pg)
|
| 45 |
|
| 46 |
pg.run()
|
app/backend/data_engine.py
CHANGED
|
@@ -83,7 +83,9 @@ class DataEngine:
|
|
| 83 |
df_results_list.append(df_result_row)
|
| 84 |
df_result = pd.concat(df_results_list)
|
| 85 |
|
| 86 |
-
df_result = df_result[["model_name", "dataset_name", "ndcg_at_10"]]
|
|
|
|
|
|
|
| 87 |
|
| 88 |
df_datasets_list = []
|
| 89 |
for item in self.datasets:
|
|
@@ -105,44 +107,29 @@ class DataEngine:
|
|
| 105 |
df = pd.merge(df_result, df_dataset, on=["dataset_name"], how="inner")
|
| 106 |
# df = pd.merge(df, df_model, on=["model_name"], how="inner")
|
| 107 |
|
| 108 |
-
dataset_num_map = {}
|
| 109 |
-
grouped_dataset_count = df.groupby(["group_name"]).agg({
|
| 110 |
-
|
| 111 |
-
}).reset_index()
|
| 112 |
-
|
| 113 |
-
for _, row in grouped_dataset_count.iterrows():
|
| 114 |
-
|
| 115 |
|
| 116 |
-
|
| 117 |
-
open_datasets = []
|
| 118 |
-
for result in results_list:
|
| 119 |
-
if not result.get("is_closed", False):
|
| 120 |
-
open_datasets.append(result["dataset_name"])
|
| 121 |
-
|
| 122 |
-
# Count open datasets
|
| 123 |
-
open_dataset_count = len(open_datasets)
|
| 124 |
-
|
| 125 |
-
grouped_model = df.groupby(["model_name", "group_name"]).agg({
|
| 126 |
"ndcg_at_10": "mean",
|
| 127 |
}).reset_index()
|
| 128 |
|
| 129 |
-
pivot = grouped_model.pivot(index="model_name",
|
|
|
|
| 130 |
|
| 131 |
# Rename columns
|
| 132 |
pivot.columns = list(
|
| 133 |
-
map(lambda x: f"{x[1].capitalize()} Average
|
| 134 |
-
pivot.columns))
|
| 135 |
-
|
| 136 |
-
pivot_dataset = df_result.pivot(index="model_name", columns="dataset_name", values="ndcg_at_10")
|
| 137 |
|
| 138 |
-
|
| 139 |
-
open_df = df_result[df_result["dataset_name"].isin(open_datasets)]
|
| 140 |
-
open_avg = open_df.groupby("model_name")["ndcg_at_10"].mean().reset_index()
|
| 141 |
-
open_avg = open_avg.rename(columns={"ndcg_at_10": f"Open average ({open_dataset_count} datasets)"})
|
| 142 |
|
| 143 |
-
df = pd.merge(df_model, pivot, on="model_name")
|
| 144 |
-
df = pd.merge(df,
|
| 145 |
-
df = pd.merge(df, pivot_dataset, on="model_name")
|
| 146 |
|
| 147 |
if df.empty:
|
| 148 |
return pd.DataFrame(columns=COLUMNS + ["reference"])
|
|
|
|
| 83 |
df_results_list.append(df_result_row)
|
| 84 |
df_result = pd.concat(df_results_list)
|
| 85 |
|
| 86 |
+
df_result = df_result[["model_name", "dataset_name", "ndcg_at_10", "embd_dim", "embd_dtype"]]
|
| 87 |
+
|
| 88 |
+
df_result["ndcg_at_10"] = (df_result["ndcg_at_10"] * 100).round(2)
|
| 89 |
|
| 90 |
df_datasets_list = []
|
| 91 |
for item in self.datasets:
|
|
|
|
| 107 |
df = pd.merge(df_result, df_dataset, on=["dataset_name"], how="inner")
|
| 108 |
# df = pd.merge(df, df_model, on=["model_name"], how="inner")
|
| 109 |
|
| 110 |
+
# dataset_num_map = {}
|
| 111 |
+
# grouped_dataset_count = df.groupby(["group_name"]).agg({
|
| 112 |
+
# "dataset_name": "nunique"
|
| 113 |
+
# }).reset_index()
|
| 114 |
+
#
|
| 115 |
+
# for _, row in grouped_dataset_count.iterrows():
|
| 116 |
+
# dataset_num_map[row["group_name"]] = row["dataset_name"]
|
| 117 |
|
| 118 |
+
grouped_model = df.groupby(["model_name", "group_name", "embd_dim", "embd_dtype"]).agg({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
"ndcg_at_10": "mean",
|
| 120 |
}).reset_index()
|
| 121 |
|
| 122 |
+
pivot = grouped_model.pivot(index=["model_name", "embd_dim", "embd_dtype"], columns="group_name",
|
| 123 |
+
values=["ndcg_at_10"]).round(2)
|
| 124 |
|
| 125 |
# Rename columns
|
| 126 |
pivot.columns = list(
|
| 127 |
+
map(lambda x: f"{x[1].capitalize()} Average" if x[1] != 'text' else f"Average", pivot.columns))
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
+
pivot_dataset = df_result.pivot(index=["model_name", "embd_dim", "embd_dtype"], columns="dataset_name", values="ndcg_at_10")
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
+
df = pd.merge(df_model, pivot, on=["model_name", "embd_dim", "embd_dtype"])
|
| 132 |
+
df = pd.merge(df, pivot_dataset, on=["model_name", "embd_dim", "embd_dtype"])
|
|
|
|
| 133 |
|
| 134 |
if df.empty:
|
| 135 |
return pd.DataFrame(columns=COLUMNS + ["reference"])
|
app/backend/data_page.py
CHANGED
|
@@ -3,11 +3,14 @@
|
|
| 3 |
# @Author : q275343119
|
| 4 |
# @File : data_page.py
|
| 5 |
# @Description:
|
|
|
|
|
|
|
| 6 |
from st_aggrid import AgGrid, JsCode, ColumnsAutoSizeMode
|
| 7 |
|
| 8 |
import streamlit as st
|
| 9 |
|
| 10 |
from app.backend.app_init_func import LEADERBOARD_MAP
|
|
|
|
| 11 |
|
| 12 |
COLUMNS = ['model_name',
|
| 13 |
'embd_dtype', 'embd_dim', 'num_params', 'max_tokens', 'similarity',
|
|
@@ -37,8 +40,15 @@ def get_closed_dataset():
|
|
| 37 |
return closed_list
|
| 38 |
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
def render_page(group_name):
|
| 41 |
# Add theme color and grid styles
|
|
|
|
| 42 |
st.markdown("""
|
| 43 |
<style>
|
| 44 |
:root {
|
|
@@ -94,18 +104,36 @@ def render_page(group_name):
|
|
| 94 |
a:hover {
|
| 95 |
color: rgba(129, 150, 64, 0.8) !important;
|
| 96 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
</style>
|
| 98 |
""", unsafe_allow_html=True)
|
| 99 |
|
| 100 |
# logo
|
| 101 |
# st.markdown('<img src="https://www.voyageai.com/logo.svg" class="center-image" width="200">', unsafe_allow_html=True)
|
| 102 |
-
|
|
|
|
|
|
|
| 103 |
# title
|
| 104 |
-
st.markdown(
|
| 105 |
|
| 106 |
data_engine = st.session_state["data_engine"]
|
| 107 |
|
| 108 |
-
df = data_engine.jsons_to_df()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
# get columns
|
| 110 |
column_list = []
|
| 111 |
avg_column = None
|
|
@@ -126,10 +154,8 @@ def render_page(group_name):
|
|
| 126 |
|
| 127 |
if column.startswith(group_name.capitalize() + " "):
|
| 128 |
avg_column = column
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
column_list.append(new_column)
|
| 132 |
-
avg_column = new_column
|
| 133 |
|
| 134 |
dataset_list = []
|
| 135 |
|
|
@@ -140,16 +166,22 @@ def render_page(group_name):
|
|
| 140 |
column_list.extend(dataset_list)
|
| 141 |
closed_list = get_closed_dataset()
|
| 142 |
close_avg_list = list(set(dataset_list) & set(closed_list))
|
| 143 |
-
df["Closed average"] = df[close_avg_list].mean(axis=1)
|
| 144 |
column_list.append("Closed average")
|
| 145 |
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
column_list.append(open_avg_col)
|
| 150 |
|
| 151 |
df = df[COLUMNS + column_list].sort_values(by=avg_column, ascending=False)
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
# setting column config
|
| 154 |
grid_options = {
|
| 155 |
'columnDefs': [
|
|
@@ -160,12 +192,16 @@ def render_page(group_name):
|
|
| 160 |
'sortable': False,
|
| 161 |
'headerStyle': HEADER_STYLE,
|
| 162 |
'cellStyle': CELL_STYLE,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
'cellRenderer': JsCode("""class CustomHTML {
|
| 164 |
init(params) {
|
| 165 |
const link = params.data.reference;
|
| 166 |
this.eGui = document.createElement('div');
|
| 167 |
this.eGui.innerHTML = link ?
|
| 168 |
-
`<a href="${link}" target="_blank">${params.value}</a>` :
|
| 169 |
params.value;
|
| 170 |
}
|
| 171 |
|
|
@@ -173,85 +209,111 @@ def render_page(group_name):
|
|
| 173 |
return this.eGui;
|
| 174 |
}
|
| 175 |
}"""),
|
|
|
|
|
|
|
| 176 |
},
|
| 177 |
-
{'headerName':
|
| 178 |
'field': avg_column,
|
| 179 |
'headerStyle': HEADER_STYLE,
|
| 180 |
'cellStyle': CELL_STYLE,
|
| 181 |
-
'suppressSizeToFit': True
|
|
|
|
| 182 |
|
| 183 |
# Add Open average column definition
|
| 184 |
-
{'headerName':
|
| 185 |
-
'field':
|
| 186 |
'headerStyle': HEADER_STYLE,
|
| 187 |
'cellStyle': CELL_STYLE,
|
| 188 |
-
'suppressSizeToFit': True
|
|
|
|
| 189 |
|
| 190 |
-
{'headerName': 'Closed
|
| 191 |
'field': 'Closed average',
|
| 192 |
'headerStyle': HEADER_STYLE,
|
| 193 |
'cellStyle': CELL_STYLE,
|
| 194 |
-
'suppressSizeToFit': True
|
|
|
|
| 195 |
|
| 196 |
{
|
| 197 |
-
'headerName': '
|
| 198 |
'field': 'embd_dtype',
|
| 199 |
'headerStyle': HEADER_STYLE,
|
| 200 |
'cellStyle': CELL_STYLE,
|
| 201 |
-
'suppressSizeToFit': True,
|
| 202 |
},
|
| 203 |
{
|
| 204 |
'headerName': 'Embd Dim',
|
| 205 |
'field': 'embd_dim',
|
| 206 |
'headerStyle': HEADER_STYLE,
|
| 207 |
'cellStyle': CELL_STYLE,
|
| 208 |
-
'suppressSizeToFit': True,
|
| 209 |
},
|
| 210 |
{
|
| 211 |
-
'headerName': '
|
| 212 |
'field': 'num_params',
|
| 213 |
'cellDataType': 'number',
|
| 214 |
'headerStyle': HEADER_STYLE,
|
| 215 |
'cellStyle': CELL_STYLE,
|
| 216 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
},
|
| 218 |
{
|
| 219 |
'headerName': 'Context Length',
|
| 220 |
'field': 'max_tokens',
|
| 221 |
'headerStyle': HEADER_STYLE,
|
| 222 |
'cellStyle': CELL_STYLE,
|
| 223 |
-
'suppressSizeToFit': True,
|
| 224 |
-
},
|
| 225 |
-
{
|
| 226 |
-
'headerName': 'Query Instruction',
|
| 227 |
-
'field': 'query_instruct',
|
| 228 |
-
'headerStyle': HEADER_STYLE,
|
| 229 |
-
'cellStyle': CELL_STYLE,
|
| 230 |
-
'suppressSizeToFit': True,
|
| 231 |
-
|
| 232 |
},
|
| 233 |
-
{
|
| 234 |
-
'headerName': 'Corpus Instruction',
|
| 235 |
-
'field': 'corpus_instruct',
|
| 236 |
-
'headerStyle': HEADER_STYLE,
|
| 237 |
-
'cellStyle': CELL_STYLE,
|
| 238 |
-
'suppressSizeToFit': True,
|
| 239 |
|
| 240 |
-
|
| 241 |
-
*[{'headerName': column,
|
| 242 |
'field': column,
|
| 243 |
'headerStyle': HEADER_STYLE,
|
| 244 |
'cellStyle': CELL_STYLE,
|
| 245 |
-
'suppressSizeToFit': True
|
|
|
|
|
|
|
| 246 |
],
|
| 247 |
'defaultColDef': {
|
| 248 |
'filter': True,
|
| 249 |
'sortable': True,
|
| 250 |
-
'resizable': True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
},
|
| 252 |
-
|
| 253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
}
|
|
|
|
| 255 |
}
|
| 256 |
|
| 257 |
AgGrid(
|
|
@@ -261,4 +323,5 @@ def render_page(group_name):
|
|
| 261 |
allow_unsafe_jscode=True,
|
| 262 |
columns_auto_size_mode=ColumnsAutoSizeMode.FIT_CONTENTS,
|
| 263 |
theme="streamlit",
|
|
|
|
| 264 |
)
|
|
|
|
| 3 |
# @Author : q275343119
|
| 4 |
# @File : data_page.py
|
| 5 |
# @Description:
|
| 6 |
+
import io
|
| 7 |
+
|
| 8 |
from st_aggrid import AgGrid, JsCode, ColumnsAutoSizeMode
|
| 9 |
|
| 10 |
import streamlit as st
|
| 11 |
|
| 12 |
from app.backend.app_init_func import LEADERBOARD_MAP
|
| 13 |
+
from app.backend.constant import LEADERBOARD_ICON_MAP
|
| 14 |
|
| 15 |
COLUMNS = ['model_name',
|
| 16 |
'embd_dtype', 'embd_dim', 'num_params', 'max_tokens', 'similarity',
|
|
|
|
| 40 |
return closed_list
|
| 41 |
|
| 42 |
|
| 43 |
+
def convert_df_to_csv(df):
|
| 44 |
+
output = io.StringIO()
|
| 45 |
+
df.to_csv(output, index=False)
|
| 46 |
+
return output.getvalue()
|
| 47 |
+
|
| 48 |
+
|
| 49 |
def render_page(group_name):
|
| 50 |
# Add theme color and grid styles
|
| 51 |
+
st.title("Retrieval Embedding Benchmark (RTEB)")
|
| 52 |
st.markdown("""
|
| 53 |
<style>
|
| 54 |
:root {
|
|
|
|
| 104 |
a:hover {
|
| 105 |
color: rgba(129, 150, 64, 0.8) !important;
|
| 106 |
}
|
| 107 |
+
/* Download Button */
|
| 108 |
+
button[data-testid="stBaseButton-secondary"] {
|
| 109 |
+
float: right;
|
| 110 |
+
|
| 111 |
+
}
|
| 112 |
</style>
|
| 113 |
""", unsafe_allow_html=True)
|
| 114 |
|
| 115 |
# logo
|
| 116 |
# st.markdown('<img src="https://www.voyageai.com/logo.svg" class="center-image" width="200">', unsafe_allow_html=True)
|
| 117 |
+
title = f'<h2 class="center-text">{LEADERBOARD_ICON_MAP.get(group_name.capitalize(), "")} {group_name.capitalize()}</h2>'
|
| 118 |
+
if is_section(group_name):
|
| 119 |
+
title = f'<h2 class="center-text">{LEADERBOARD_ICON_MAP.get(group_name.capitalize() + " Leaderboard", "")} {group_name.capitalize() + " Leaderboard"}</h2>'
|
| 120 |
# title
|
| 121 |
+
st.markdown(title, unsafe_allow_html=True)
|
| 122 |
|
| 123 |
data_engine = st.session_state["data_engine"]
|
| 124 |
|
| 125 |
+
df = data_engine.jsons_to_df().copy()
|
| 126 |
+
|
| 127 |
+
csv = convert_df_to_csv(df)
|
| 128 |
+
file_name = f"{group_name.capitalize()} Leaderboard" if is_section(group_name) else group_name.capitalize()
|
| 129 |
+
st.download_button(
|
| 130 |
+
label="Download CSV",
|
| 131 |
+
data=csv,
|
| 132 |
+
file_name=f"{file_name}.csv",
|
| 133 |
+
mime="text/csv",
|
| 134 |
+
icon=":material/download:",
|
| 135 |
+
)
|
| 136 |
+
|
| 137 |
# get columns
|
| 138 |
column_list = []
|
| 139 |
avg_column = None
|
|
|
|
| 154 |
|
| 155 |
if column.startswith(group_name.capitalize() + " "):
|
| 156 |
avg_column = column
|
| 157 |
+
|
| 158 |
+
column_list.append(avg_column)
|
|
|
|
|
|
|
| 159 |
|
| 160 |
dataset_list = []
|
| 161 |
|
|
|
|
| 166 |
column_list.extend(dataset_list)
|
| 167 |
closed_list = get_closed_dataset()
|
| 168 |
close_avg_list = list(set(dataset_list) & set(closed_list))
|
| 169 |
+
df["Closed average"] = df[close_avg_list].mean(axis=1).round(2)
|
| 170 |
column_list.append("Closed average")
|
| 171 |
|
| 172 |
+
open_avg_list = list(set(dataset_list) - set(closed_list))
|
| 173 |
+
df["Open average"] = df[open_avg_list].mean(axis=1).round(2)
|
| 174 |
+
column_list.append("Open average")
|
|
|
|
| 175 |
|
| 176 |
df = df[COLUMNS + column_list].sort_values(by=avg_column, ascending=False)
|
| 177 |
|
| 178 |
+
# rename avg column name
|
| 179 |
+
if not is_section(group_name):
|
| 180 |
+
new_column = avg_column.replace(group_name.capitalize(), "").strip()
|
| 181 |
+
df.rename(columns={avg_column: new_column}, inplace=True)
|
| 182 |
+
column_list.remove(avg_column)
|
| 183 |
+
avg_column = new_column
|
| 184 |
+
|
| 185 |
# setting column config
|
| 186 |
grid_options = {
|
| 187 |
'columnDefs': [
|
|
|
|
| 192 |
'sortable': False,
|
| 193 |
'headerStyle': HEADER_STYLE,
|
| 194 |
'cellStyle': CELL_STYLE,
|
| 195 |
+
"tooltipValueGetter": JsCode(
|
| 196 |
+
"""function(p) {return p.value}"""
|
| 197 |
+
),
|
| 198 |
+
"width": 250,
|
| 199 |
'cellRenderer': JsCode("""class CustomHTML {
|
| 200 |
init(params) {
|
| 201 |
const link = params.data.reference;
|
| 202 |
this.eGui = document.createElement('div');
|
| 203 |
this.eGui.innerHTML = link ?
|
| 204 |
+
`<a href="${link}" class="a-cell" target="_blank">${params.value} </a>` :
|
| 205 |
params.value;
|
| 206 |
}
|
| 207 |
|
|
|
|
| 209 |
return this.eGui;
|
| 210 |
}
|
| 211 |
}"""),
|
| 212 |
+
'suppressSizeToFit': True
|
| 213 |
+
|
| 214 |
},
|
| 215 |
+
{'headerName': "Overall Score",
|
| 216 |
'field': avg_column,
|
| 217 |
'headerStyle': HEADER_STYLE,
|
| 218 |
'cellStyle': CELL_STYLE,
|
| 219 |
+
# 'suppressSizeToFit': True
|
| 220 |
+
},
|
| 221 |
|
| 222 |
# Add Open average column definition
|
| 223 |
+
{'headerName': 'Open Average',
|
| 224 |
+
'field': 'Open average',
|
| 225 |
'headerStyle': HEADER_STYLE,
|
| 226 |
'cellStyle': CELL_STYLE,
|
| 227 |
+
# 'suppressSizeToFit': True
|
| 228 |
+
},
|
| 229 |
|
| 230 |
+
{'headerName': 'Closed Average',
|
| 231 |
'field': 'Closed average',
|
| 232 |
'headerStyle': HEADER_STYLE,
|
| 233 |
'cellStyle': CELL_STYLE,
|
| 234 |
+
# 'suppressSizeToFit': True
|
| 235 |
+
},
|
| 236 |
|
| 237 |
{
|
| 238 |
+
'headerName': 'Embd Dtype',
|
| 239 |
'field': 'embd_dtype',
|
| 240 |
'headerStyle': HEADER_STYLE,
|
| 241 |
'cellStyle': CELL_STYLE,
|
| 242 |
+
# 'suppressSizeToFit': True,
|
| 243 |
},
|
| 244 |
{
|
| 245 |
'headerName': 'Embd Dim',
|
| 246 |
'field': 'embd_dim',
|
| 247 |
'headerStyle': HEADER_STYLE,
|
| 248 |
'cellStyle': CELL_STYLE,
|
| 249 |
+
# 'suppressSizeToFit': True,
|
| 250 |
},
|
| 251 |
{
|
| 252 |
+
'headerName': 'Number of Parameters',
|
| 253 |
'field': 'num_params',
|
| 254 |
'cellDataType': 'number',
|
| 255 |
'headerStyle': HEADER_STYLE,
|
| 256 |
'cellStyle': CELL_STYLE,
|
| 257 |
+
'valueFormatter': JsCode(
|
| 258 |
+
"""function(params) {
|
| 259 |
+
const num = params.value;
|
| 260 |
+
if (num >= 1e9) return (num / 1e9).toFixed(2) + "B";
|
| 261 |
+
if (num >= 1e6) return (num / 1e6).toFixed(2) + "M";
|
| 262 |
+
if (num >= 1e3) return (num / 1e3).toFixed(2) + "K";
|
| 263 |
+
return num;
|
| 264 |
+
}"""
|
| 265 |
+
),
|
| 266 |
+
# 'suppressSizeToFit': True,
|
| 267 |
},
|
| 268 |
{
|
| 269 |
'headerName': 'Context Length',
|
| 270 |
'field': 'max_tokens',
|
| 271 |
'headerStyle': HEADER_STYLE,
|
| 272 |
'cellStyle': CELL_STYLE,
|
| 273 |
+
# 'suppressSizeToFit': True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
|
| 276 |
+
*[{'headerName': column if "Average" not in column else column.replace("Average", "").strip().capitalize(),
|
|
|
|
| 277 |
'field': column,
|
| 278 |
'headerStyle': HEADER_STYLE,
|
| 279 |
'cellStyle': CELL_STYLE,
|
| 280 |
+
# 'suppressSizeToFit': True
|
| 281 |
+
} for column in column_list if
|
| 282 |
+
column not in (avg_column, "Closed average", "Open average")]
|
| 283 |
],
|
| 284 |
'defaultColDef': {
|
| 285 |
'filter': True,
|
| 286 |
'sortable': True,
|
| 287 |
+
'resizable': True,
|
| 288 |
+
'headerClass': "multi-line-header",
|
| 289 |
+
'autoHeaderHeight': True
|
| 290 |
+
},
|
| 291 |
+
"autoSizeStrategy": {
|
| 292 |
+
"type": 'fitGridWidth',
|
| 293 |
+
"defaultMinWidth": 105,
|
| 294 |
},
|
| 295 |
+
"tooltipShowDelay": 500,
|
| 296 |
+
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
custom_css = {
|
| 300 |
+
|
| 301 |
+
".a-cell": {
|
| 302 |
+
"display": "inline-block",
|
| 303 |
+
"white-space": "nowrap",
|
| 304 |
+
"overflow": "hidden",
|
| 305 |
+
"text-overflow": "ellipsis",
|
| 306 |
+
"width": "100%",
|
| 307 |
+
"min-width": "0"
|
| 308 |
+
},
|
| 309 |
+
|
| 310 |
+
".multi-line-header": {
|
| 311 |
+
"text-overflow": "clip",
|
| 312 |
+
"overflow": "visible",
|
| 313 |
+
"white-space": "normal",
|
| 314 |
+
"height": "auto",
|
| 315 |
}
|
| 316 |
+
|
| 317 |
}
|
| 318 |
|
| 319 |
AgGrid(
|
|
|
|
| 323 |
allow_unsafe_jscode=True,
|
| 324 |
columns_auto_size_mode=ColumnsAutoSizeMode.FIT_CONTENTS,
|
| 325 |
theme="streamlit",
|
| 326 |
+
custom_css=custom_css
|
| 327 |
)
|
utils/cache_decorator.py
CHANGED
|
@@ -31,7 +31,7 @@ def cache_dict_with_custom_key(cache_key: str):
|
|
| 31 |
def decorator(func):
|
| 32 |
@wraps(func)
|
| 33 |
def wrapper(*args, **kwargs):
|
| 34 |
-
if cache_key in CACHE and CACHE[cache_key].get("expiry")
|
| 35 |
return CACHE[cache_key]["data"]
|
| 36 |
|
| 37 |
result: dict = func(*args, **kwargs)
|
|
|
|
| 31 |
def decorator(func):
|
| 32 |
@wraps(func)
|
| 33 |
def wrapper(*args, **kwargs):
|
| 34 |
+
if cache_key in CACHE and time.time() - CACHE[cache_key].get("expiry") < TTL:
|
| 35 |
return CACHE[cache_key]["data"]
|
| 36 |
|
| 37 |
result: dict = func(*args, **kwargs)
|