Commit 5aacefc00e3b7c4071c018db5e52f2d5a57cec27
1 parent
075545c1
【缺陷修复】AI:新增对话进行问答时,toolNames cannot be null的问题
Showing
1 changed file
with
3 additions
and
0 deletions
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/util/AiUtils.java
| 1 | 1 | package cn.iocoder.yudao.framework.ai.core.util; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.util.ObjUtil; | |
| 3 | 4 | import cn.hutool.core.util.StrUtil; |
| 4 | 5 | import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum; |
| 5 | 6 | import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatOptions; |
| ... | ... | @@ -13,6 +14,7 @@ import org.springframework.ai.openai.OpenAiChatOptions; |
| 13 | 14 | import org.springframework.ai.qianfan.QianFanChatOptions; |
| 14 | 15 | import org.springframework.ai.zhipuai.ZhiPuAiChatOptions; |
| 15 | 16 | |
| 17 | +import java.util.Collections; | |
| 16 | 18 | import java.util.Set; |
| 17 | 19 | |
| 18 | 20 | /** |
| ... | ... | @@ -28,6 +30,7 @@ public class AiUtils { |
| 28 | 30 | |
| 29 | 31 | public static ChatOptions buildChatOptions(AiPlatformEnum platform, String model, Double temperature, Integer maxTokens, |
| 30 | 32 | Set<String> toolNames) { |
| 33 | + toolNames = ObjUtil.defaultIfNull(toolNames, Collections.emptySet()); | |
| 31 | 34 | // noinspection EnhancedSwitchMigration |
| 32 | 35 | switch (platform) { |
| 33 | 36 | case TONG_YI: | ... | ... |