Danialebrat commited on
Commit
d33c602
·
1 Parent(s): 9c64f47

fixing bugs - header and message exceeding character limit

Browse files
Messaging_system/Message_generator.py CHANGED
@@ -186,7 +186,8 @@ Common instructor phrases:
186
 
187
  ABSOLUTE RULE – OVERRIDES EVERYTHING ELSE:
188
  the header and the message **MUST NOT** contain any banned word or phrases(case-insensitive; singular, plural, verb forms, or their derivatives)
189
- - header < {self.Core.config_file["header_limit"]} and message < {self.Core.config_file["message_limit"]} characters.
 
190
 
191
  Banned word:
192
  {jargon_list}
 
186
 
187
  ABSOLUTE RULE – OVERRIDES EVERYTHING ELSE:
188
  the header and the message **MUST NOT** contain any banned word or phrases(case-insensitive; singular, plural, verb forms, or their derivatives)
189
+ - **important Note:** header must be less than {self.Core.config_file["header_limit"]} and message must be less than {self.Core.config_file["message_limit"]} characters.
190
+
191
 
192
  Banned word:
193
  {jargon_list}
Messaging_system/MultiMessage.py CHANGED
@@ -271,32 +271,37 @@ Write the *next* follow up personalized push notification following the instruct
271
  "thumbnail_url": None
272
  }
273
  else:
274
- recommendation_dict = user["recommendation"]
275
- content_id = int(recommendation_dict["content_id"])
 
276
 
277
- # Extract required fields from found_item
278
- web_url_path = recommendation_dict["web_url_path"]
279
- title = recommendation_dict["title"]
280
- thumbnail_url = recommendation_dict["thumbnail_url"]
281
 
282
- msg = message.get("message")
283
- if isinstance(msg, str):
284
- msg = msg.replace('\\', '').replace('"', '')
285
- else:
286
- msg = str(msg) # or handle it differently if this shouldn't happen
 
287
 
288
- # message["message"].replace('\\', '').replace('"', '')
 
 
 
 
 
 
 
 
 
 
 
 
 
289
 
290
- # Add these to the message dict
291
- output_message = {
292
- "header": message.get("header"),
293
- "message": message.get("message"),
294
- "content_id": content_id,
295
- "web_url_path": web_url_path,
296
- "title": title,
297
- "thumbnail_url": thumbnail_url
298
- }
299
- return output_message
300
 
301
  # ===============================================================
302
  def _remove_from_all(self, recsys_dict, cid):
@@ -368,6 +373,7 @@ Common instructor phrases:
368
 
369
  ABSOLUTE RULE – OVERRIDES EVERYTHING ELSE:
370
  the header and the message **MUST NOT** contain any banned word or phrases(case-insensitive; singular, plural, verb forms, or their derivatives)
 
371
 
372
  Banned word:
373
  {jargon_list}
 
271
  "thumbnail_url": None
272
  }
273
  else:
274
+ try:
275
+ recommendation_dict = user["recommendation"]
276
+ content_id = int(recommendation_dict["content_id"])
277
 
278
+ # Extract required fields from found_item
279
+ web_url_path = recommendation_dict["web_url_path"]
280
+ title = recommendation_dict["title"]
281
+ thumbnail_url = recommendation_dict["thumbnail_url"]
282
 
283
+ msg = message.get("message")
284
+ if isinstance(msg, str):
285
+ msg = msg.replace('\\', '').replace('"', '')
286
+ else:
287
+ msg = str(msg) # or handle it differently if this shouldn't happen
288
+ message["message"] = msg
289
 
290
+ # message["message"].replace('\\', '').replace('"', '')
291
+
292
+ # Add these to the message dict
293
+ output_message = {
294
+ "header": message.get("header"),
295
+ "message": message.get("message"),
296
+ "content_id": content_id,
297
+ "web_url_path": web_url_path,
298
+ "title": title,
299
+ "thumbnail_url": thumbnail_url
300
+ }
301
+ return output_message
302
+ except:
303
+ raise ValueError(f"Parsed response is not a dict: \n\n {message}")
304
 
 
 
 
 
 
 
 
 
 
 
305
 
306
  # ===============================================================
307
  def _remove_from_all(self, recsys_dict, cid):
 
373
 
374
  ABSOLUTE RULE – OVERRIDES EVERYTHING ELSE:
375
  the header and the message **MUST NOT** contain any banned word or phrases(case-insensitive; singular, plural, verb forms, or their derivatives)
376
+ - **important Note:** header must be less than {self.Core.config_file["header_limit"]} and message must be less than {self.Core.config_file["message_limit"]} characters.
377
 
378
  Banned word:
379
  {jargon_list}