fix: 修复工作流入口标题与提示词校验
- 支持系统入口标题清空占位与下游引用展示同步 - 降低字段编辑触发的节点图重算和无效渲染 - 在保存及执行前拦截空白的大模型用户提示词
This commit is contained in:
@@ -436,6 +436,41 @@ public class WorkflowCheckServiceTest {
|
||||
assertHasCode(result, "SEARCH_DATASET_INVALID");
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证保存阶段拒绝空白的大模型用户提示词。
|
||||
*/
|
||||
@Test
|
||||
public void testSaveShouldBlockBlankLlmUserPrompt() throws Exception {
|
||||
WorkflowCheckService service = newService(new HashMap<>());
|
||||
JSONObject llmData = data("大模型");
|
||||
llmData.put("userPrompt", " ");
|
||||
String content = workflowJson(
|
||||
array(node("llm-1", "llmNode", null, llmData)),
|
||||
new JSONArray()
|
||||
);
|
||||
|
||||
WorkflowCheckResult result = service.checkContent(content, WorkflowCheckStage.SAVE, null);
|
||||
Assert.assertFalse(result.isPassed());
|
||||
assertHasCode(result, "LLM_USER_PROMPT_EMPTY");
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证保存阶段接受有效的大模型用户提示词。
|
||||
*/
|
||||
@Test
|
||||
public void testSaveShouldPassNonBlankLlmUserPrompt() throws Exception {
|
||||
WorkflowCheckService service = newService(new HashMap<>());
|
||||
JSONObject llmData = data("大模型");
|
||||
llmData.put("userPrompt", "{{start-1.user_input}}");
|
||||
String content = workflowJson(
|
||||
array(node("llm-1", "llmNode", null, llmData)),
|
||||
new JSONArray()
|
||||
);
|
||||
|
||||
WorkflowCheckResult result = service.checkContent(content, WorkflowCheckStage.SAVE, null);
|
||||
Assert.assertTrue(result.isPassed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreExecuteShouldBlockMissingStartOrEnd() throws Exception {
|
||||
WorkflowCheckService service = newService(new HashMap<>());
|
||||
@@ -453,6 +488,34 @@ public class WorkflowCheckServiceTest {
|
||||
assertHasCode(result, "END_NODE_MISSING");
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证执行前校验拒绝空的大模型用户提示词。
|
||||
*/
|
||||
@Test
|
||||
public void testPreExecuteShouldBlockEmptyLlmUserPrompt() throws Exception {
|
||||
WorkflowCheckService service = newService(new HashMap<>());
|
||||
JSONObject llmData = data("大模型");
|
||||
llmData.put("userPrompt", "");
|
||||
String content = workflowJson(
|
||||
array(
|
||||
node("s1", "startNode", null, data("开始")),
|
||||
node("llm-1", "llmNode", null, llmData),
|
||||
node("e1", "endNode", null, data("结束"))
|
||||
),
|
||||
array(
|
||||
edge("edge-1", "s1", "llm-1"),
|
||||
edge("edge-2", "llm-1", "e1")
|
||||
)
|
||||
);
|
||||
|
||||
WorkflowCheckResult result = service.checkContent(
|
||||
content,
|
||||
WorkflowCheckStage.PRE_EXECUTE,
|
||||
BigInteger.ONE);
|
||||
Assert.assertFalse(result.isPassed());
|
||||
assertHasCode(result, "LLM_USER_PROMPT_EMPTY");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreExecuteShouldPassForSourceOnlySearchDatasetNode() throws Exception {
|
||||
WorkflowCheckService service = newService(new HashMap<>());
|
||||
|
||||
Reference in New Issue
Block a user