chore: opencode冗余清理 + LLM任务级模型选择 + systemd服务化
- 删除 opencode_search.py / mcp_search_server.py 及所有 MCP 引用 - 移除搜索缓存定时任务(scheduled_refresh_search_cache) - 清理前后端所有 opencode/MCP 代码和注释 - LLM 提供商量换:opencode-go→nvidia(默认)+sensenova(合规审查) - llm_configs 新增 is_default 字段,API 层互斥逻辑 - 所有定时任务支持独立 LLM 模型选择(LLM_TASK_PROVIDER env) - compliance_optimizer.py 修复:import os / 解硬编码 / 关键词过滤 - Scheduler 日志修复:始终 INSERT,避免僵尸 running 行 - Systemd 服务化:Restart=always / 单 worker / Type=exec - 搜索提供商:替换 opencode→360/搜狗/微信(免 Key) - 更新 AGENTS.md / PROGRESS.md
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
合规审查:文章合规检查 → LLM迭代修复
|
||||
从articles表读取待审文章,进行合规评分;不合格文章由LLM修复(最多3次),通过后更新选题状态为待发布
|
||||
"""
|
||||
import json, datetime, logging, sys, re
|
||||
import json, os, datetime, logging, sys, re
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
from dataclasses import dataclass, asdict
|
||||
@@ -165,7 +165,7 @@ 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) — 审查用更好的模型
|
||||
LLM 提供者由 LLM_TASK_PROVIDER 环境变量决定(scheduler 从 TaskConfig 读取设置)
|
||||
"""
|
||||
if not HAVE_LLM:
|
||||
return html, None
|
||||
@@ -182,16 +182,15 @@ 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, provider="sensenova", temperature=temperature, max_tokens=max_tokens, system_prompt=system_prompt)
|
||||
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:
|
||||
if not any(kw in polished for kw in ['保留', '建议', '可以', '应该', '推荐', '改为', '替换为']):
|
||||
tag = "针对性修复" if remaining_issues else "常规润色"
|
||||
return polished, f"LLM {tag}"
|
||||
logger.warning(f"LLM 优化输出异常(过短或含建议性文字),保留原文 (len={len(polished)})")
|
||||
tag = "针对性修复" if remaining_issues else "常规润色"
|
||||
return polished, f"LLM {tag}"
|
||||
logger.warning(f"LLM 优化输出过短,保留原文 (len={len(polished)})")
|
||||
except Exception as e:
|
||||
logger.warning(f"LLM 优化失败 (尝试 {attempt+1}/2): {e}")
|
||||
if attempt == 0:
|
||||
@@ -229,7 +228,8 @@ def _load_platform_configs() -> Dict[str, Dict]:
|
||||
|
||||
def main(topic_ids: List[str] = None, today_only: bool = False):
|
||||
logger.info("=== 合规审查与优化开始 ===")
|
||||
logger.info("LLM 配置: opencode-go (model=deepseek-v4-flash) — 固定用于合规审查")
|
||||
llm_provider = os.getenv("LLM_TASK_PROVIDER", "sensenova")
|
||||
logger.info(f"LLM 配置: {llm_provider} — 合规审查")
|
||||
|
||||
platform_configs = _load_platform_configs()
|
||||
logger.info(f"已加载 {len(platform_configs)} 个平台配置")
|
||||
|
||||
Reference in New Issue
Block a user