"""Helper functions to style our gradio elements""" def model_hyperlink(link, model_name): return f'{model_name}' 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'View Report' def styled_error(error): """Format an error message with a red header""" return f'❌ Error: {error}' def styled_warning(warn): """Format a warning message with an orange header""" return f'⚠️ Warning: {warn}' def styled_message(message): """Format a message with a green header""" return f'✅ Success: {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'{library_name}' # 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'{score:.1f}' elif score < 7: return f'{score:.1f}' else: return f'{score:.1f}'