~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix: Split Paperless highlights into separate citable sources
LearningCircuite28cfe87071f
diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_paperless.py b/src/local_deep_research/web_search_engines/engines/search_engine_paperless.pyindex b6ae491adc..9ebaf8fd44 100644--- a/src/local_deep_research/web_search_engines/engines/search_engine_paperless.py+++ b/src/local_deep_research/web_search_engines/engines/search_engine_paperless.py@@ -354,10 +354,17 @@ Include synonyms, plural forms, and technical terms."""return []# Convert documents to preview format+ # Note: Each document may return multiple previews (one per highlight)previews = []for doc_data in results:- preview = self._convert_document_to_preview(doc_data, query)- previews.append(preview)+ doc_previews = self._convert_document_to_preview(+ doc_data, query+ )+ # Handle both single preview and list of previews+ if isinstance(doc_previews, list):+ previews.extend(doc_previews)+ else:+ previews.append(doc_previews)logger.info(f"Found {len(previews)} documents in Paperless-ngx for query: {query}"@@ -397,6 +404,7 @@ Include synonyms, plural forms, and technical terms."""snippet = ""search_score = 0.0search_rank = None+ all_highlights = [] # Initialize empty highlights listif "__search_hit__" in doc_data:search_hit = doc_data["__search_hit__"]@@ -416,9 +424,18 @@ Include synonyms, plural forms, and technical terms."""logger.debug(f"Highlights is list with {len(highlights)} items")- # Join multiple highlight snippets- snippet = " ... ".join(highlights)+ # IMPORTANT: Store highlights list for processing later+ # Each highlight will become a separate search result for proper citation+ all_highlights = highlights+ # Use first highlight for the default snippet+ snippet = highlights[0] if highlights else ""+ logger.info(+ f"Will create {len(highlights)} separate results from highlights"+ )else:+ all_highlights = [+ str(highlights)+ ] # Single highlight as listsnippet = str(highlights)logger.debug(@@ -571,7 +588,41 @@ Include synonyms, plural forms, and technical terms."""f"Built preview for doc {doc_id}: URL={url}, snippet_len={len(snippet)}, has_author={bool(preview['author'])}, has_date={bool(preview['date'])}")- return preview+ # Check if we have multiple highlights to return as separate results+ if "all_highlights" in locals() and len(all_highlights) > 1:+ # Create multiple previews, one for each highlight+ previews = []+ for i, highlight in enumerate(all_highlights):+ # Clean each highlight+ clean_snippet = re.sub(r"<span[^>]*>", "**", str(highlight))+ clean_snippet = re.sub(r"</span>", "**", clean_snippet)+ clean_snippet = re.sub(r"<[^>]+>", "", clean_snippet)++ # Create a preview for this highlight+ highlight_preview = {+ "title": f"{enhanced_title} (excerpt {i + 1})", # Differentiate each excerpt+ "url": url,+ "link": url,+ "snippet": clean_snippet,+ "author": doc_data.get("correspondent_name", ""),+ "date": doc_data.get("created", ""),+ "source": "Paperless",+ "metadata": {+ **metadata,+ "excerpt_number": i + 1,+ "total_excerpts": len(all_highlights),+ },+ "_raw_data": doc_data,+ }+ previews.append(highlight_preview)++ logger.info(+ f"Created {len(previews)} separate previews from highlights for doc {doc_id}"+ )+ return previews+ else:+ # Single preview (original behavior)+ return previewdef _get_full_content(self, relevant_items: List[Dict[str, Any]]@@ -682,9 +733,15 @@ Include synonyms, plural forms, and technical terms."""logger.info(f"Search completed successfully, returning {len(results)} results")- logger.info(- f"Results summary: {[{'title': r.get('title', '')[:30], 'url': r.get('url', '')[:50]} for r in results[:3]]}"- )+ # Enhanced logging to track document structure for citation debugging+ for i, r in enumerate(results[:3], 1):+ logger.info(+ f"Result {i}: title='{r.get('title', '')[:50]}...', "+ f"has_full_content={bool(r.get('full_content'))}, "+ f"full_content_len={len(r.get('full_content', ''))}, "+ f"snippet_len={len(r.get('snippet', ''))}, "+ f"url={r.get('url', '')[:50]}"+ )return results