fix(rag): _run_index 修正 index_document 簽名不符 — 讀檔內容再傳 service
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 13m3s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-10 09:00:26 +08:00
parent 0ee5d532ba
commit 3ed52b0424

View File

@@ -87,15 +87,19 @@ async def _run_index() -> None:
for source_dir in sources:
if not source_dir.exists():
continue
pattern = "*.md"
for md_file in source_dir.glob(pattern):
for md_file in source_dir.glob("*.md"):
try:
count = await svc.index_document(
file_path=md_file,
source_type=source_dir.parts[0] if len(source_dir.parts) == 1 else source_dir.parts[1],
text = md_file.read_text(encoding="utf-8", errors="ignore")
source_type = source_dir.parts[-1] # e.g. "runbooks", "adr", "skills"
ok = await svc.index_document(
source=source_type,
source_id=str(md_file),
title=md_file.stem,
text=text,
)
total += count
logger.debug("rag_indexed", file=str(md_file), chunks=count)
if ok:
total += 1
logger.debug("rag_indexed", file=str(md_file))
except Exception as e:
logger.warning("rag_index_file_failed", file=str(md_file), error=str(e))