Allow empty text for non-target AI rewrites

This commit is contained in:
Your Name
2026-07-30 09:14:54 +05:00
parent 519474e4ff
commit 858fa4cc46
3 changed files with 7 additions and 2 deletions
+2 -2
View File
@@ -152,8 +152,6 @@ def validate_rewrites(
if post_id not in expected_ids:
raise ValueError(f"AI returned unexpected id={post_id}")
text = strip_leading_emoji_markers(str(item.get("text") or "").strip())
if len(text) < 40:
raise ValueError(f"AI returned too short rewrite for id={post_id}")
by_id = {int(c["id"]): c for c in categories if c.get("id") is not None}
by_name = {str(c["name"]).lower(): c for c in categories if c.get("name")}
if item.get("category_id") is not None:
@@ -170,6 +168,8 @@ def validate_rewrites(
seen.add(post_id)
category_tag = normalize_hash_tag(category_row.get("tag") or category_row.get("name") or "", "category")
reject_by_category = int(category_row["id"]) == NON_TARGET_CATEGORY_ID or category_tag.lower() in NON_TARGET_CATEGORY_TAGS
if not reject_by_category and len(text) < 40:
raise ValueError(f"AI returned too short rewrite for id={post_id}")
out.append(
{
"id": post_id,