重命名 modal
This commit is contained in:
parent
17f7970259
commit
1875a49ba3
|
@ -5,6 +5,7 @@ import cn.hutool.core.exceptions.ExceptionUtil;
|
|||
import cn.iocoder.yudao.framework.ai.chat.*;
|
||||
import cn.iocoder.yudao.framework.ai.chat.prompt.ChatOptions;
|
||||
import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt;
|
||||
import cn.iocoder.yudao.framework.ai.chatxinghuo.api.XingHuoApi;
|
||||
import cn.iocoder.yudao.framework.ai.chatxinghuo.api.XingHuoChatCompletion;
|
||||
import cn.iocoder.yudao.framework.ai.chatxinghuo.api.XingHuoChatCompletionRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -69,7 +70,7 @@ public class XingHuoChatClient implements ChatClient, StreamingChatClient {
|
|||
// 创建 request 请求,stream模式需要供应商支持
|
||||
XingHuoChatCompletionRequest request = this.createRequest(prompt, chatOptions);
|
||||
// 调用 callWithFunctionSupport 发送请求
|
||||
ResponseEntity<XingHuoChatCompletion> response = xingHuoApi.chatCompletionEntity(request, chatOptions.getDomain());
|
||||
ResponseEntity<XingHuoChatCompletion> response = xingHuoApi.chatCompletionEntity(request, chatOptions.getChatModel());
|
||||
// 获取结果封装 ChatResponse
|
||||
return new ChatResponse(List.of(new Generation(response.getBody().getPayload().getChoices().getText().get(0).getContent())));
|
||||
});
|
||||
|
@ -82,7 +83,7 @@ public class XingHuoChatClient implements ChatClient, StreamingChatClient {
|
|||
// 创建 request 请求,stream模式需要供应商支持
|
||||
XingHuoChatCompletionRequest request = this.createRequest(prompt, chatOptions);
|
||||
// 发送请求
|
||||
Flux<XingHuoChatCompletion> response = this.xingHuoApi.chatCompletionStream(request, chatOptions.getDomain());
|
||||
Flux<XingHuoChatCompletion> response = this.xingHuoApi.chatCompletionStream(request, chatOptions.getChatModel());
|
||||
return response.map(res -> {
|
||||
String content = res.getPayload().getChoices().getText().stream()
|
||||
.map(item -> item.getContent()).collect(Collectors.joining());
|
||||
|
@ -113,7 +114,7 @@ public class XingHuoChatClient implements ChatClient, StreamingChatClient {
|
|||
// 创建 params
|
||||
XingHuoChatCompletionRequest.Parameter.Chat chatParameter = new XingHuoChatCompletionRequest.Parameter.Chat();
|
||||
BeanUtil.copyProperties(xingHuoOptions, chatParameter);
|
||||
chatParameter.setDomain(xingHuoOptions.getDomain().getValue());
|
||||
chatParameter.setDomain(xingHuoOptions.getChatModel().getValue());
|
||||
XingHuoChatCompletionRequest.Parameter parameter = new XingHuoChatCompletionRequest.Parameter().setChat(chatParameter);
|
||||
// 创建 payload text 信息
|
||||
XingHuoChatCompletionRequest.Payload.Message.Text text = new XingHuoChatCompletionRequest.Payload.Message.Text();
|
||||
|
|
|
@ -24,7 +24,7 @@ public class XingHuoOptions implements ChatOptions {
|
|||
* generalv3.5指向V3.5版本;
|
||||
* 注意:不同的取值对应的url也不一样!
|
||||
*/
|
||||
private XingHuoChatModel domain = XingHuoChatModel.XING_HUO_3_5;
|
||||
private XingHuoChatModel chatModel = XingHuoChatModel.XING_HUO_3_5;
|
||||
/**
|
||||
* 取值范围 (0,1] ,默认值0.5
|
||||
*/
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package cn.iocoder.yudao.framework.ai.chat;
|
||||
|
||||
import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt;
|
||||
import cn.iocoder.yudao.framework.ai.chatxinghuo.XingHuoApi;
|
||||
import cn.iocoder.yudao.framework.ai.chatxinghuo.XingHuoChatClient;
|
||||
import cn.iocoder.yudao.framework.ai.chatxinghuo.XingHuoChatModel;
|
||||
import cn.iocoder.yudao.framework.ai.chatxinghuo.XingHuoOptions;
|
||||
import cn.iocoder.yudao.framework.ai.chatxinghuo.api.XingHuoApi;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
@ -31,7 +31,7 @@ public class XingHuoChatClientTests {
|
|||
"cb6415c19d6162cda07b47316fcb0416",
|
||||
"Y2JiYTIxZjA3MDMxMjNjZjQzYzVmNzdh"
|
||||
),
|
||||
new XingHuoOptions().setDomain(XingHuoChatModel.XING_HUO_3_5)
|
||||
new XingHuoOptions().setChatModel(XingHuoChatModel.XING_HUO_3_5)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue