feat(assistant): 基于聚合结果动态回答并支持对话新增分析列

This commit is contained in:
Jayway Liu
2026-11-01 10:54:57 +08:00
parent 31e59a426d
commit 7ff1070dc3
4 changed files with 880 additions and 93 deletions
+5 -5
View File
@@ -92,7 +92,7 @@ def test_model_intent_polls_in_progress_and_retries_invalid_response(workspace,
{"action": "anomalies", "metric": "revenue", "group": "department", "filters": []}
)
with patch("finance.assistant.httpx.Client", ClientMock):
with patch("finance.ai.httpx.Client", ClientMock):
intent = model_intent("看异常", ds, {"metric": "revenue", "group": "department", "filters": {}})
assert intent["action"] == "anomalies"
@@ -228,7 +228,7 @@ def test_assistant_uses_org_db_config(workspace):
},
content_type="application/json",
)
with patch("finance.assistant.httpx.Client") as http:
with patch("finance.ai.httpx.Client") as http:
http.return_value.__enter__.return_value.post.return_value = completed_response()
response = client.post(
f"/api/datasets/{ds.pk}/assistant",
@@ -290,7 +290,7 @@ def test_model_intent_accepts_only_valid_dimensions_and_sends_no_rows(workspace,
],
}
with patch("finance.assistant.httpx.Client") as http:
with patch("finance.ai.httpx.Client") as http:
http.return_value.__enter__.return_value.post.return_value = Response()
intent = model_intent("看儿科收入", ds, {"metric": "revenue", "group": "department", "filters": {}})
@@ -331,12 +331,12 @@ def test_model_intent_rejects_unknown_filter_and_incomplete_provider_response(wo
}
response = Response()
with patch("finance.assistant.httpx.Client") as http:
with patch("finance.ai.httpx.Client") as http:
http.return_value.__enter__.return_value.post.return_value = response
with pytest.raises(Exception, match="无效意图"):
model_intent("分析收入", ds, {"metric": "revenue", "group": "department", "filters": {}})
with patch("finance.assistant.httpx.Client") as http:
with patch("finance.ai.httpx.Client") as http:
http.return_value.__enter__.return_value.post.return_value = type(
"Response",
(),