Commit 1875a49ba39e05740b935061a3b0c96b071d8e15
1 parent
17f79702
重命名 modal
Showing
3 changed files
with
7 additions
and
6 deletions
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/chatxinghuo/XingHuoChatClient.java
| ... | ... | @@ -5,6 +5,7 @@ import cn.hutool.core.exceptions.ExceptionUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.ai.chat.*; |
| 6 | 6 | import cn.iocoder.yudao.framework.ai.chat.prompt.ChatOptions; |
| 7 | 7 | import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt; |
| 8 | +import cn.iocoder.yudao.framework.ai.chatxinghuo.api.XingHuoApi; | |
| 8 | 9 | import cn.iocoder.yudao.framework.ai.chatxinghuo.api.XingHuoChatCompletion; |
| 9 | 10 | import cn.iocoder.yudao.framework.ai.chatxinghuo.api.XingHuoChatCompletionRequest; |
| 10 | 11 | import lombok.extern.slf4j.Slf4j; |
| ... | ... | @@ -69,7 +70,7 @@ public class XingHuoChatClient implements ChatClient, StreamingChatClient { |
| 69 | 70 | // 创建 request 请求,stream模式需要供应商支持 |
| 70 | 71 | XingHuoChatCompletionRequest request = this.createRequest(prompt, chatOptions); |
| 71 | 72 | // 调用 callWithFunctionSupport 发送请求 |
| 72 | - ResponseEntity<XingHuoChatCompletion> response = xingHuoApi.chatCompletionEntity(request, chatOptions.getDomain()); | |
| 73 | + ResponseEntity<XingHuoChatCompletion> response = xingHuoApi.chatCompletionEntity(request, chatOptions.getChatModel()); | |
| 73 | 74 | // 获取结果封装 ChatResponse |
| 74 | 75 | return new ChatResponse(List.of(new Generation(response.getBody().getPayload().getChoices().getText().get(0).getContent()))); |
| 75 | 76 | }); |
| ... | ... | @@ -82,7 +83,7 @@ public class XingHuoChatClient implements ChatClient, StreamingChatClient { |
| 82 | 83 | // 创建 request 请求,stream模式需要供应商支持 |
| 83 | 84 | XingHuoChatCompletionRequest request = this.createRequest(prompt, chatOptions); |
| 84 | 85 | // 发送请求 |
| 85 | - Flux<XingHuoChatCompletion> response = this.xingHuoApi.chatCompletionStream(request, chatOptions.getDomain()); | |
| 86 | + Flux<XingHuoChatCompletion> response = this.xingHuoApi.chatCompletionStream(request, chatOptions.getChatModel()); | |
| 86 | 87 | return response.map(res -> { |
| 87 | 88 | String content = res.getPayload().getChoices().getText().stream() |
| 88 | 89 | .map(item -> item.getContent()).collect(Collectors.joining()); |
| ... | ... | @@ -113,7 +114,7 @@ public class XingHuoChatClient implements ChatClient, StreamingChatClient { |
| 113 | 114 | // 创建 params |
| 114 | 115 | XingHuoChatCompletionRequest.Parameter.Chat chatParameter = new XingHuoChatCompletionRequest.Parameter.Chat(); |
| 115 | 116 | BeanUtil.copyProperties(xingHuoOptions, chatParameter); |
| 116 | - chatParameter.setDomain(xingHuoOptions.getDomain().getValue()); | |
| 117 | + chatParameter.setDomain(xingHuoOptions.getChatModel().getValue()); | |
| 117 | 118 | XingHuoChatCompletionRequest.Parameter parameter = new XingHuoChatCompletionRequest.Parameter().setChat(chatParameter); |
| 118 | 119 | // 创建 payload text 信息 |
| 119 | 120 | XingHuoChatCompletionRequest.Payload.Message.Text text = new XingHuoChatCompletionRequest.Payload.Message.Text(); | ... | ... |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/chatxinghuo/XingHuoOptions.java
| ... | ... | @@ -24,7 +24,7 @@ public class XingHuoOptions implements ChatOptions { |
| 24 | 24 | * generalv3.5指向V3.5版本; |
| 25 | 25 | * 注意:不同的取值对应的url也不一样! |
| 26 | 26 | */ |
| 27 | - private XingHuoChatModel domain = XingHuoChatModel.XING_HUO_3_5; | |
| 27 | + private XingHuoChatModel chatModel = XingHuoChatModel.XING_HUO_3_5; | |
| 28 | 28 | /** |
| 29 | 29 | * 取值范围 (0,1] ,默认值0.5 |
| 30 | 30 | */ | ... | ... |
yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/chat/XingHuoChatClientTests.java
| 1 | 1 | package cn.iocoder.yudao.framework.ai.chat; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt; |
| 4 | -import cn.iocoder.yudao.framework.ai.chatxinghuo.XingHuoApi; | |
| 5 | 4 | import cn.iocoder.yudao.framework.ai.chatxinghuo.XingHuoChatClient; |
| 6 | 5 | import cn.iocoder.yudao.framework.ai.chatxinghuo.XingHuoChatModel; |
| 7 | 6 | import cn.iocoder.yudao.framework.ai.chatxinghuo.XingHuoOptions; |
| 7 | +import cn.iocoder.yudao.framework.ai.chatxinghuo.api.XingHuoApi; | |
| 8 | 8 | import org.junit.Before; |
| 9 | 9 | import org.junit.Test; |
| 10 | 10 | import reactor.core.publisher.Flux; |
| ... | ... | @@ -31,7 +31,7 @@ public class XingHuoChatClientTests { |
| 31 | 31 | "cb6415c19d6162cda07b47316fcb0416", |
| 32 | 32 | "Y2JiYTIxZjA3MDMxMjNjZjQzYzVmNzdh" |
| 33 | 33 | ), |
| 34 | - new XingHuoOptions().setDomain(XingHuoChatModel.XING_HUO_3_5) | |
| 34 | + new XingHuoOptions().setChatModel(XingHuoChatModel.XING_HUO_3_5) | |
| 35 | 35 | ); |
| 36 | 36 | } |
| 37 | 37 | ... | ... |