mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
【todo】百度文言一心,解决 todo,删除 doOnComplete、增加 retryTemplate
This commit is contained in:
parent
e0d8ac74a4
commit
3a10fedddb
@ -85,22 +85,20 @@ public class YiYanChatClient implements ChatClient, StreamingChatClient {
|
|||||||
@Override
|
@Override
|
||||||
public Flux<ChatResponse> stream(Prompt prompt) {
|
public Flux<ChatResponse> stream(Prompt prompt) {
|
||||||
YiYanChatCompletionRequest request = this.createRequest(prompt, true);
|
YiYanChatCompletionRequest request = this.createRequest(prompt, true);
|
||||||
// TODO @fan:return this.retryTemplate.execute(ctx -> {
|
// TODO done @fan:return this.retryTemplate.execute(ctx -> {
|
||||||
// 调用 callWithFunctionSupport 发送请求
|
return retryTemplate.execute(ctx -> {
|
||||||
Flux<YiYanChatCompletionResponse> response = this.yiYanApi.chatCompletionStream(request);
|
// 调用 callWithFunctionSupport 发送请求
|
||||||
// TODO @fan:下面的 doOnComplete 是不是可以删除哈?
|
Flux<YiYanChatCompletionResponse> response = this.yiYanApi.chatCompletionStream(request);
|
||||||
response.doOnComplete(new Runnable() {
|
return response.map(chunk -> {
|
||||||
@Override
|
// System.err.println("---".concat(chunk.getResult()));
|
||||||
public void run() {
|
// TODO @fan:ChatResponseMetadata chatResponseMetadata
|
||||||
String a = ";";
|
return new ChatResponse(List.of(new Generation(chunk.getResult())));
|
||||||
}
|
});
|
||||||
});
|
|
||||||
return response.map(chunk -> {
|
|
||||||
// TODO @fan:ChatResponseMetadata chatResponseMetadata
|
|
||||||
return new ChatResponse(List.of(new Generation(chunk.getResult())));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private YiYanChatCompletionRequest createRequest(Prompt prompt, boolean stream) {
|
private YiYanChatCompletionRequest createRequest(Prompt prompt, boolean stream) {
|
||||||
// 参考 https://cloud.baidu.com/doc/WENXINWORKSHOP/s/clntwmv7t 文档,system 是独立字段
|
// 参考 https://cloud.baidu.com/doc/WENXINWORKSHOP/s/clntwmv7t 文档,system 是独立字段
|
||||||
// 1.1 获取 user 和 assistant
|
// 1.1 获取 user 和 assistant
|
||||||
|
Loading…
Reference in New Issue
Block a user