~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
from markdown import markdown
import pytest
from local_deep_research.chat.citation_stripping import (
strip_prior_turn_citations,
)
from local_deep_research.text_optimization.citation_formatter import (
CitationFormatter,
CitationMode,
)
@pytest.mark.parametrize(
"url",
[
"http://example.com:8080/a",
"http://EXAMPLE.COM:8080/a",
"http://[::1]:8080/a",
],
)
def test_formatter_port_label_is_stripped_when_source_has_authority(
url: str,
) -> None:
document = f"See [1] now.\n\n## Sources\n\n[1] Example\nURL: {url}"
formatted = CitationFormatter(
mode=CitationMode.DOMAIN_HYPERLINKS
).format_document(document)
text = formatted.split("\n\n## Sources", maxsplit=1)[0]
result = strip_prior_turn_citations(text)
assert result == "See now."
@pytest.mark.parametrize(
"text",
[
"",
"[1]: https://en.wikipedia.org",
"Go to https://example.com/page/[1]/details here",
],
)
def test_numeric_markdown_and_url_path_survive_when_not_citations(
text: str,
) -> None:
result = strip_prior_turn_citations(text)
assert result == text
@pytest.mark.parametrize(
("text", "expected", "rendered"),
[
(
"<span>word</span> [[1]](u)<span>next</span>",
"<span>word</span> <span>next</span>",
"<p><span>word</span> <span>next</span></p>",
),
(
"word [[1]](u)[dataset](v)",
"word [dataset](v)",
'<p>word <a href="v">dataset</a></p>',
),
("text [1]more", "text more", "<p>text more</p>"),
],
)
def test_removed_citation_keeps_rendered_text_separated(
text: str, expected: str, rendered: str
) -> None:
result = strip_prior_turn_citations(text)
assert result == expected
assert markdown(result) == rendered
@pytest.mark.parametrize("marker", ["`", "~"])
def test_fence_longer_than_previous_limit_is_fully_protected(
marker: str,
) -> None:
fence = marker * 33
shorter = marker * 32
text = f"{fence}\n[1] [[2]](u)\n{shorter}\n[3]\n{fence}"
result = strip_prior_turn_citations(text)
assert result == text