mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-10 16:21:52 +08:00
【代码优化】增强 JDK17、JDK8 之间的兼容性
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.framework.ai.core.model.deepseek;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.chat.metadata.ChatGenerationMetadata;
|
||||
@@ -70,12 +71,12 @@ public class DeepSeekChatModel implements ChatModel {
|
||||
OpenAiApi.ChatCompletion chatCompletion = completionEntity.getBody();
|
||||
if (chatCompletion == null) {
|
||||
log.warn("No chat completion returned for prompt: {}", prompt);
|
||||
return new ChatResponse(List.of());
|
||||
return new ChatResponse(ListUtil.of());
|
||||
}
|
||||
List<OpenAiApi.ChatCompletion.Choice> choices = chatCompletion.choices();
|
||||
if (choices == null) {
|
||||
log.warn("No choices returned for prompt: {}", prompt);
|
||||
return new ChatResponse(List.of());
|
||||
return new ChatResponse(ListUtil.of());
|
||||
}
|
||||
|
||||
// 2. 转换 ChatResponse 返回
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.framework.ai.core.model.xinghuo;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.chat.metadata.ChatGenerationMetadata;
|
||||
@@ -72,12 +73,12 @@ public class XingHuoChatModel implements ChatModel {
|
||||
OpenAiApi.ChatCompletion chatCompletion = completionEntity.getBody();
|
||||
if (chatCompletion == null) {
|
||||
log.warn("No chat completion returned for prompt: {}", prompt);
|
||||
return new ChatResponse(List.of());
|
||||
return new ChatResponse(ListUtil.of());
|
||||
}
|
||||
List<OpenAiApi.ChatCompletion.Choice> choices = chatCompletion.choices();
|
||||
if (choices == null) {
|
||||
log.warn("No choices returned for prompt: {}", prompt);
|
||||
return new ChatResponse(List.of());
|
||||
return new ChatResponse(ListUtil.of());
|
||||
}
|
||||
|
||||
// 2. 转换 ChatResponse 返回
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.alibaba.cloud.ai.tongyi.audio.transcription;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import com.alibaba.cloud.ai.tongyi.audio.AudioTranscriptionModels;
|
||||
import com.alibaba.cloud.ai.tongyi.audio.transcription.api.AudioTranscriptionPrompt;
|
||||
import com.alibaba.cloud.ai.tongyi.audio.transcription.api.AudioTranscriptionResponse;
|
||||
@@ -82,7 +83,7 @@ public class TongYiAudioTranscriptionModel
|
||||
try {
|
||||
transcriptionParam = TranscriptionParam.builder()
|
||||
.model(AudioTranscriptionModels.Paraformer_V1)
|
||||
.fileUrls(List.of(String.valueOf(instructions.getURL())))
|
||||
.fileUrls(ListUtil.of(String.valueOf(instructions.getURL())))
|
||||
.build();
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.alibaba.cloud.ai.tongyi.chat;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import com.alibaba.cloud.ai.tongyi.common.exception.TongYiException;
|
||||
import com.alibaba.dashscope.aigc.conversation.ConversationParam;
|
||||
import com.alibaba.dashscope.aigc.generation.Generation;
|
||||
@@ -207,7 +208,7 @@ public class TongYiChatModel extends
|
||||
.getChoices()
|
||||
.get(0)
|
||||
));
|
||||
return new ChatResponse(List.of(gen));
|
||||
return new ChatResponse(ListUtil.of(gen));
|
||||
})
|
||||
)
|
||||
.publishOn(Schedulers.parallel());
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.alibaba.cloud.ai.tongyi.embedding;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import com.alibaba.cloud.ai.tongyi.common.exception.TongYiException;
|
||||
import com.alibaba.cloud.ai.tongyi.metadata.TongYiTextEmbeddingResponseMetadata;
|
||||
import com.alibaba.dashscope.embeddings.TextEmbedding;
|
||||
@@ -100,7 +101,7 @@ public class TongYiTextEmbeddingModel extends AbstractEmbeddingModel {
|
||||
|
||||
return this.call(
|
||||
new EmbeddingRequest(
|
||||
List.of(document.getFormattedContent(this.metadataMode)),
|
||||
ListUtil.of(document.getFormattedContent(this.metadataMode)),
|
||||
null)
|
||||
).getResults().stream()
|
||||
.map(Embedding::getOutput)
|
||||
|
Reference in New Issue
Block a user