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>
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""Keep DeepSeek provider config reads and HTTPX TLS setup off the loop."""
|
|
|
|
import importlib
|
|
import json
|
|
import threading
|
|
from pathlib import Path
|
|
from types import SimpleNamespace
|
|
|
|
import httpx
|
|
import pytest
|
|
|
|
from deerflow.config.pii_redaction_config import PiiRedactionConfig
|
|
|
|
|
|
@pytest.fixture
|
|
def provider(monkeypatch):
|
|
module = importlib.import_module("deerflow.community.deepseek.tools")
|
|
threads = []
|
|
|
|
def config():
|
|
threads.append(threading.get_ident())
|
|
Path(__file__).read_text(encoding="utf-8")
|
|
return SimpleNamespace(get_tool_config=lambda _name: SimpleNamespace(model_extra={"api_key": "test-key"}), pii_redaction=PiiRedactionConfig())
|
|
|
|
def respond(request):
|
|
return httpx.Response(200, json={"choices": [{"finish_reason": "stop", "message": {"content": "", "server_tool_calls": []}}]})
|
|
|
|
def client(**kwargs):
|
|
threads.append(threading.get_ident())
|
|
Path(__file__).read_text(encoding="utf-8")
|
|
return httpx.AsyncClient(transport=httpx.MockTransport(respond), **kwargs)
|
|
|
|
private_httpx = SimpleNamespace(**vars(httpx))
|
|
private_httpx.AsyncClient = client
|
|
monkeypatch.setattr(module, "get_app_config", config)
|
|
monkeypatch.setattr(module, "httpx", private_httpx)
|
|
return module.web_search_tool, threads
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_deepseek_search_initializes_off_loop(provider):
|
|
tool, threads = provider
|
|
result = json.loads(await tool.ainvoke({"query": "test"}))
|
|
assert result["error"] == "No results found"
|
|
assert len(threads) == 2
|
|
assert all(thread != threading.get_ident() for thread in threads)
|