Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -844,18 +844,13 @@ def _censor_me(self, p, safer=0.0005):
|
|
844 |
resp_dict = resp_orig.model_dump()
|
845 |
#
|
846 |
v1 = resp_dict["results"][0]["category_scores"]
|
|
|
847 |
print(f'resp_dic: {resp_dict}')
|
848 |
print(f'v1: {v1}')
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
try:
|
854 |
-
max_key = max(v1, keym)
|
855 |
-
except Exception as e:
|
856 |
-
max_key = 0
|
857 |
-
|
858 |
-
sum_value = sum(value for value in v1.values() if value is not None)
|
859 |
#
|
860 |
v1["is_safer_flagged"] = False
|
861 |
if (max_value >= safer):
|
|
|
844 |
resp_dict = resp_orig.model_dump()
|
845 |
#
|
846 |
v1 = resp_dict["results"][0]["category_scores"]
|
847 |
+
v1 = {key: value if value is not None else 0 for key, value in v1.items()}
|
848 |
print(f'resp_dic: {resp_dict}')
|
849 |
print(f'v1: {v1}')
|
850 |
+
|
851 |
+
max_key = max(v1, key=v1.get)
|
852 |
+
max_value = v1[max_key]
|
853 |
+
sum_value = sum(v1.values())
|
|
|
|
|
|
|
|
|
|
|
|
|
854 |
#
|
855 |
v1["is_safer_flagged"] = False
|
856 |
if (max_value >= safer):
|