feat: GEO/SEO structured data + search ranking tracker

This commit is contained in:
Yuzhiran Dev
2026-06-09 17:18:09 +08:00
parent 23ff63baa9
commit 8595bbc521
26 changed files with 961 additions and 51 deletions
+7 -4
View File
@@ -169,25 +169,28 @@ def polish_with_llm(html: str, platform: str, remaining_issues: Optional[List[Di
"""
if not HAVE_LLM:
return html, None
prompt_key = "compliance_fix" if remaining_issues else "compliance_polish"
for attempt in range(2):
try:
temperature = 0.5
max_tokens = 4000
params = get_prompt_params(prompt_key)
max_tokens = params.get("max_tokens", 8000)
system_prompt = "你是一个专业的内容合规与优化助手,擅长在保持文章质量和可读性的前提下修复合规问题。"
if remaining_issues:
issues_desc = "\n".join(
f"- [{i['type']}] {i.get('category','')}: {i.get('detail','')}"
for i in remaining_issues
)
prompt = get_prompt("compliance_fix", issues_desc=issues_desc, html=html)
prompt = get_prompt(prompt_key, issues_desc=issues_desc, html=html)
else:
prompt = get_prompt("compliance_polish", html=html)
prompt = get_prompt(prompt_key, html=html)
polished = call_llm(prompt, temperature=temperature, max_tokens=max_tokens, system_prompt=system_prompt)
polished = clean_html_content(polished)
polished = strip_ai_preface(polished)
polished = strip_thinking_html(polished)
if '<h2' in polished or '<p>' in polished:
if len(polished) > len(html) * 0.3 and len(polished) > 100:
min_acceptable = min(len(html) * 0.3, 12000)
if len(polished) > min_acceptable and len(polished) > 100:
tag = "针对性修复" if remaining_issues else "常规润色"
return polished, f"LLM {tag}"
logger.warning(f"LLM 优化输出过短,保留原文 (len={len(polished)})")