~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(pubmed): read each abstract section once, with the text of its inline markup (#7728)
Lukasd647e1799767
diff --git a/changelog.d/7728.bugfix.md b/changelog.d/7728.bugfix.mdnew file mode 100644index 0000000000..285417dc0f--- /dev/null+++ b/changelog.d/7728.bugfix.md@@ -0,0 +1,3 @@+PubMed abstracts are no longer repeated: the first section was read once on its own and+again with the other sections, so a plain abstract appeared twice. Text inside inline+markup is kept as well, so `Rising CO<sub>2</sub> levels` no longer reads `Rising CO`.diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_pubmed.py b/src/local_deep_research/web_search_engines/engines/search_engine_pubmed.pyindex 932db936e8..cb91c38dc7 100644--- a/src/local_deep_research/web_search_engines/engines/search_engine_pubmed.py+++ b/src/local_deep_research/web_search_engines/engines/search_engine_pubmed.py@@ -930,14 +930,8 @@ The default assumption should be that medical and scientific queries want RECENTif pmid is None:continue- # Find abstract text+ # The abstract is its sections, one or several (structured)abstract_text = ""- abstract_elem = article.find(".//AbstractText")-- if abstract_elem is not None:- abstract_text = abstract_elem.text or ""-- # Some abstracts are split into multiple sectionsabstract_sections = article.findall(".//AbstractText")if len(abstract_sections) > 1:logger.debug(@@ -947,7 +941,9 @@ The default assumption should be that medical and scientific queries want RECENTfor section in abstract_sections:# Get section label if it existslabel = section.get("Label")- section_text = section.text or ""+ # All of the section's text: `.text` stops at the first inline+ # element, so "CO<sub>2</sub> levels" would read "CO"+ section_text = "".join(section.itertext()).strip()if label and section_text:if abstract_text:diff --git a/tests/web_search_engines/engines/test_search_engine_pubmed.py b/tests/web_search_engines/engines/test_search_engine_pubmed.pyindex e89d6f6fca..459ccac4be 100644--- a/tests/web_search_engines/engines/test_search_engine_pubmed.py+++ b/tests/web_search_engines/engines/test_search_engine_pubmed.py@@ -950,6 +950,55 @@ class TestGetArticleAbstracts:assert "METHODS" in result["12345"]assert "RESULTS" in result["12345"]+ def test_reads_each_abstract_section_once_with_its_inline_markup(self):+ """A plain abstract is not repeated, and inline markup keeps its text."""+ from local_deep_research.web_search_engines.engines.search_engine_pubmed import (+ PubMedSearchEngine,+ )++ engine = PubMedSearchEngine()++ xml_response = """<?xml version="1.0"?>+ <PubmedArticleSet>+ <PubmedArticle>+ <MedlineCitation>+ <PMID>1</PMID>+ <Article>+ <Abstract>+ <AbstractText>Rising CO<sub>2</sub> levels in <i>E. coli</i> cultures.</AbstractText>+ </Abstract>+ </Article>+ </MedlineCitation>+ </PubmedArticle>+ <PubmedArticle>+ <MedlineCitation>+ <PMID>2</PMID>+ <Article>+ <Abstract>+ <AbstractText Label="BACKGROUND">Background info.</AbstractText>+ <AbstractText Label="RESULTS">Results info.</AbstractText>+ </Abstract>+ </Article>+ </MedlineCitation>+ </PubmedArticle>+ </PubmedArticleSet>+ """++ with patch(+ "local_deep_research.web_search_engines.engines.search_engine_pubmed.safe_get"+ ) as mock_get:+ mock_response = Mock()+ mock_response.text = xml_response+ mock_response.raise_for_status = Mock()+ mock_get.return_value = mock_response++ result = engine._get_article_abstracts(["1", "2"])++ assert result == {+ "1": "Rising CO2 levels in E. coli cultures.",+ "2": "BACKGROUND: Background info.\n\nRESULTS: Results info.",+ }+class TestGetArticleDetailedMetadata:"""Tests for _get_article_detailed_metadata method."""