From a3530555ca82d259fc4cde2f84ece4467a39553f Mon Sep 17 00:00:00 2001 From: cherishsince Date: Sun, 14 Apr 2024 15:52:35 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0=20chat=20=E5=92=8C?= =?UTF-8?q?=20chatStream?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{app/chat => }/AiChatRoleController.java | 4 +- .../module/ai/controller/ChatController.java | 76 +++++++++++++++++++ .../controller/admin/chat/ChatController.java | 34 --------- .../ai/controller/admin/package-info.java | 5 -- .../ai/controller/app/package-info.java | 5 -- .../module/ai/service/ChatRoleService.java | 2 +- .../{ => impl}/ChatRoleServiceImpl.java | 5 +- .../yudao/module/ai/service/package-info.java | 5 -- .../admin/chat => }/vo/AiChatReqVO.java | 2 +- .../app/chat => }/vo/ChatRoleAddReq.java | 2 +- .../app/chat => }/vo/ChatRoleListReq.java | 2 +- .../app/chat => }/vo/ChatRoleListRes.java | 2 +- .../app/chat => }/vo/ChatRoleUpdateReq.java | 2 +- .../vo/ChatRoleUpdateVisibilityReq.java | 2 +- .../src/main/resources/http/chat.http | 13 +--- .../main/resources/http/http-client.env.json | 2 +- .../ai/chatyiyan/YiYanChatClient.java | 6 ++ 17 files changed, 98 insertions(+), 71 deletions(-) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/{app/chat => }/AiChatRoleController.java (93%) create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatController.java delete mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/ChatController.java delete mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/package-info.java delete mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/package-info.java rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/{ => impl}/ChatRoleServiceImpl.java (83%) delete mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/package-info.java rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/{controller/admin/chat => }/vo/AiChatReqVO.java (92%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/{controller/app/chat => }/vo/ChatRoleAddReq.java (86%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/{controller/app/chat => }/vo/ChatRoleListReq.java (86%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/{controller/app/chat => }/vo/ChatRoleListRes.java (75%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/{controller/app/chat => }/vo/ChatRoleUpdateReq.java (86%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/{controller/app/chat => }/vo/ChatRoleUpdateVisibilityReq.java (87%) diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/AiChatRoleController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatRoleController.java similarity index 93% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/AiChatRoleController.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatRoleController.java index 785abdc12..543754e91 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/AiChatRoleController.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatRoleController.java @@ -1,8 +1,8 @@ -package cn.iocoder.yudao.module.ai.controller.app.chat; +package cn.iocoder.yudao.module.ai.controller; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.ai.controller.app.chat.vo.*; import cn.iocoder.yudao.module.ai.service.ChatRoleService; +import cn.iocoder.yudao.module.ai.vo.*; import io.swagger.v3.oas.annotations.Operation; import lombok.AllArgsConstructor; import org.springframework.validation.annotation.Validated; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatController.java new file mode 100644 index 000000000..a46574046 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatController.java @@ -0,0 +1,76 @@ +package cn.iocoder.yudao.module.ai.controller; + +import cn.hutool.core.exceptions.ExceptionUtil; +import cn.iocoder.yudao.framework.ai.chat.ChatResponse; +import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt; +import cn.iocoder.yudao.framework.ai.config.AiClient; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; +import reactor.core.publisher.Flux; + +import java.io.IOException; +import java.util.function.Consumer; + +/** + * @author fansili + * @time 2024/4/13 17:44 + * @since 1.0 + */ +@Tag(name = "AI模块") +@RestController +@RequestMapping("/ai") +@Slf4j +@AllArgsConstructor +public class ChatController { + + + + @Autowired + private AiClient aiClient; + + @GetMapping("/chat") + public CommonResult chat(@RequestParam("prompt") String prompt) { + ChatResponse callRes = aiClient.call(new Prompt(prompt), "qianWen"); + return CommonResult.success(callRes.getResult().getOutput().getContent()); + } + + // TODO @芋艿:调用这个方法异常,Unable to handle the Spring Security Exception because the response is already committed. + @GetMapping(value = "/chatStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE) + public SseEmitter chatStream(@RequestParam("prompt") String prompt) { + Utf8SseEmitter sseEmitter = new Utf8SseEmitter(); + Flux streamResponse = aiClient.stream(new Prompt(prompt), "qianWen"); + streamResponse.subscribe( + new Consumer() { + @Override + public void accept(ChatResponse chatResponse) { + String content = chatResponse.getResults().get(0).getOutput().getContent(); + try { + sseEmitter.send(content, MediaType.APPLICATION_JSON); + } catch (IOException e) { + log.error("发送异常{}", ExceptionUtil.getMessage(e)); + // 如果不是因为关闭而抛出异常,则重新连接 + sseEmitter.completeWithError(e); + } + } + }, + error -> { + // + log.error("subscribe错误 {}", ExceptionUtil.getMessage(error)); + }, + () -> { + log.info("发送完成!"); + sseEmitter.complete(); + } + ); + return sseEmitter; + } +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/ChatController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/ChatController.java deleted file mode 100644 index 90710a3dd..000000000 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/ChatController.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.ai.controller.admin.chat; - -import cn.iocoder.yudao.framework.ai.chat.ChatResponse; -import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt; -import cn.iocoder.yudao.framework.ai.config.AiClient; -import cn.iocoder.yudao.framework.ai.config.YudaoAiClient; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -/** - * @author fansili - * @since 1.0 - * @time 2024/4/13 17:44 - */ -@Tag(name = "AI模块") -@RestController -@RequestMapping("/admin-api/ai") -@Slf4j -@AllArgsConstructor -public class ChatController { - - private final AiClient aiClient; - - @PostMapping("/chat") - public CommonResult chat(@RequestParam("prompt") String prompt) { - ChatResponse callRes = aiClient.call(new Prompt(prompt), "qianWen"); - return CommonResult.success(callRes.getResult().getOutput().getContent()); - } - -} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/package-info.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/package-info.java deleted file mode 100644 index 81fe7e4bb..000000000 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * author: fansili - * time: 2024/3/4 13:08 - */ -package cn.iocoder.yudao.module.ai.controller.admin; \ No newline at end of file diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/package-info.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/package-info.java deleted file mode 100644 index a7675c99b..000000000 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * author: fansili - * time: 2024/3/4 13:08 - */ -package cn.iocoder.yudao.module.ai.controller.app; \ No newline at end of file diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatRoleService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatRoleService.java index e91429715..c4c46a5ef 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatRoleService.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatRoleService.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.ai.service; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.ai.controller.app.chat.vo.*; +import cn.iocoder.yudao.module.ai.vo.*; /** * chat 角色 diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatRoleServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatRoleServiceImpl.java similarity index 83% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatRoleServiceImpl.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatRoleServiceImpl.java index dc839c4b3..310e8f766 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatRoleServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatRoleServiceImpl.java @@ -1,7 +1,8 @@ -package cn.iocoder.yudao.module.ai.service; +package cn.iocoder.yudao.module.ai.service.impl; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.ai.controller.app.chat.vo.*; +import cn.iocoder.yudao.module.ai.service.ChatRoleService; +import cn.iocoder.yudao.module.ai.vo.*; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/package-info.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/package-info.java deleted file mode 100644 index 671d5534f..000000000 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * author: fansili - * time: 2024/3/3 18:14 - */ -package cn.iocoder.yudao.module.ai.service; \ No newline at end of file diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/vo/AiChatReqVO.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatReqVO.java similarity index 92% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/vo/AiChatReqVO.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatReqVO.java index 881982a57..eafbecda5 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/vo/AiChatReqVO.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.ai.controller.admin.chat.vo; +package cn.iocoder.yudao.module.ai.vo; import cn.iocoder.yudao.module.ai.enums.OpenAiModelEnum; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleAddReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleAddReq.java similarity index 86% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleAddReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleAddReq.java index b1c08e286..2c2dfcbff 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleAddReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleAddReq.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.ai.controller.app.chat.vo; +package cn.iocoder.yudao.module.ai.vo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListReq.java similarity index 86% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListReq.java index 18f3d46c0..32a028b94 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListReq.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.ai.controller.app.chat.vo; +package cn.iocoder.yudao.module.ai.vo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListRes.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListRes.java similarity index 75% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListRes.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListRes.java index 6480296f2..8423c66b9 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListRes.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListRes.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.ai.controller.app.chat.vo; +package cn.iocoder.yudao.module.ai.vo; import lombok.Data; import lombok.experimental.Accessors; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateReq.java similarity index 86% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateReq.java index 0874fd691..2f98e4f79 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateReq.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.ai.controller.app.chat.vo; +package cn.iocoder.yudao.module.ai.vo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateVisibilityReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateVisibilityReq.java similarity index 87% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateVisibilityReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateVisibilityReq.java index fc76b5d4c..3ae25f4ab 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateVisibilityReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateVisibilityReq.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.ai.controller.app.chat.vo; +package cn.iocoder.yudao.module.ai.vo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/resources/http/chat.http b/yudao-module-ai/yudao-module-ai-biz/src/main/resources/http/chat.http index 03c829b85..95a928480 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/resources/http/chat.http +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/resources/http/chat.http @@ -16,24 +16,17 @@ tenant-id: 1 } ### chat call -POST {{baseUrl}}/admin-api/ai/chat?prompt=中国怎么样 +GET {{baseUrl}}/ai/chat?prompt=中国怎么样 tenant-id: 1 Authorization: {{token}} + ### chat call -POST {{baseUrl}}/ai-api/chat -tenant-id: 1 -Authorization: {{token}} - - -### chat call -GET {{baseUrl}}/chat-role/list +GET {{baseUrl}}/ai/chatStream?prompt=苹果是什么颜色? tenant-id: 1 Authorization: {{token}} - - diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/resources/http/http-client.env.json b/yudao-module-ai/yudao-module-ai-biz/src/main/resources/http/http-client.env.json index 5fd488f50..5beca6fd1 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/resources/http/http-client.env.json +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/resources/http/http-client.env.json @@ -1,6 +1,6 @@ { "dev": { "baseUrl": "http://127.0.0.1:48080", - "token": "Bearer 07390ff2824a4798bcfd7f9395092181" + "token": "Bearer cff0ce99ddb14ea89c62ff4de1c31180" } } \ No newline at end of file diff --git a/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/chatyiyan/YiYanChatClient.java b/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/chatyiyan/YiYanChatClient.java index c4be256da..fae550da8 100644 --- a/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/chatyiyan/YiYanChatClient.java +++ b/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/chatyiyan/YiYanChatClient.java @@ -82,6 +82,12 @@ public class YiYanChatClient implements ChatClient, StreamingChatClient { YiYanChatCompletionRequest request = this.createRequest(prompt, true); // 调用 callWithFunctionSupport 发送请求 Flux response = this.yiYanApi.chatCompletionStream(request); + response.doOnComplete(new Runnable() { + @Override + public void run() { + String a = ";"; + } + }); return response.map(res -> new ChatResponse(List.of(new Generation(res.getResult())))); }