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:
@@ -35,14 +35,26 @@ def import_initial_data():
|
||||
db.commit()
|
||||
print(f"✅ 创建默认管理员: {DEFAULT_ADMIN_USERNAME}")
|
||||
|
||||
# 补充或更新 LLM 供应商配置(nvidia 为主,opencode-go 为备)
|
||||
# 补充或更新 LLM 供应商配置(nvidia 为主,sensenova 为备,含多模型)
|
||||
expected = {
|
||||
"opencode-go": dict(provider="opencode-go", model="deepseek-v4-flash",
|
||||
base_url="https://opencode.ai/zen/go/v1", temperature=0.7, max_tokens=131072, is_active=True,
|
||||
user_prompt_template="将以下内容扩展为完整文章:\n{topic_title}\n{core_concept}"),
|
||||
"nvidia": dict(provider="nvidia", model="stepfun-ai/step-3.5-flash",
|
||||
"nvidia": dict(provider="nvidia", model="qwen/qwen3.5-397b-a17b",
|
||||
base_url="https://integrate.api.nvidia.com/v1", temperature=0.5, max_tokens=131072, is_active=False,
|
||||
user_prompt_template="将以下内容扩展为完整章节:\n{section_content}"),
|
||||
"sensenova-6.7-flash-lite": dict(provider="sensenova", model="sensenova-6.7-flash-lite",
|
||||
base_url="https://token.sensenova.cn/v1", temperature=0.3, max_tokens=16384, is_active=True,
|
||||
rate_limit=1500, rate_limit_window_minutes=300,
|
||||
user_prompt_template="将以下内容扩展为完整章节:\n{section_content}"),
|
||||
"sensenova-u1-fast": dict(provider="sensenova", model="sensenova-u1-fast",
|
||||
base_url="https://token.sensenova.cn/v1", temperature=0.3, max_tokens=16384, is_active=True,
|
||||
rate_limit=1500, rate_limit_window_minutes=300,
|
||||
user_prompt_template="根据以下内容生成信息图:\n{section_content}"),
|
||||
"sensenova-deepseek": dict(provider="sensenova", model="deepseek-v4-flash",
|
||||
base_url="https://token.sensenova.cn/v1", temperature=0.3, max_tokens=16384, is_active=True,
|
||||
rate_limit=500, rate_limit_window_minutes=300,
|
||||
user_prompt_template="将以下内容扩展为完整章节:\n{section_content}"),
|
||||
}
|
||||
existing = {c.name: c for c in db.query(LLMConfig).all()}
|
||||
for name, cfg in expected.items():
|
||||
@@ -90,7 +102,7 @@ def import_initial_data():
|
||||
"platform": "zhihu",
|
||||
"name": "知乎",
|
||||
"icon": "🔍",
|
||||
"default_format": "长文深度分析,1500-3000字,有数据支撑",
|
||||
"default_format": "深度分析 3000-8000字,数据驱动",
|
||||
"compliance_rules": {
|
||||
"max_title_len": 100,
|
||||
"allowed_tags": ["科技", "生活", "职场", "教育", "可持续", "AI", "远程工作", "个人成长"],
|
||||
@@ -102,14 +114,14 @@ def import_initial_data():
|
||||
"image_count_max": 0,
|
||||
"image_width": 0,
|
||||
"image_height": 0,
|
||||
"min_words": 1500,
|
||||
"max_words": 3000
|
||||
"min_words": 3000,
|
||||
"max_words": 8000
|
||||
},
|
||||
{
|
||||
"platform": "wechat",
|
||||
"name": "微信公众号",
|
||||
"icon": "💚",
|
||||
"default_format": "公众号图文,800-1500字,亲切口语化",
|
||||
"default_format": "个人叙事 2000-4000字,对话感",
|
||||
"compliance_rules": {
|
||||
"max_title_len": 32,
|
||||
"allowed_tags": ["科技", "生活", "职场", "教育", "可持续", "AI", "远程工作", "个人成长"],
|
||||
@@ -121,14 +133,14 @@ def import_initial_data():
|
||||
"image_count_max": 3,
|
||||
"image_width": 1080,
|
||||
"image_height": 1080,
|
||||
"min_words": 800,
|
||||
"max_words": 1500
|
||||
"min_words": 2000,
|
||||
"max_words": 4000
|
||||
},
|
||||
{
|
||||
"platform": "xiaohongshu",
|
||||
"name": "小红书",
|
||||
"icon": "📕",
|
||||
"default_format": "图文笔记,300-800字,emoji+标签",
|
||||
"default_format": "精炼干货 400-1000字,实用优先",
|
||||
"compliance_rules": {
|
||||
"max_title_len": 50,
|
||||
"allowed_tags": ["生活方式", "可持续", "AI", "个人成长", "极简", "环保"],
|
||||
@@ -140,14 +152,29 @@ def import_initial_data():
|
||||
"image_count_max": 6,
|
||||
"image_width": 1080,
|
||||
"image_height": 1440,
|
||||
"min_words": 300,
|
||||
"max_words": 800
|
||||
"min_words": 400,
|
||||
"max_words": 1000
|
||||
}
|
||||
]
|
||||
for p in platforms:
|
||||
db.add(PlatformConfig(**p))
|
||||
db.commit()
|
||||
print("✅ 插入平台配置")
|
||||
else:
|
||||
# 更新已有平台配置的字数要求(迁移:2026-06 内容质量升级)
|
||||
platform_updates = {
|
||||
"zhihu": {"min_words": 3000, "max_words": 8000, "default_format": "深度分析 3000-8000字,数据驱动"},
|
||||
"wechat": {"min_words": 2000, "max_words": 4000, "default_format": "个人叙事 2000-4000字,对话感"},
|
||||
"xiaohongshu": {"min_words": 400, "max_words": 1000, "default_format": "精炼干货 400-1000字,实用优先"},
|
||||
}
|
||||
for p in db.query(PlatformConfig).all():
|
||||
if p.platform in platform_updates:
|
||||
up = platform_updates[p.platform]
|
||||
p.min_words = up["min_words"]
|
||||
p.max_words = up["max_words"]
|
||||
p.default_format = up["default_format"]
|
||||
db.commit()
|
||||
print("✅ 平台配置已更新(字数/格式)")
|
||||
|
||||
if db.query(TopicField).count() == 0:
|
||||
fields = [
|
||||
|
||||
Reference in New Issue
Block a user