aboutsummaryrefslogtreecommitdiff
path: root/internal/weblog_utilities.py
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-05-14 05:15:28 +0530
committerBobby <[email protected]>2026-05-14 05:15:28 +0530
commit033027268ca1708d0bd249549e746914f1588a5c (patch)
treefdf6766320c0435018f213097b37d88b5d0c5d21 /internal/weblog_utilities.py
parente229c334e9491bd7dd6399a1716d641dcb6ee2ad (diff)
downloadthatcomputerscientist-v2.tar.xz
thatcomputerscientist-v2.zip
Fix Pylance type errors in spam check helperv2
Diffstat (limited to 'internal/weblog_utilities.py')
-rw-r--r--internal/weblog_utilities.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/internal/weblog_utilities.py b/internal/weblog_utilities.py
index c307929c..ae354116 100644
--- a/internal/weblog_utilities.py
+++ b/internal/weblog_utilities.py
@@ -180,11 +180,16 @@ def check_comment_spam(post, comment):
"""
safety_settings = [
- {"category": "HARM_CATEGORY_DANGEROUS", "threshold": "BLOCK_NONE"},
- {"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_NONE"},
- {"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_NONE"},
- {"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT", "threshold": "BLOCK_NONE"},
- {"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_NONE"},
+ genai.types.SafetySetting(
+ category=cat,
+ threshold=genai.types.HarmBlockThreshold.BLOCK_NONE,
+ )
+ for cat in (
+ genai.types.HarmCategory.HARM_CATEGORY_HARASSMENT,
+ genai.types.HarmCategory.HARM_CATEGORY_HATE_SPEECH,
+ genai.types.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
+ genai.types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
+ )
]
response = client.models.generate_content(
@@ -192,6 +197,6 @@ def check_comment_spam(post, comment):
contents=prompt,
config=genai.types.GenerateContentConfig(safety_settings=safety_settings),
)
- result = response.text.strip()
+ result = (response.text or "").strip()
return result.upper() == "Y" # Return True if spam, False otherwise