chore: 集成 LLM 增强 — config/main/articles schema/workers + .env.example 加 Agnes 配置

This commit is contained in:
Mavis
2026-06-08 14:24:23 +08:00
parent ffd667f0dc
commit ba2298da0a
7 changed files with 48 additions and 7 deletions

View File

@@ -17,6 +17,7 @@ from sqlalchemy import select
from app.config import settings
from app.database import AsyncSessionLocal
from app.models.source import Source
from app.services.llm.enrichment import enrichment_loop
from app.workers.pipeline import fetch_one_source, run_once, translation_loop
logger = logging.getLogger("news.worker")
@@ -93,6 +94,10 @@ async def main() -> None:
translation_task = asyncio.create_task(translation_loop(), name="translation_loop")
logger.info("translation_loop task scheduled (1 article/sec)")
# 独立的 LLM 增强后台循环(翻译完成后,跑 4 项 LLM 任务)
enrichment_task = asyncio.create_task(enrichment_loop(), name="enrichment_loop")
logger.info("enrichment_loop task scheduled (scans translated articles)")
stop = asyncio.Event()
def _signal_handler():
@@ -108,12 +113,13 @@ async def main() -> None:
pass
await stop.wait()
logger.info("stopping scheduler and translation loop")
translation_task.cancel()
try:
await translation_task
except asyncio.CancelledError:
pass
logger.info("stopping scheduler and background loops")
for t in (translation_task, enrichment_task):
t.cancel()
try:
await t
except asyncio.CancelledError:
pass
scheduler.shutdown(wait=False)