~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://10.0.0.1/a",
"http://10.0.0.1:8080/a",
],
)
def test_formatter_ipv4_label_is_stripped(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."
assert markdown(result) == "<p>See now.</p>"
@pytest.mark.parametrize(
"text",
[
"[dataset](https://example.com/page/[1]/details)",
"<https://example.com/page/[1]/details>",
"(https://example.com/page/[1]/details)",
'<a href="https://example.com/page/[1]/details">dataset</a>',
],
)
def test_numeric_marker_in_punctuation_prefixed_url_survives(text: str) -> None:
result = strip_prior_turn_citations(text)
assert result == text
assert markdown(result) == markdown(text)
@pytest.mark.parametrize(
"text",
[
"![Figure 1 [1]](pic.jpg)",
"![some [1] text](pic.jpg)",
],
)
def test_numeric_marker_nested_in_image_alt_text_survives(text: str) -> None:
result = strip_prior_turn_citations(text)
assert result == text
assert markdown(result) == markdown(text)
@pytest.mark.parametrize(
("text", "expected"),
[
("word[[1]](u)[dataset](v)", "word [dataset](v)"),
("word[[1]](u)more", "word more"),
(
"<span>word</span>[[1]](u)<span>next</span>",
"<span>word</span> <span>next</span>",
),
],
)
def test_adjacent_citation_removal_separates_rendered_words(
text: str, expected: str
) -> None:
result = strip_prior_turn_citations(text)
assert result == expected
assert markdown(result) == markdown(expected)
@pytest.mark.parametrize(
"text",
[
" [1]\n [2]",
"\t[1]",
"<code>[1]</code>",
"<code>first [1]\nsecond [2]</code>",
],
)
def test_commonmark_code_content_preserves_numeric_brackets(text: str) -> None:
result = strip_prior_turn_citations(text)
assert result == text
assert markdown(result) == markdown(text)