* local question answering over analysis notebooks with LightRAG, Neo4j, Qdrant and Ollama * RAGAS evaluation with a generator x judge comparison matrix, fully local * docs in README and OKF
61 lines
1.6 KiB
Python
61 lines
1.6 KiB
Python
"""
|
|
One-shot script to process any pending/failed documents in LightRAG.
|
|
|
|
Use when a previous ingest was interrupted before entity extraction completed.
|
|
Run inside the container: uv run python scripts/process_pending.py
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import logging
|
|
import sys
|
|
|
|
from lightrag.base import DocStatus
|
|
|
|
from askme.rag import create_rag
|
|
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(asctime)s %(levelname)s %(message)s",
|
|
stream=sys.stderr,
|
|
)
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
async def main() -> None:
|
|
rag = create_rag()
|
|
await rag.initialize_storages()
|
|
|
|
pending = await rag.doc_status.get_docs_by_status(DocStatus.PENDING)
|
|
processing = await rag.doc_status.get_docs_by_status(DocStatus.PROCESSING)
|
|
log.info("Found %d pending, %d processing docs", len(pending), len(processing))
|
|
|
|
if not pending and not processing:
|
|
log.info("Nothing to process.")
|
|
await rag.finalize_storages()
|
|
return
|
|
|
|
await rag.apipeline_process_enqueue_documents()
|
|
|
|
poll_interval = 30
|
|
while True:
|
|
pending = await rag.doc_status.get_docs_by_status(DocStatus.PENDING)
|
|
processing = await rag.doc_status.get_docs_by_status(DocStatus.PROCESSING)
|
|
if not pending and not processing:
|
|
break
|
|
log.info(
|
|
"Waiting: %d pending, %d processing — checking again in %ds",
|
|
len(pending),
|
|
len(processing),
|
|
poll_interval,
|
|
)
|
|
await asyncio.sleep(poll_interval)
|
|
|
|
await rag.finalize_storages()
|
|
log.info("Done.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|