增加 QianWenOptions 类型判断,避免强转失败!

This commit is contained in:
cherishsince 2024-03-16 19:54:20 +08:00
parent 6415422f7d
commit 1fada268ac

View File

@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.ai.chat.*;
import cn.iocoder.yudao.framework.ai.chat.messages.MessageType;
import cn.iocoder.yudao.framework.ai.chat.prompt.ChatOptions;
import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt;
import cn.iocoder.yudao.framework.ai.chatyiyan.YiYanOptions;
import cn.iocoder.yudao.framework.ai.chatyiyan.exception.YiYanApiException;
import com.aliyun.broadscope.bailian.sdk.models.*;
import lombok.extern.slf4j.Slf4j;
@ -89,6 +90,10 @@ public class QianWenChatClient implements ChatClient, StreamingChatClient {
if (prompt.getOptions() != null) {
options = (ChatOptions) prompt.getOptions();
}
// Prompt 里面是一个 ChatOptions用户可以随意传入这里做一下判断
if (!(options instanceof QianWenOptions)) {
throw new ChatException("Prompt 传入的不是 QianWenOptions!");
}
QianWenOptions qianWenOptions = (QianWenOptions) options;
// 需要额外处理
if (!stream) {