Spaces:
Running
Running
Commit
·
b981c80
1
Parent(s):
564504c
added more info to safety scores
Browse files
app/message_processing.py
CHANGED
@@ -272,8 +272,10 @@ def convert_to_openai_format(gemini_response: Any, model: str) -> Dict[str, Any]
|
|
272 |
for rating in candidate.safety_ratings:
|
273 |
category = rating.category.name.replace('HARM_CATEGORY_', '').replace('_', ' ').title()
|
274 |
probability = rating.probability.name
|
275 |
-
ratings_list.append(
|
276 |
-
|
|
|
|
|
277 |
if final_reasoning_content_str:
|
278 |
final_reasoning_content_str += safety_ratings_str
|
279 |
else:
|
@@ -325,8 +327,10 @@ def convert_chunk_to_openai(chunk: Any, model: str, response_id: str, candidate_
|
|
325 |
for rating in candidate.safety_ratings:
|
326 |
category = rating.category.name.replace('HARM_CATEGORY_', '').replace('_', ' ').title()
|
327 |
probability = rating.probability.name
|
328 |
-
ratings_list.append(
|
329 |
-
|
|
|
|
|
330 |
if reasoning_text:
|
331 |
reasoning_text += safety_ratings_str
|
332 |
else:
|
|
|
272 |
for rating in candidate.safety_ratings:
|
273 |
category = rating.category.name.replace('HARM_CATEGORY_', '').replace('_', ' ').title()
|
274 |
probability = rating.probability.name
|
275 |
+
ratings_list.append(
|
276 |
+
f"{category}: {probability} (Score: {rating.probability_score}, Severity: {rating.severity_score})"
|
277 |
+
)
|
278 |
+
safety_ratings_str = "\n\n--- Safety Ratings ---\n" + "\n".join(ratings_list) + "\n"
|
279 |
if final_reasoning_content_str:
|
280 |
final_reasoning_content_str += safety_ratings_str
|
281 |
else:
|
|
|
327 |
for rating in candidate.safety_ratings:
|
328 |
category = rating.category.name.replace('HARM_CATEGORY_', '').replace('_', ' ').title()
|
329 |
probability = rating.probability.name
|
330 |
+
ratings_list.append(
|
331 |
+
f"{category}: {probability} (Score: {rating.probability_score}, Severity: {rating.severity_score})"
|
332 |
+
)
|
333 |
+
safety_ratings_str = "\n\n--- Safety Ratings ---\n" + "\n".join(ratings_list) + "\n"
|
334 |
if reasoning_text:
|
335 |
reasoning_text += safety_ratings_str
|
336 |
else:
|