From 8923987afb811d7a708b9e4ef58d80666f0ebfb9 Mon Sep 17 00:00:00 2001 From: Liuyang <2746366019@qq.com> Date: Thu, 13 Mar 2025 11:01:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(yudao-module-llm):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=B5=81=E5=BC=8F=E8=81=8A=E5=A4=A9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E6=AD=A5=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -移除了未使用的代码块,简化了代码结构 - 保留了 SseEmitter 的创建和异步处理逻辑 - 删除了冗余的注释和未使用的 ExecutorService 相关代码 --- .../conversation/ConversationController.java | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/conversation/ConversationController.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/conversation/ConversationController.java index 555951f8b..cb4cd11ec 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/conversation/ConversationController.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/conversation/ConversationController.java @@ -109,27 +109,8 @@ public class ConversationController { @PostMapping("/stream-chat") public SseEmitter streamChat (@Valid @RequestBody ChatReqVO chatReqVO, HttpServletResponse response) { log.info("收到对话推理请求,请求参数: {}", chatReqVO); - SseEmitter emitter = new SseEmitter(120_000L); - // ExecutorService executor = Executors.newSingleThreadExecutor(); - // try { - // executor.execute(() -> { - // try { - // conversationService.chatStream(chatReqVO, emitter, response); - // } catch (Exception e) { - // emitter.completeWithError(e); - // } finally { - // executor.shutdown(); - // } - // }); - // } catch (Exception e) { - // log.error("处理对话推理请求时发生异常", e); - // try { - // emitter.completeWithError(e); - // } catch (Exception ex) { - // log.error("无法完成 SseEmitter 错误处理", ex); - // } - // } - // log.info("返回 SseEmitter 对象,准备进行流式响应"); + SseEmitter emitter = new SseEmitter(120_0000L); + // 异步处理,避免阻塞主线程 CompletableFuture.runAsync(() -> { try {