fix: 三平台内容差异化 + admin敏感词管理表格化

- writer.py: _expand_section() 去除 <100字阈值,始终调用 LLM 平台专属扩写
- prompt_loader.py: 新增 section_expansion_zhihu/wechat/xiaohongshu 三个独立 prompt
- admin.html: 配置管理标签页 + 敏感词/清理规则子标签 + 敏感词表格化管理(编辑/删除)
- config_items.py: PUT /sensitive-words/{id} 支持更新 word/category
- compliance_checker.py: AI 套话从 DB 加载 + 人称规则修正
- initial_data.py: PlatformConfig 字数迁移 + 新种子
- 各前端页面: LLM 配置 rate_limit 字段 + 供应商列表排序
This commit is contained in:
Yuzhiran Dev
2026-06-08 13:51:35 +08:00
parent d0896ef10e
commit 23ff63baa9
26 changed files with 582 additions and 93 deletions
+52 -14
View File
@@ -55,10 +55,29 @@ AI_TELTALES = [
"众所周知",
"毋庸置疑",
"不知大家有没有发现",
"不可否认",
"毫无疑义",
"从某种意义上",
"从某种程度上",
"在一定程度上",
"换而言之",
"换言之",
"从本质",
"归根结底",
"说到底",
"这为我们提供了",
"为我们提供了宝贵的",
"引发了我们",
"不得不让人思考",
"引人深思",
"毫无悬念",
"毫无意外",
"毫无争议",
]
_cached_sensitive_words = None
_cached_platform_rules = None
_cached_ai_telltales = None
def _load_sensitive_words():
global _cached_sensitive_words
@@ -121,6 +140,34 @@ def _load_platform_rules():
_cached_platform_rules = PLATFORM_RULES
return _cached_platform_rules
def _load_ai_telltales():
"""从 DB ContentCleanRule 加载 AI 套话模式(rule_type='ai_telltale'),无 DB 时回退硬编码列表"""
global _cached_ai_telltales
if _cached_ai_telltales is not None:
return _cached_ai_telltales
try:
from app.core.prompt_loader import _get_session
from app.models import ContentCleanRule
session = _get_session()
try:
rows = session.query(ContentCleanRule).filter(
ContentCleanRule.rule_type == 'ai_telltale',
ContentCleanRule.is_active == True
).order_by(ContentCleanRule.sort_order).all()
if rows:
_cached_ai_telltales = [r.pattern for r in rows]
return _cached_ai_telltales
finally:
session.close()
except Exception:
pass
_cached_ai_telltales = list(AI_TELTALES)
return _cached_ai_telltales
class ComplianceChecker:
"""合规审查器"""
@@ -349,7 +396,8 @@ class ComplianceChecker:
def _check_ai_telltales(self, text: str):
"""检查AI套话——正文中出现这些模式说明AI写作痕迹明显"""
plain = re.sub(r'<[^>]+>', '', text)
for pattern in AI_TELTALES:
patterns = _load_ai_telltales()
for pattern in patterns:
if re.search(pattern, plain):
self.issues.append({
"type": "内容质量",
@@ -359,26 +407,16 @@ class ComplianceChecker:
})
def _check_pronoun_consistency(self, text: str, platform: str):
"""检查人称一致性(尤其是微信文章)"""
if platform != "wechat":
return
"""检查人称一致性"""
plain = re.sub(r'<[^>]+>', '', text)
has_ni = '' in plain
has_nimen = '你们' in plain
has_women = '我们' in plain
if has_nimen and has_ni:
self.issues.append({
"type": "内容质量",
"category": "人称混用",
"detail": "微信文章中同时使用「你」和「你们」,建议统一为「你」",
"suggestion": "所有「你们」替换为「你」,保持与读者的单数对话感"
})
if has_women and has_ni:
self.issues.append({
"type": "内容质量",
"category": "人称混用",
"detail": "微信文章中同时使用「我们」和「你」,建议统一视角",
"suggestion": "将「我们」替换为「你」或「我」,保持与读者对话而非说教"
"detail": "同时使用「你」和「你们」,建议统一为「你」",
"suggestion": "将「你们」替换为「你」,保持对话感"
})
def _check_reading_experience(self, text: str, platform: str = ""):