Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public Map<String, Object> apply(OverAllState state) throws Exception {
String systemPrompt = PromptConstant.getPythonAnalyzePromptTemplate()
.render(Map.of("python_output", pythonOutput, "user_query", userQuery));

Flux<ChatResponse> pythonAnalyzeFlux = llmService.callSystem(systemPrompt);
Flux<ChatResponse> pythonAnalyzeFlux = llmService.callUser(systemPrompt);

Flux<GraphResponse<StreamingOutput>> generator = FluxUtil.createStreamingGeneratorWithMessages(this.getClass(),
state, "正在分析代码运行结果...\n", "\n结果分析完成。", aiResponse -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void apply_validOutput_returnsAnalysis() throws Exception {
OverAllState state = createTestState();
setupBasicState(state);

when(llmService.callSystem(anyString()))
when(llmService.callUser(anyString()))
.thenReturn(Flux.just(ChatResponseUtil.createPureResponse("销售总额为15000元,平均销售额3000元")));

Map<String, Object> result = pythonAnalyzeNode.apply(state);
Expand All @@ -116,7 +116,7 @@ void apply_llmFailure_throwsException() {
OverAllState state = createTestState();
setupBasicState(state);

when(llmService.callSystem(anyString())).thenThrow(new RuntimeException("LLM service unavailable"));
when(llmService.callUser(anyString())).thenThrow(new RuntimeException("LLM service unavailable"));

assertThrows(RuntimeException.class, () -> pythonAnalyzeNode.apply(state));
}
Expand All @@ -139,7 +139,7 @@ void apply_emptyPythonOutput_returnsMinimalAnalysis() throws Exception {
state.updateState(Map.of(PYTHON_EXECUTE_NODE_OUTPUT, "", PLAN_CURRENT_STEP, 1, QUERY_ENHANCE_NODE_OUTPUT,
TEST_QUERY_ENHANCE, PLANNER_NODE_OUTPUT, TEST_PLAN_JSON));

when(llmService.callSystem(anyString()))
when(llmService.callUser(anyString()))
.thenReturn(Flux.just(ChatResponseUtil.createPureResponse("Python输出为空,无法进行深入分析")));

Map<String, Object> result = pythonAnalyzeNode.apply(state);
Expand All @@ -156,7 +156,7 @@ void apply_updatesExecutionResults_correctly() throws Exception {
existingResults.put("step_1", "{\"data\": []}");
state.updateState(Map.of(SQL_EXECUTE_NODE_OUTPUT, existingResults));

when(llmService.callSystem(anyString()))
when(llmService.callUser(anyString()))
.thenReturn(Flux.just(ChatResponseUtil.createPureResponse("分析完成:数据为空")));

Map<String, Object> result = pythonAnalyzeNode.apply(state);
Expand All @@ -171,7 +171,7 @@ void apply_invalidOutput_throwsOrHandlesGracefully() throws Exception {
state.updateState(Map.of(PYTHON_EXECUTE_NODE_OUTPUT, "{{{{invalid json garbage}}}}", PLAN_CURRENT_STEP, 1,
QUERY_ENHANCE_NODE_OUTPUT, TEST_QUERY_ENHANCE, PLANNER_NODE_OUTPUT, TEST_PLAN_JSON));

when(llmService.callSystem(anyString()))
when(llmService.callUser(anyString()))
.thenReturn(Flux.just(ChatResponseUtil.createPureResponse("无法解析Python输出")));

Map<String, Object> result = pythonAnalyzeNode.apply(state);
Expand All @@ -184,7 +184,7 @@ void apply_timeoutInLlmAnalysis_returnsResultWithGenerator() throws Exception {
OverAllState state = createTestState();
setupBasicState(state);

when(llmService.callSystem(anyString())).thenReturn(Flux.error(new RuntimeException("LLM analysis timeout")));
when(llmService.callUser(anyString())).thenReturn(Flux.error(new RuntimeException("LLM analysis timeout")));

Map<String, Object> result = pythonAnalyzeNode.apply(state);
assertNotNull(result);
Expand Down
Loading