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.

feat: optimize text extraction to use existing PDFs

LearningCircuite3e21b8ba14b
diff --git a/src/local_deep_research/research_library/services/download_service.py b/src/local_deep_research/research_library/services/download_service.py
index 071f11b971..0e160d91e4 100644
--- a/src/local_deep_research/research_library/services/download_service.py
+++ b/src/local_deep_research/research_library/services/download_service.py
@@ -671,6 +671,34 @@ class DownloadService:
logger.info(f"Text file already exists: {existing_files[0]}")
return True, None
+ # Check if we already have a PDF downloaded that we can extract from
+ pdf_path = Path(self.library_root) / "pdfs"
+ existing_pdfs = (
+ list(pdf_path.glob(f"*_{resource_id}.pdf"))
+ if pdf_path.exists()
+ else []
+ )
+
+ if existing_pdfs:
+ logger.info(
+ f"Found existing PDF, extracting text from: {existing_pdfs[0]}"
+ )
+ try:
+ with open(existing_pdfs[0], "rb") as f:
+ pdf_content = f.read()
+ text = self._extract_text_from_pdf(pdf_content)
+ if text:
+ text_path = self._save_text(resource, text)
+ if text_path:
+ return True, None
+ else:
+ return False, "Failed to save text file"
+ except Exception:
+ logger.exception(
+ f"Failed to extract text from existing PDF: {existing_pdfs[0]}"
+ )
+ # Fall through to download new content
+
# Try to get text content directly without saving PDF
logger.info(f"Extracting text from: {resource.url}")