Spaces:
Restarting
Restarting
File size: 1,965 Bytes
bccaf50 9ab539a 8558676 ca72b36 8558676 9ab539a ca72b36 9ab539a ca72b36 9ab539a ca72b36 9ab539a bccaf50 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
"""Helper functions to style our gradio elements"""
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>'
def make_clickable_model(model_name):
link = f"https://huggingface.co/{model_name}"
return model_hyperlink(link, model_name)
def make_clickable_report(report_url):
"""Create a clickable HTML link for assessment reports"""
return f'<a href="{report_url}" target="_blank">View Report</a>'
def styled_error(error):
"""Format an error message with a red header"""
return f'<span style="color: red">❌ Error:</span> {error}'
def styled_warning(warn):
"""Format a warning message with an orange header"""
return f'<span style="color: orange">⚠️ Warning:</span> {warn}'
def styled_message(message):
"""Format a message with a green header"""
return f'<span style="color: green">✅ Success:</span> {message}'
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)
def make_clickable_library(library_name: str) -> str:
"""Link to the GitHub repository"""
library_path = library_name.replace(" ", "-").lower()
# If this is a GitHub repository, link directly
github_url = f"https://github.com/{library_path}"
return f'<a href="{github_url}" target="_blank">{library_name}</a>'
# Risk severity coloring for risk scores
def colorize_risk_score(score):
"""
Apply color coding to risk scores:
0-3.9: Green (Low risk)
4-6.9: Orange (Medium risk)
7-10: Red (High risk)
"""
if score < 4:
return f'<span style="color: green">{score:.1f}</span>'
elif score < 7:
return f'<span style="color: orange">{score:.1f}</span>'
else:
return f'<span style="color: red">{score:.1f}</span>'
|