refactor: 清理历史 AI Agent 文档残留 + 重构 docs/ + Pipeline 健壮性修复
- docs: 删除 CLAUDE.md / continuation.md / english-news-plan.md 及旧版 intlnews_usage.*,
统一迁移到 docs/{README,architecture,quickstart,usage,pipeline,configuration,deployment,development,faq}.md
- README: 精简为仓库入口,指向 docs/
- configs/sources.yaml: 更新注释指向新文档
- .env.example: 修正 DashScope Embedding 端点说明
Pipeline 修复:
- dedup/llm/embedding/vectorstore/reporter: 过滤 M2 no_content / 空正文,避免污染下游与 Qdrant
- dedup/pipeline: 改为先写唯一文件再写指纹,避免崩溃导致文章永久丢失
- crawler/orchestrator: sources_crawled 改为“尝试数”,成功数 = crawled - failed
- crawler/storage: write_index_jsonl 从文章路径推断日期,修复跨天/测试路径问题
- scheduler/pipeline: STEP_TIMEOUTS 实际生效(SIGALRM)
- scheduler/reporter: emb_count 排除 index.json;日报跳过无原文事件
- vectorstore/pipeline: payload 增加 source_ids;--recreate --all 时空日期也重建 collection
- app/cli: extract/dedup/translate/embed/index/pipeline 支持 --date;embed/index 支持 --all;crawl 全源失败返回非零
- scripts: domestic_full/crawl_8g/crawl_2g/pipeline 安全加载 .env;M1 全失败不标记且最终退出码=1
This commit is contained in:
@@ -50,6 +50,11 @@ def _load_embedding_files(date_str: str) -> list[dict]:
|
||||
if event_file.exists():
|
||||
article_data = json.loads(event_file.read_text(encoding="utf-8"))
|
||||
|
||||
# 防御性过滤:没有英文原文的事件/向量不应进入知识库。
|
||||
# 历史 no_content 残留满足此条件,重建/全量回灌时可被自动剔除。
|
||||
if not (article_data.get("content_en") or "").strip():
|
||||
continue
|
||||
|
||||
items.append({
|
||||
"url_hash": emb_data["url_hash"],
|
||||
"source_id": emb_data.get("source_id", ""),
|
||||
@@ -77,6 +82,7 @@ def _build_payload(article_data: dict) -> dict:
|
||||
"title_zh": article_data.get("title_zh", ""),
|
||||
"url": article_data.get("url", ""),
|
||||
"source_id": article_data.get("source_id", ""),
|
||||
"source_ids": article_data.get("source_ids", []),
|
||||
"source_name": article_data.get("source_name", ""),
|
||||
"publish_time": article_data.get("publish_time", ""),
|
||||
"events": article_data.get("events", []),
|
||||
@@ -107,6 +113,15 @@ def ingest_all_embeddings(
|
||||
|
||||
items = _load_embedding_files(date_str)
|
||||
if not items:
|
||||
# --recreate 时即使当天没有有效向量,也要先把 collection 重建/清空,
|
||||
# 避免 --all --recreate 遇到首个空日期时跳过重建。
|
||||
if recreate:
|
||||
client = make_qdrant_client()
|
||||
store = VectorStore(client)
|
||||
try:
|
||||
store.init_collection(recreate=True)
|
||||
finally:
|
||||
store.close()
|
||||
logger.warning("嵌入目录无数据: data/embeddings/%s/", date_str)
|
||||
return {"date": date_str, "total": 0, "ingested": 0, "failed": 0, "elapsed_sec": 0}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user