feat: GEO/SEO structured data + search ranking tracker
This commit is contained in:
+18
-1
@@ -3,7 +3,7 @@
|
||||
大纲阶段:基于选题和研究笔记,用 LLM 动态生成结构化大纲
|
||||
"""
|
||||
|
||||
import json, datetime, logging, sys
|
||||
import json, datetime, logging, sys, re
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
|
||||
@@ -43,6 +43,21 @@ class Outliner:
|
||||
if not topic: raise ValueError(f"Topic {self.topic_id} not found")
|
||||
return topic
|
||||
|
||||
@staticmethod
|
||||
def _extract_seo_keywords(research_notes: str) -> str:
|
||||
"""从研究笔记中提取 SEO 关键词"""
|
||||
if not research_notes:
|
||||
return "暂无"
|
||||
# 尝试匹配 "SEO关键词建议" 块
|
||||
m = re.search(r'(?:SEO关键词建议|SEO关键词|搜索词)[::]\s*(.*?)(?:\n\n|\Z)', research_notes, re.DOTALL)
|
||||
if m:
|
||||
return m.group(1).strip()[:300]
|
||||
# 回退:取所有 # 标签或关键词模式
|
||||
keywords = re.findall(r'[##](\w{2,6})', research_notes)
|
||||
if keywords:
|
||||
return "、".join(keywords[:5])
|
||||
return "暂无"
|
||||
|
||||
def generate_outline(self) -> str:
|
||||
title = self.topic['title']
|
||||
field = self.topic.get('field', '')
|
||||
@@ -50,6 +65,7 @@ class Outliner:
|
||||
pain = self.topic.get('audience_pain', '')
|
||||
angle = self.topic.get('unique_angle', '')
|
||||
cases_summary = self.research_notes[:2000] if self.research_notes else "暂无研究笔记"
|
||||
seo_keywords = self._extract_seo_keywords(self.research_notes)
|
||||
|
||||
if HAVE_LLM:
|
||||
_now = datetime.datetime.now()
|
||||
@@ -62,6 +78,7 @@ class Outliner:
|
||||
pain=pain,
|
||||
angle=angle,
|
||||
cases_summary=cases_summary,
|
||||
seo_keywords=seo_keywords,
|
||||
)
|
||||
try:
|
||||
params = get_prompt_params("outline_generation")
|
||||
|
||||
Reference in New Issue
Block a user