pull/137/MERGE
YunaiV 2024-08-26 12:38:48 +08:00
commit f63b75241b
6 changed files with 14 additions and 8 deletions

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.framework.ai.core.model.deepseek; package cn.iocoder.yudao.framework.ai.core.model.deepseek;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.metadata.ChatGenerationMetadata; import org.springframework.ai.chat.metadata.ChatGenerationMetadata;
@ -70,12 +71,12 @@ public class DeepSeekChatModel implements ChatModel {
OpenAiApi.ChatCompletion chatCompletion = completionEntity.getBody(); OpenAiApi.ChatCompletion chatCompletion = completionEntity.getBody();
if (chatCompletion == null) { if (chatCompletion == null) {
log.warn("No chat completion returned for prompt: {}", prompt); 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(); List<OpenAiApi.ChatCompletion.Choice> choices = chatCompletion.choices();
if (choices == null) { if (choices == null) {
log.warn("No choices returned for prompt: {}", prompt); log.warn("No choices returned for prompt: {}", prompt);
return new ChatResponse(List.of()); return new ChatResponse(ListUtil.of());
} }
// 2. 转换 ChatResponse 返回 // 2. 转换 ChatResponse 返回

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.framework.ai.core.model.xinghuo; package cn.iocoder.yudao.framework.ai.core.model.xinghuo;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.metadata.ChatGenerationMetadata; import org.springframework.ai.chat.metadata.ChatGenerationMetadata;
@ -72,12 +73,12 @@ public class XingHuoChatModel implements ChatModel {
OpenAiApi.ChatCompletion chatCompletion = completionEntity.getBody(); OpenAiApi.ChatCompletion chatCompletion = completionEntity.getBody();
if (chatCompletion == null) { if (chatCompletion == null) {
log.warn("No chat completion returned for prompt: {}", prompt); 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(); List<OpenAiApi.ChatCompletion.Choice> choices = chatCompletion.choices();
if (choices == null) { if (choices == null) {
log.warn("No choices returned for prompt: {}", prompt); log.warn("No choices returned for prompt: {}", prompt);
return new ChatResponse(List.of()); return new ChatResponse(ListUtil.of());
} }
// 2. 转换 ChatResponse 返回 // 2. 转换 ChatResponse 返回

View File

@ -16,6 +16,7 @@
package com.alibaba.cloud.ai.tongyi.audio.transcription; 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.AudioTranscriptionModels;
import com.alibaba.cloud.ai.tongyi.audio.transcription.api.AudioTranscriptionPrompt; import com.alibaba.cloud.ai.tongyi.audio.transcription.api.AudioTranscriptionPrompt;
import com.alibaba.cloud.ai.tongyi.audio.transcription.api.AudioTranscriptionResponse; import com.alibaba.cloud.ai.tongyi.audio.transcription.api.AudioTranscriptionResponse;
@ -82,7 +83,7 @@ public class TongYiAudioTranscriptionModel
try { try {
transcriptionParam = TranscriptionParam.builder() transcriptionParam = TranscriptionParam.builder()
.model(AudioTranscriptionModels.Paraformer_V1) .model(AudioTranscriptionModels.Paraformer_V1)
.fileUrls(List.of(String.valueOf(instructions.getURL()))) .fileUrls(ListUtil.of(String.valueOf(instructions.getURL())))
.build(); .build();
} }
catch (IOException e) { catch (IOException e) {

View File

@ -16,6 +16,7 @@
package com.alibaba.cloud.ai.tongyi.chat; 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.cloud.ai.tongyi.common.exception.TongYiException;
import com.alibaba.dashscope.aigc.conversation.ConversationParam; import com.alibaba.dashscope.aigc.conversation.ConversationParam;
import com.alibaba.dashscope.aigc.generation.Generation; import com.alibaba.dashscope.aigc.generation.Generation;
@ -207,7 +208,7 @@ public class TongYiChatModel extends
.getChoices() .getChoices()
.get(0) .get(0)
)); ));
return new ChatResponse(List.of(gen)); return new ChatResponse(ListUtil.of(gen));
}) })
) )
.publishOn(Schedulers.parallel()); .publishOn(Schedulers.parallel());

View File

@ -16,6 +16,7 @@
package com.alibaba.cloud.ai.tongyi.embedding; 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.common.exception.TongYiException;
import com.alibaba.cloud.ai.tongyi.metadata.TongYiTextEmbeddingResponseMetadata; import com.alibaba.cloud.ai.tongyi.metadata.TongYiTextEmbeddingResponseMetadata;
import com.alibaba.dashscope.embeddings.TextEmbedding; import com.alibaba.dashscope.embeddings.TextEmbedding;
@ -100,7 +101,7 @@ public class TongYiTextEmbeddingModel extends AbstractEmbeddingModel {
return this.call( return this.call(
new EmbeddingRequest( new EmbeddingRequest(
List.of(document.getFormattedContent(this.metadataMode)), ListUtil.of(document.getFormattedContent(this.metadataMode)),
null) null)
).getResults().stream() ).getResults().stream()
.map(Embedding::getOutput) .map(Embedding::getOutput)

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.framework.ai.music; package cn.iocoder.yudao.framework.ai.music;
import cn.hutool.core.collection.ListUtil;
import cn.iocoder.yudao.framework.ai.core.model.suno.api.SunoApi; import cn.iocoder.yudao.framework.ai.core.model.suno.api.SunoApi;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -66,7 +67,7 @@ public class SunoApiTests {
String id = "584729e5-0fe9-4157-86da-1b4803ff42bf"; String id = "584729e5-0fe9-4157-86da-1b4803ff42bf";
// 调用方法 // 调用方法
List<SunoApi.MusicData> musicList = sunoApi.getMusicList(List.of(id)); List<SunoApi.MusicData> musicList = sunoApi.getMusicList(ListUtil.of(id));
// 打印结果 // 打印结果
System.out.println(musicList); System.out.println(musicList);
} }