From 878daebfe012007776492bb5b5eb745564e094e4 Mon Sep 17 00:00:00 2001 From: Yuzhiran Dev Date: Wed, 27 May 2026 09:36:34 +0800 Subject: [PATCH] fix: route compliance to opencode-go, others to nvidia; skip status on force-pass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. DB active provider switched to nvidia (stepfun-ai/step-3.5-flash) → trends/collector/writer 默认用 nvidia 2. compliance_optimizer.py 固定 provider='opencode-go' → 合规审查用 deepseek-v4-flash(更好的模型) 3. force_passed 的选题不再更新为 'ready'(待发布) → 只有真正修复通过才更新状态 --- scripts/compliance_optimizer.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/scripts/compliance_optimizer.py b/scripts/compliance_optimizer.py index 0180737..018054e 100644 --- a/scripts/compliance_optimizer.py +++ b/scripts/compliance_optimizer.py @@ -160,17 +160,15 @@ def polish_with_llm(html: str, platform: str, remaining_issues: Optional[List[Di """用 LLM 优化文章内容,返回 (html, log_message_or_None) 如果指定 remaining_issues,则针对性修复合规问题 LLM 失败时自动重试一次 + 固定使用 opencode-go (deepseek-v4-flash) — 审查用更好的模型 """ if not HAVE_LLM: return html, None - llm_cfg = get_llm_config() for attempt in range(2): try: - model = llm_cfg.get('model') if llm_cfg else None - temperature = llm_cfg.get('temperature', 0.5) if llm_cfg else 0.5 - max_tokens = llm_cfg.get('max_tokens', 4000) if llm_cfg else 4000 - system_prompt = llm_cfg.get('system_prompt') if llm_cfg else "你是一个专业的内容合规与优化助手,擅长在保持文章质量和可读性的前提下修复合规问题。" - + temperature = 0.5 + max_tokens = 4000 + system_prompt = "你是一个专业的内容合规与优化助手,擅长在保持文章质量和可读性的前提下修复合规问题。" if remaining_issues: issues_desc = "\n".join( f"- [{i['type']}] {i.get('category','')}: {i.get('detail','')}" @@ -179,7 +177,7 @@ def polish_with_llm(html: str, platform: str, remaining_issues: Optional[List[Di prompt = get_prompt("compliance_fix", issues_desc=issues_desc, html=html) else: prompt = get_prompt("compliance_polish", html=html) - polished = call_llm(prompt, model=model, temperature=temperature, max_tokens=max_tokens, system_prompt=system_prompt) + polished = call_llm(prompt, provider="opencode-go", 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) @@ -226,11 +224,7 @@ def _load_platform_configs() -> Dict[str, Dict]: def main(topic_ids: List[str] = None): logger.info("=== 合规审查与优化开始 ===") - llm_cfg = get_llm_config() - if llm_cfg: - logger.info(f"LLM 配置: {llm_cfg['name']} (model={llm_cfg['model']})") - else: - logger.info("LLM 配置: 使用环境变量默认值") + logger.info("LLM 配置: opencode-go (model=deepseek-v4-flash) — 固定用于合规审查") platform_configs = _load_platform_configs() logger.info(f"已加载 {len(platform_configs)} 个平台配置") @@ -251,6 +245,7 @@ def main(topic_ids: List[str] = None): topic_map = load_topic_map() results = [] + force_passed_topics = set() for html, platform_dir, topic_id in articles: topic_data = topic_map.get(topic_id) @@ -294,6 +289,7 @@ def main(topic_ids: List[str] = None): else: save_article(topic_id, platform_dir, current_html) logger.warning(f"⚠️ {label} 仍有 {len(current_issues)} 个问题未修复,已强制通过(当前分 {current_score})") + force_passed_topics.add(topic_id) results.append(OptimizationResult( file=f"db:{platform_dir}_{topic_id}", platform=platform_dir, @@ -302,7 +298,7 @@ def main(topic_ids: List[str] = None): original_issues=len(issues), fixed_issues=len(issues) - len(current_issues), final_score=current_score, - status="passed" + status="force_passed" )) else: results.append(OptimizationResult( @@ -324,6 +320,9 @@ def main(topic_ids: List[str] = None): passed_scores[res.topic_id].append(res.final_score) for tid, scores in passed_scores.items(): + if tid in force_passed_topics: + logger.warning(f"选题 {tid} 仍有未修复问题,跳过状态更新(保留当前状态)") + continue avg_score = sum(scores) // len(scores) update_topic_status(tid, 'ready', compliance_score=avg_score, reviewed_at=datetime.datetime.now()) logger.info(f"选题 {tid} 状态 → ready(待发布), 合规分={avg_score}") @@ -342,8 +341,8 @@ def main(topic_ids: List[str] = None): with open(report_file, 'w', encoding='utf-8') as f: json.dump(report, f, ensure_ascii=False, indent=2) - logger.info(f"✅ 合规审查完成: {len(results)} 篇文章全部通过") - print(f"OPTIMIZATION_COMPLETE: {len(results)} articles, all passed") + logger.info(f"✅ 合规审查完成: {len(results)} 篇文章, 其中 {len([r for r in results if r.status=='force_passed'])} 篇强制通过") + print(f"OPTIMIZATION_COMPLETE: {len(results)} articles, {len(force_passed_topics)} topics skipped status update") sys.exit(0) if __name__ == "__main__":