tlogandesigns commited on
Commit
e7b5e83
·
1 Parent(s): 10ae45a

fix social

Browse files
Files changed (1) hide show
  1. checker.py +11 -12
checker.py CHANGED
@@ -32,8 +32,8 @@ DISCLAIMER_DEFAULT = (
32
  "of Columbia Insurance Company, a Berkshire Hathaway affiliate. Equal Housing Opportunity."
33
  )
34
 
35
- # Behavior toggle for social posts requiring disclaimer (choose True/False)
36
- REQUIRE_DISCLAIMER_ON_SOCIAL = os.getenv("REQUIRE_DISCLAIMER_ON_SOCIAL", "1") == "1"
37
 
38
  # Optional HF classifier (tiny) – set USE_TINY_ML=1 to enable
39
  USE_TINY_ML = os.getenv("USE_TINY_ML", "0") == "1"
@@ -162,7 +162,7 @@ def evaluate_section(
162
  agent_name: str,
163
  agent_phone: str,
164
  disclaimer: str,
165
- require_disclaimer_on_social: bool,
166
  ) -> Dict[str, Any]:
167
  flags: List[str] = []
168
 
@@ -178,8 +178,8 @@ def evaluate_section(
178
  phone_equal = office_phone_count == agent_phone_count
179
 
180
  # Disclaimer logic
181
- disclaimer_ok = False
182
- if social and require_disclaimer_on_social:
183
  disclaimer_ok = contains_disclaimer(text, disclaimer)
184
  if not disclaimer_ok:
185
  flags.append("Missing disclaimer on social content")
@@ -235,7 +235,7 @@ def run_check(
235
  company_name: str = COMPANY_NAME_DEFAULT,
236
  company_phones: Optional[List[str]] = None,
237
  disclaimer: str = DISCLAIMER_DEFAULT,
238
- require_disclaimer_on_social: Optional[bool] = None,
239
  ) -> Dict[str, Any]:
240
  """
241
  Execute full pipeline and return payload dict with keys:
@@ -244,8 +244,8 @@ def run_check(
244
  - Ptxt
245
  """
246
  company_phones = company_phones or COMPANY_PHONES_DEFAULT
247
- if require_disclaimer_on_social is None:
248
- require_disclaimer_on_social = REQUIRE_DISCLAIMER_ON_SOCIAL
249
 
250
  itxt = ocr_image(image)
251
 
@@ -265,7 +265,7 @@ def run_check(
265
  agent_name=agent_name,
266
  agent_phone=agent_phone,
267
  disclaimer=disclaimer,
268
- require_disclaimer_on_social=require_disclaimer_on_social,
269
  )
270
 
271
  # Evaluate post text section
@@ -277,7 +277,7 @@ def run_check(
277
  agent_name=agent_name,
278
  agent_phone=agent_phone,
279
  disclaimer=disclaimer,
280
- require_disclaimer_on_social=require_disclaimer_on_social,
281
  )
282
 
283
  return {
@@ -291,7 +291,7 @@ __all__ = [
291
  "COMPANY_NAME_DEFAULT",
292
  "COMPANY_PHONES_DEFAULT",
293
  "DISCLAIMER_DEFAULT",
294
- "REQUIRE_DISCLAIMER_ON_SOCIAL",
295
  "USE_TINY_ML",
296
  "HF_REPO",
297
  "HF_THRESH",
@@ -304,4 +304,3 @@ __all__ = [
304
  "ocr_image",
305
  "run_check",
306
  ]
307
-
 
32
  "of Columbia Insurance Company, a Berkshire Hathaway affiliate. Equal Housing Opportunity."
33
  )
34
 
35
+ # Behavior toggle for non-social posts requiring disclaimer (choose True/False)
36
+ REQUIRE_DISCLAIMER_ON_NON_SOCIAL = os.getenv("REQUIRE_DISCLAIMER_ON_NON_SOCIAL", "1") == "1"
37
 
38
  # Optional HF classifier (tiny) – set USE_TINY_ML=1 to enable
39
  USE_TINY_ML = os.getenv("USE_TINY_ML", "0") == "1"
 
162
  agent_name: str,
163
  agent_phone: str,
164
  disclaimer: str,
165
+ require_disclaimer_on_non_social: bool,
166
  ) -> Dict[str, Any]:
167
  flags: List[str] = []
168
 
 
178
  phone_equal = office_phone_count == agent_phone_count
179
 
180
  # Disclaimer logic
181
+ disclaimer_ok = True
182
+ if (not social) and require_disclaimer_on_non_social:
183
  disclaimer_ok = contains_disclaimer(text, disclaimer)
184
  if not disclaimer_ok:
185
  flags.append("Missing disclaimer on social content")
 
235
  company_name: str = COMPANY_NAME_DEFAULT,
236
  company_phones: Optional[List[str]] = None,
237
  disclaimer: str = DISCLAIMER_DEFAULT,
238
+ require_disclaimer_on_non_social: Optional[bool] = None,
239
  ) -> Dict[str, Any]:
240
  """
241
  Execute full pipeline and return payload dict with keys:
 
244
  - Ptxt
245
  """
246
  company_phones = company_phones or COMPANY_PHONES_DEFAULT
247
+ if require_disclaimer_on_non_social is None:
248
+ require_disclaimer_on_non_social = REQUIRE_DISCLAIMER_ON_NON_SOCIAL
249
 
250
  itxt = ocr_image(image)
251
 
 
265
  agent_name=agent_name,
266
  agent_phone=agent_phone,
267
  disclaimer=disclaimer,
268
+ require_disclaimer_on_non_social=require_disclaimer_on_non_social,
269
  )
270
 
271
  # Evaluate post text section
 
277
  agent_name=agent_name,
278
  agent_phone=agent_phone,
279
  disclaimer=disclaimer,
280
+ require_disclaimer_on_non_social=require_disclaimer_on_non_social,
281
  )
282
 
283
  return {
 
291
  "COMPANY_NAME_DEFAULT",
292
  "COMPANY_PHONES_DEFAULT",
293
  "DISCLAIMER_DEFAULT",
294
+ "REQUIRE_DISCLAIMER_ON_NON_SOCIAL",
295
  "USE_TINY_ML",
296
  "HF_REPO",
297
  "HF_THRESH",
 
304
  "ocr_image",
305
  "run_check",
306
  ]