openfree's picture
Update src/display/formatting.py
ec05e33 verified
# File: src/display/formatting.py
def model_hyperlink(link, model_name):
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline; text-decoration-style: dotted;">{model_name}</a>'
# ์ „์—ญ์—์„œ MODEL_MAPPING์„ ๋จผ์ € ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.
MODEL_MAPPING = {
"DeepSeek-R1": "deepseek-ai/DeepSeek-R1",
"deepseek-r1": "deepseek-ai/DeepSeek-R1", # ์†Œ๋ฌธ์ž ๋ฒ„์ „๋„ ์ถ”๊ฐ€
"OpenAI ChatGPT-4o": ("External Awesome Model", "https://chatgpt.com")
}
def make_clickable_model(model_name):
"""
๋ชจ๋ธ ์ด๋ฆ„์„ ๋ฐ›์•„์„œ ํด๋ฆญ ๊ฐ€๋Šฅํ•œ ํ•˜์ดํผ๋งํฌ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
MODEL_MAPPING์— ์žˆ๋Š” ๋ชจ๋ธ์€ ๋งคํ•‘๋œ ์ด๋ฆ„๊ณผ URL์„ ์‚ฌ์šฉํ•˜๊ณ ,
์—†๋Š” ๋ชจ๋ธ์€ ๊ธฐ๋ณธ Hugging Face URL์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
"""
if model_name is None:
return "N/A"
# ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ (๋‹ค๋ฅธ ํƒ€์ž…์ด ์ „๋‹ฌ๋  ๊ฒฝ์šฐ)
model_name_str = str(model_name).strip()
# MODEL_MAPPING์—์„œ ์ฐพ๊ธฐ (๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„ ์—†์ด)
for key, mapping_value in MODEL_MAPPING.items():
if model_name_str.lower() == key.lower():
if isinstance(mapping_value, tuple):
# ํŠœํ”Œ์ธ ๊ฒฝ์šฐ, (ํ‘œ์‹œ๋  ์ด๋ฆ„, ์™ธ๋ถ€ URL)๋กœ ์‚ฌ์šฉ
new_name, new_url = mapping_value
else:
# ๋ฌธ์ž์—ด์ธ ๊ฒฝ์šฐ, ๋‚ด๋ถ€ Hugging Face URL๋กœ ๊ตฌ์„ฑ
new_name = mapping_value
new_url = f"https://huggingface.co/{new_name}"
return model_hyperlink(new_url, new_name)
# ๋งคํ•‘์ด ์—†๋Š” ๊ฒฝ์šฐ ๊ธฐ๋ณธ Hugging Face URL ์‚ฌ์šฉ
link = f"https://huggingface.co/{model_name_str}"
return model_hyperlink(link, model_name_str)
def styled_error(error):
return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
def styled_warning(warn):
return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
def styled_message(message):
return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
def has_no_nan_values(df, columns):
return df[columns].notna().all(axis=1)
def has_nan_values(df, columns):
return df[columns].isna().any(axis=1)