feat: optimize all 13 prompts by function+scenario; fix topic_selector hardcode

Prompt optimizations:
- topics_trends: 10→8 topics, simplified output, anti-hallucination
- topic_generate: stronger structure, user-pain focus
- topic_selector_gaps: add SEO+social instruction, clean JSON output
- section_expansion: shorter (removed over-detailed AI套话 list), cleaner
- title_optimize_*: 3 titles per line (no numbering), cleaned up
- outline_generation: simplified structure, strong anti-generic-titles
- compliance_fix/polish: expanded fix types, stronger output requirements
- sources_optimization: cleaner JSON schema
- tags_generation: added 'no thinking output' instruction
- research_summary: simplified output structure
- clean_ai_verbosity/clean_thinking_patterns: unchanged (rule-based)

topic_selector.py: hardcoded prompt → get_prompt('topic_selector_gaps')
_PROMPT_DEFAULTS seeds updated to match DB
This commit is contained in:
Yuzhiran Dev
2026-05-27 11:07:56 +08:00
parent 2c6adf1f43
commit 6585909ffc
2 changed files with 19 additions and 30 deletions
+6 -17
View File
@@ -15,6 +15,7 @@ sys.path.insert(0, str(PROJECT_ROOT / "platform" / "backend"))
from trends import load_trends
from db_helper import export_topics_to_json, update_topic_status, save_topics_to_db
from app.core.nvidia_client import call_llm
from prompt_loader import get_prompt
DATA_DIR = PROJECT_ROOT / "automation" / "data"
TRENDS_FILE = DATA_DIR / "trends.json"
@@ -130,23 +131,11 @@ def detect_trend_gaps() -> List[Dict]:
def generate_new_topics(gaps: List[Dict]) -> List[Dict]:
if not gaps:
return []
prompt = f"""你是一个敏锐的内容策略师,擅长将热点转化为有价值、有传播力的选题。以下热点当前未覆盖,请为每个热点生成选题建议。
注意:选题要兼具SEO价值(能在搜索中被找到)和社交传播力(能在平台引发讨论)。
热点列表:
{chr(10).join(f'- {g["topic"]}{g.get("domain","")})— {g.get("reason","")}。热搜词:{", ".join(g.get("hot_keywords", []))}' for g in gaps)}
每个选题需包含:
- "title": 标题(20字内,包含核心关键词,有吸引力)
- "field": 所属领域
- "core_concept": 核心观点(一句话说清独特价值)
- "audience_pain": 受众痛点(真实用户的困惑/焦虑/需求)
- "unique_angle": 独特视角(差异化切入点,含SEO关键词潜力)
- "target_platform": 最适合发布平台(知乎/小红书/微信/多平台)
- "estimated_search_volume": 预估搜索热度(高/中/低)
只输出 JSON 数组,不要其他文字。"""
gaps_text = chr(10).join(
f'- {g["topic"]}{g.get("domain","")})— {g.get("reason","")}。热搜词:{", ".join(g.get("hot_keywords", []))}'
for g in gaps
)
prompt = get_prompt("topic_selector_gaps", gaps=gaps_text)
try:
resp = call_llm(prompt, temperature=0.4)
resp = resp.strip()