mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-11-20 11:20:35 +00:00
* feat(search): add DeepSeek web search with configurable thinking * fix(search): drain DeepSeek teardown and retain citation spans Reuse the cancellation-safe context helper so repeated cancellation cannot interrupt HTTP transport cleanup. Preserve validated Unicode citation ranges on retained public sources so the agent can associate claims with their supporting pages. Add regressions for cancellation, timeout, normal completion, invalid ranges, URL screening, and result limits. * fix(search): preserve DeepSeek citation excerpts through guardrails * fix(search): share DeepSeek citation excerpts across sources Group each validated answer range once and associate it with response-local source IDs after URL filtering and result limits. Preserve full-answer PII redaction and existing source-card fields, document the model-facing citation mapping, and repair live-test configuration for both thinking modes. Add HTTP transport, guardrail/budget, attribution, and browser reload regressions. --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""Opt-in API checks. Set DEER_FLOW_RUN_LIVE_TESTS=1 and DEEPSEEK_API_KEY."""
|
|
|
|
import json
|
|
import os
|
|
from types import SimpleNamespace
|
|
|
|
import pytest
|
|
|
|
from deerflow.community.deepseek import tools as deepseek
|
|
from deerflow.config.pii_redaction_config import PiiRedactionConfig
|
|
|
|
pytestmark = [
|
|
pytest.mark.live,
|
|
pytest.mark.skipif(os.getenv("DEER_FLOW_RUN_LIVE_TESTS") != "1", reason="Live DeepSeek requests are opt-in"),
|
|
pytest.mark.skipif(not os.getenv("DEEPSEEK_API_KEY"), reason="DEEPSEEK_API_KEY is required"),
|
|
]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.parametrize("thinking", [False, True])
|
|
async def test_deepseek_search_api_returns_public_sources(monkeypatch, thinking):
|
|
extras = {"thinking": thinking, "max_results": 2}
|
|
monkeypatch.setattr(deepseek, "get_app_config", lambda: SimpleNamespace(get_tool_config=lambda name: SimpleNamespace(model_extra=extras), pii_redaction=PiiRedactionConfig()))
|
|
result = json.loads(
|
|
await deepseek.web_search_tool.ainvoke(
|
|
{
|
|
"query": "Search the official Python website for the Python 3.13.0 release date and provide its release page URL.",
|
|
}
|
|
)
|
|
)
|
|
assert "error" not in result
|
|
assert 0 < result["total_results"] <= 2
|
|
assert result["answer"]
|
|
assert all(row["url"].startswith(("https://", "http://")) for row in result["results"])
|