kkAsmaa commited on
Commit
72e2b13
ยท
verified ยท
1 Parent(s): a12ba0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -80,6 +80,8 @@ def predict_safety_api(text):
80
  triggered_windows = []
81
  windows_table_data = []
82
 
 
 
83
  for idx, win_ids in enumerate(windows):
84
  window_text = tokenizer.decode(win_ids, skip_special_tokens=True)
85
  inputs = tokenizer(
@@ -115,6 +117,8 @@ def predict_safety_api(text):
115
  f"โŒ {prediction}" if prediction == "UNSAFE" else f"โœ… {prediction}"
116
  ])
117
 
 
 
118
  if unsafe_prob > 0.50:
119
  is_blocked = True
120
  highest_unsafe_prob = max(highest_unsafe_prob, unsafe_prob)
@@ -144,7 +148,13 @@ def predict_safety_api(text):
144
  print(tabulate(windows_table_data, headers=["ID", "Window Text Preview", "Safe Prob", "Unsafe Prob", "Verdict"], tablefmt="grid"))
145
  print("========================================================================\n")
146
 
147
-
 
 
 
 
 
 
148
  return {
149
  "original_text": text,
150
  "cleaned_text": cleaned_text,
 
80
  triggered_windows = []
81
  windows_table_data = []
82
 
83
+ full_windows_text_list = []
84
+
85
  for idx, win_ids in enumerate(windows):
86
  window_text = tokenizer.decode(win_ids, skip_special_tokens=True)
87
  inputs = tokenizer(
 
117
  f"โŒ {prediction}" if prediction == "UNSAFE" else f"โœ… {prediction}"
118
  ])
119
 
120
+ full_windows_text_list.append(f"๐Ÿ“– [Window {idx + 1} Full Text]:\n \"{window_text}\"\n")
121
+
122
  if unsafe_prob > 0.50:
123
  is_blocked = True
124
  highest_unsafe_prob = max(highest_unsafe_prob, unsafe_prob)
 
148
  print(tabulate(windows_table_data, headers=["ID", "Window Text Preview", "Safe Prob", "Unsafe Prob", "Verdict"], tablefmt="grid"))
149
  print("========================================================================\n")
150
 
151
+
152
+ print("\n๐Ÿ” === Windows Text Inspection (ุงู„ู†ุตูˆุต ุงู„ูƒุงู…ู„ุฉ ู„ุชู‚ุณูŠู… ุงู„ู†ูˆุงูุฐ) ===")
153
+ for window_log in full_windows_text_list:
154
+ print(window_log)
155
+ print("========================================================================\n")
156
+
157
+
158
  return {
159
  "original_text": text,
160
  "cleaned_text": cleaned_text,