Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

merge: resolve conflicts with fix/collection-search-efficiency

LearningCircuit9b905d29058d
diff --cc src/local_deep_research/research_library/routes/rag_routes.py
index 177419308f,ee2c5b6f60..1dadafcf8f
--- a/src/local_deep_research/research_library/routes/rag_routes.py
+++ b/src/local_deep_research/research_library/routes/rag_routes.py
@@@ -2045,41 -1999,17 +2045,43 @@@ def index_collection(collection_id)
yield f"data: {json.dumps({'type': 'progress', 'current': idx, 'total': total, 'filename': filename, 'percent': int((idx / total) * 100)})}\n\n"
try:
- logger.debug(f"Indexing document {idx}/{total}")
- logger.info(
++ logger.debug(
+ f"Indexing document {idx}/{total}: {filename}"
+ )
- # Index the document using collection-based method
- result = rag_service.index_document(
- document_id=doc.id,
- collection_id=collection_id,
- force_reindex=force_reindex,
- )
+
+ # Use a queue to run index_document in a thread while sending heartbeats
+ result_queue = queue.Queue()
+ error_queue = queue.Queue()
+
+ def index_in_thread():
+ try:
+ r = rag_service.index_document(
+ document_id=doc.id,
+ collection_id=collection_id,
+ force_reindex=force_reindex,
+ )
+ result_queue.put(r)
+ except Exception as ex:
+ error_queue.put(ex)
+
+ thread = threading.Thread(target=index_in_thread)
+ thread.start()
+
+ # Send heartbeats while waiting for the thread to complete
+ heartbeat_interval = 5 # seconds
+ while thread.is_alive():
+ thread.join(timeout=heartbeat_interval)
+ if thread.is_alive():
+ # Send SSE comment as heartbeat (keeps connection alive)
+ yield f": heartbeat {idx}/{total}\n\n"
+
+ # Check for errors from thread
+ if not error_queue.empty():
+ raise error_queue.get()
+
+ result = result_queue.get()
- logger.debug(
- f"Indexed document {idx}/{total}, status={result.get('status')}"
+ logger.info(
+ f"Indexed document {idx}/{total}: {filename} - status={result.get('status')}"
)
if result.get("status") == "success":
@@@ -2098,7 -2028,7 +2100,7 @@@
}
)
logger.warning(
- f"Failed to index document {idx}/{total}: {error_msg}"
- f"Failed to index {filename}: {error_msg}"
++ f"Failed to index {filename} ({idx}/{total}): {error_msg}"
)
except Exception as e:
results["failed"] += 1
@@@ -2110,7 -2040,7 +2112,7 @@@
}
)
logger.exception(
- f"Exception indexing document {idx}/{total}"
- f"Exception indexing document {filename}"
++ f"Exception indexing document {filename} ({idx}/{total})"
)
# Send error update to client so they know indexing is continuing
yield f"data: {json.dumps({'type': 'doc_error', 'filename': filename, 'error': error_msg})}\n\n"