refactor(yudao-module-llm): 优化流式聊天接口的异步处理逻辑
-移除了未使用的代码块,简化了代码结构 - 保留了 SseEmitter 的创建和异步处理逻辑 - 删除了冗余的注释和未使用的 ExecutorService 相关代码
This commit is contained in:
parent
864b25e919
commit
8923987afb
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user