Skip to content

Commit 2e3b3fd

Browse files
committed
feat(deepresearch): add stop action
1 parent 3ccf2ad commit 2e3b3fd

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

spring-ai-alibaba-deepresearch/src/main/java/com/alibaba/cloud/ai/example/deepresearch/controller/ChatController.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
import com.alibaba.cloud.ai.example.deepresearch.config.DeepResearchProperties;
2020
import com.alibaba.cloud.ai.example.deepresearch.controller.graph.GraphProcess;
2121
import com.alibaba.cloud.ai.example.deepresearch.controller.request.ChatRequestProcess;
22+
import com.alibaba.cloud.ai.example.deepresearch.model.ApiResponse;
2223
import com.alibaba.cloud.ai.example.deepresearch.model.req.ChatRequest;
2324
import com.alibaba.cloud.ai.example.deepresearch.model.req.FeedbackRequest;
2425
import com.alibaba.cloud.ai.example.deepresearch.model.req.GraphId;
25-
import com.alibaba.cloud.ai.example.deepresearch.model.response.ReportResponse;
2626
import com.alibaba.cloud.ai.example.deepresearch.util.SearchBeanUtil;
2727
import com.alibaba.cloud.ai.graph.CompileConfig;
2828
import com.alibaba.cloud.ai.graph.CompiledGraph;
@@ -138,10 +138,10 @@ public Flux<ServerSentEvent<String>> chatStream(@RequestBody(required = false) C
138138
});
139139
}
140140

141-
@DeleteMapping("/stop")
142-
public ReportResponse<?> stopGraph(@RequestBody GraphId graphId) {
143-
return graphProcess.stopGraph(graphId) ? ReportResponse.success(graphId.threadId(), "Success", null)
144-
: ReportResponse.error(graphId.threadId(), "Failure");
141+
@PostMapping("/stop")
142+
public ApiResponse<String> stopGraph(@RequestBody GraphId graphId) {
143+
return graphProcess.stopGraph(graphId) ? ApiResponse.success(graphId.threadId())
144+
: ApiResponse.error("Failure", graphId.threadId());
145145
}
146146

147147
@PostMapping(value = "/resume", produces = MediaType.TEXT_EVENT_STREAM_VALUE)

spring-ai-alibaba-deepresearch/src/main/java/com/alibaba/cloud/ai/example/deepresearch/controller/graph/GraphProcess.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,7 @@ public class GraphProcess {
6666
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
6767

6868
// 任务被中断时发送给前端的信息
69-
public static final String TASK_STOPPED_MESSAGE_TEMPLATE = """
70-
{
71-
"nodeName": "__END__",
72-
"graphId": %s,
73-
"displayTitle": "结束",
74-
"content": {
75-
"reason": "%s"
76-
}
77-
}
78-
""";
69+
public static final String TASK_STOPPED_MESSAGE_TEMPLATE = "{\"nodeName\": \"__END__\",\"graphId\": %s, \"displayTitle\": \"结束\", \"content\": { \"reason\": \"%s\"}} ";
7970

8071
// 线程数需要大于2
8172
private final ExecutorService executor = Executors.newFixedThreadPool(10);

0 commit comments

Comments
 (0)