refa: resolve tenant model refs consistently (#16744)

This commit is contained in:
buua436
2026-07-09 14:02:08 +08:00
committed by GitHub
parent 794fcc2517
commit 6a77523bf0
51 changed files with 300 additions and 225 deletions

View File

@@ -224,7 +224,7 @@ def test_async_ask_final_event_carries_decorated_answer(monkeypatch):
monkeypatch.setattr(dialog_service.KnowledgebaseService, "get_by_ids", lambda _ids: [_KB])
monkeypatch.setattr(
dialog_service,
"get_model_config_from_provider_instance",
"resolve_model_config",
lambda _tid, _type, _name: _LLM_CONFIG,
)
monkeypatch.setattr(dialog_service, "LLMBundle", lambda _tid, _cfg: chat_mdl)
@@ -269,7 +269,7 @@ def test_async_ask_delta_events_carry_incremental_text_only(monkeypatch):
monkeypatch.setattr(dialog_service.KnowledgebaseService, "get_by_ids", lambda _ids: [_KB])
monkeypatch.setattr(
dialog_service,
"get_model_config_from_provider_instance",
"resolve_model_config",
lambda _tid, _type, _name: _LLM_CONFIG,
)
monkeypatch.setattr(dialog_service, "LLMBundle", lambda _tid, _cfg: chat_mdl)
@@ -381,7 +381,7 @@ def _make_dialog(chat_mdl_stub):
top_n=6,
top_k=1024,
rerank_id="",
tenant_rerank_id=None
tenant_rerank_id=None,
)
@@ -400,10 +400,10 @@ def test_async_chat_final_event_carries_decorated_answer(monkeypatch):
retriever = _StubRetriever()
# Stub out the heavy service/model calls
monkeypatch.setattr(dialog_service, "get_model_type_by_name", lambda _tid, _llm_id: ["chat"])
monkeypatch.setattr(dialog_service, "resolve_model_type", lambda _tid, _llm_id: ["chat"])
monkeypatch.setattr(
dialog_service,
"get_model_config_from_provider_instance",
"resolve_model_config",
lambda _tid, _type, _llm_id: _LLM_CONFIG,
)
monkeypatch.setattr(
@@ -452,10 +452,10 @@ def test_async_chat_langfuse_uses_start_observation(monkeypatch):
chat_mdl = _StreamingChatModel(llm_answer)
retriever = _StubRetriever()
monkeypatch.setattr(dialog_service, "get_model_type_by_name", lambda _tid, _llm_id: ["chat"])
monkeypatch.setattr(dialog_service, "resolve_model_type", lambda _tid, _llm_id: ["chat"])
monkeypatch.setattr(
dialog_service,
"get_model_config_from_provider_instance",
"resolve_model_config",
lambda _tid, _type, _llm_id: _LLM_CONFIG,
)
monkeypatch.setattr(
@@ -515,10 +515,10 @@ def test_async_chat_langfuse_observation_includes_session_id(monkeypatch):
chat_mdl = _StreamingChatModel("Session traces should be grouped.")
retriever = _StubRetriever()
monkeypatch.setattr(dialog_service, "get_model_type_by_name", lambda _tid, _llm_id: ["chat"])
monkeypatch.setattr(dialog_service, "resolve_model_type", lambda _tid, _llm_id: ["chat"])
monkeypatch.setattr(
dialog_service,
"get_model_config_from_provider_instance",
"resolve_model_config",
lambda _tid, _type, _llm_id: _LLM_CONFIG,
)
monkeypatch.setattr(
@@ -573,7 +573,7 @@ def test_get_models_passes_langfuse_trace_context_to_llm_bundles(monkeypatch):
monkeypatch.setattr(dialog_service.KnowledgebaseService, "get_by_ids", lambda _ids: [_KB])
monkeypatch.setattr(
dialog_service,
"get_model_config_from_provider_instance",
"resolve_model_config",
lambda _tenant_id, model_type, _model_id: {**_LLM_CONFIG, "model_type": model_type},
)
monkeypatch.setattr(
@@ -614,10 +614,10 @@ def test_async_chat_continues_when_langfuse_observation_start_fails(monkeypatch)
chat_mdl = _StreamingChatModel(llm_answer)
retriever = _StubRetriever()
monkeypatch.setattr(dialog_service, "get_model_type_by_name", lambda _tid, _llm_id: ["chat"])
monkeypatch.setattr(dialog_service, "resolve_model_type", lambda _tid, _llm_id: ["chat"])
monkeypatch.setattr(
dialog_service,
"get_model_config_from_provider_instance",
"resolve_model_config",
lambda _tid, _type, _llm_id: _LLM_CONFIG,
)
monkeypatch.setattr(

View File

@@ -317,10 +317,10 @@ def test_async_chat_uses_all_docs_when_no_doc_ids_selected(monkeypatch):
)
monkeypatch.setattr(dialog_service.settings, "retriever", retriever, raising=False)
monkeypatch.setattr(dialog_service, "get_model_type_by_name", lambda _tid, _llm_id: ["chat"])
monkeypatch.setattr(dialog_service, "resolve_model_type", lambda _tid, _llm_id: ["chat"])
monkeypatch.setattr(
dialog_service,
"get_model_config_from_provider_instance",
"resolve_model_config",
lambda *_args, **_kwargs: {"llm_factory": "unit", "max_tokens": 4096, "model_type": "chat"},
)
monkeypatch.setattr(dialog_service.TenantLangfuseService, "filter_by_tenant", lambda **_kwargs: None)