Fix: search bot and verify model instance (#15588)

### What problem does this PR solve?

Fix:
- Verify provider with empty llm list in llm_factories.json
- Set search bot's chat_llm_name, use tenant default chat model as
default

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Lynn
2026-06-04 11:59:55 +08:00
committed by GitHub
parent bbacb31226
commit 597ac1e900
4 changed files with 71 additions and 35 deletions

View File

@@ -57,10 +57,16 @@ def _load_document_api(
async def _make_response(payload):
return SimpleNamespace(payload=payload, headers={})
def _login_required(func=None, **_kw):
if func is not None:
return func
return lambda f: f
_stub(
monkeypatch, "api.apps",
AUTH_JWT="JWT", AUTH_API="API", AUTH_BETA="BETA",
current_user=SimpleNamespace(id="caller-tenant"),
login_required=lambda func: func,
login_required=_login_required,
)
_stub(monkeypatch, "api.constants", FILE_NAME_LEN_LIMIT=128, IMG_BASE64_PREFIX="data:image/")
_stub(
@@ -141,6 +147,11 @@ def _load_document_api(
apply_safe_file_response_headers=lambda *_a, **_k: None,
)
_stub(monkeypatch, "common.ssrf_guard", assert_url_is_safe=lambda *_a, **_k: None)
_stub(
monkeypatch, "rag.nlp",
search=SimpleNamespace(index_name=lambda *_a, **_k: "index"),
)
_stub(monkeypatch, "rag.nlp.search", index_name=lambda *_a, **_k: "index")
quart_stub = ModuleType("quart")
quart_stub.request = SimpleNamespace(method="GET", args={})
@@ -208,13 +219,13 @@ class TestDocumentPreviewAccessCheck:
def test_missing_doc_returns_not_found(self, monkeypatch: pytest.MonkeyPatch) -> None:
"""Missing-doc behaviour is unchanged: same 'Document not found!' shape."""
def _accessible_should_not_be_called(*_a, **_k):
raise AssertionError("accessible() must not be called for a missing doc")
def _accessible_returns_false(*_a, **_k):
return False
module = _load_document_api(
monkeypatch,
doc_get_by_id=(False, None),
accessible_fn=_accessible_should_not_be_called,
accessible_fn=_accessible_returns_false,
storage_get=lambda *_a, **_k: b"",
)