Spaces:
Running
Running
Commit
·
ca5d0fc
1
Parent(s):
a84d7ad
added styling and tags
Browse files
app/message_processing.py
CHANGED
@@ -258,16 +258,18 @@ def _create_safety_ratings_html(safety_ratings: List[Any]) -> str:
|
|
258 |
summary_category = highest_rating.category.name.replace('HARM_CATEGORY_', '').replace('_', ' ').title()
|
259 |
summary_probability = highest_rating.probability.name
|
260 |
# Using .7f for score and .8f for severity as per example's precision
|
261 |
-
|
|
|
|
|
262 |
|
263 |
# Format the list of all ratings for the <pre> block
|
264 |
ratings_list = []
|
265 |
for rating in safety_ratings:
|
266 |
category = rating.category.name.replace('HARM_CATEGORY_', '').replace('_', ' ').title()
|
267 |
probability = rating.probability.name
|
268 |
-
|
269 |
-
|
270 |
-
)
|
271 |
all_ratings_str = '\n'.join(ratings_list)
|
272 |
|
273 |
# CSS Style as specified
|
|
|
258 |
summary_category = highest_rating.category.name.replace('HARM_CATEGORY_', '').replace('_', ' ').title()
|
259 |
summary_probability = highest_rating.probability.name
|
260 |
# Using .7f for score and .8f for severity as per example's precision
|
261 |
+
summary_score_str = f"{highest_rating.probability_score:.7f}" if highest_rating.probability_score is not None else "None"
|
262 |
+
summary_severity_str = f"{highest_rating.severity_score:.8f}" if highest_rating.severity_score is not None else "None"
|
263 |
+
summary_line = f"{summary_category}: {summary_probability} (Score: {summary_score_str}, Severity: {summary_severity_str})"
|
264 |
|
265 |
# Format the list of all ratings for the <pre> block
|
266 |
ratings_list = []
|
267 |
for rating in safety_ratings:
|
268 |
category = rating.category.name.replace('HARM_CATEGORY_', '').replace('_', ' ').title()
|
269 |
probability = rating.probability.name
|
270 |
+
score_str = f"{rating.probability_score:.7f}" if rating.probability_score is not None else "None"
|
271 |
+
severity_str = f"{rating.severity_score:.8f}" if rating.severity_score is not None else "None"
|
272 |
+
ratings_list.append(f"{category}: {probability} (Score: {score_str}, Severity: {severity_str})")
|
273 |
all_ratings_str = '\n'.join(ratings_list)
|
274 |
|
275 |
# CSS Style as specified
|