Commit 2ef64a0a506c02c490f2a625859a09909196d211
1 parent
be8d9c1a
【优化】自动配置,适配新的千问
Showing
3 changed files
with
13 additions
and
24 deletions
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/chatqianwen/QianWenOptions.java
| @@ -18,11 +18,6 @@ import java.util.List; | @@ -18,11 +18,6 @@ import java.util.List; | ||
| 18 | @Accessors | 18 | @Accessors |
| 19 | public class QianWenOptions implements ChatOptions { | 19 | public class QianWenOptions implements ChatOptions { |
| 20 | 20 | ||
| 21 | - private String appId; | ||
| 22 | - /** | ||
| 23 | - * 是否流式输出, 默认为否。 | ||
| 24 | - */ | ||
| 25 | - private Boolean stream; | ||
| 26 | /** | 21 | /** |
| 27 | * 用户与模型的对话历史 | 22 | * 用户与模型的对话历史 |
| 28 | */ | 23 | */ |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/config/YudaoAiAutoConfiguration.java
| @@ -44,13 +44,16 @@ public class YudaoAiAutoConfiguration { | @@ -44,13 +44,16 @@ public class YudaoAiAutoConfiguration { | ||
| 44 | @ConditionalOnProperty(value = "yudao.ai.qianwen.enable", havingValue = "true") | 44 | @ConditionalOnProperty(value = "yudao.ai.qianwen.enable", havingValue = "true") |
| 45 | public QianWenChatClient qianWenChatClient(YudaoAiProperties yudaoAiProperties) { | 45 | public QianWenChatClient qianWenChatClient(YudaoAiProperties yudaoAiProperties) { |
| 46 | YudaoAiProperties.QianWenProperties qianWenProperties = yudaoAiProperties.getQianwen(); | 46 | YudaoAiProperties.QianWenProperties qianWenProperties = yudaoAiProperties.getQianwen(); |
| 47 | + QianWenOptions qianWenOptions = new QianWenOptions(); | ||
| 48 | + qianWenOptions.setTopK(qianWenProperties.getTopK()); | ||
| 49 | + qianWenOptions.setTopP(qianWenProperties.getTopP()); | ||
| 50 | + qianWenOptions.setTemperature(qianWenProperties.getTemperature()); | ||
| 47 | return new QianWenChatClient( | 51 | return new QianWenChatClient( |
| 48 | new QianWenApi( | 52 | new QianWenApi( |
| 49 | - qianWenProperties.getAgentKey(), | 53 | + qianWenProperties.getApiKey(), |
| 50 | QianWenChatModal.QWEN_72B_CHAT | 54 | QianWenChatModal.QWEN_72B_CHAT |
| 51 | ), | 55 | ), |
| 52 | - new QianWenOptions() | ||
| 53 | - .setAppId(qianWenProperties.getAppId()) | 56 | + qianWenOptions |
| 54 | ); | 57 | ); |
| 55 | } | 58 | } |
| 56 | 59 |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/config/YudaoAiProperties.java
| @@ -42,26 +42,15 @@ public class YudaoAiProperties { | @@ -42,26 +42,15 @@ public class YudaoAiProperties { | ||
| 42 | @Data | 42 | @Data |
| 43 | @Accessors(chain = true) | 43 | @Accessors(chain = true) |
| 44 | public static class QianWenProperties extends ChatProperties { | 44 | public static class QianWenProperties extends ChatProperties { |
| 45 | + | ||
| 45 | /** | 46 | /** |
| 46 | - * 阿里云:服务器接入点 | ||
| 47 | - */ | ||
| 48 | - private String endpoint = "bailian.cn-beijing.aliyuncs.com"; | ||
| 49 | - /** | ||
| 50 | - * 阿里云:权限 accessKeyId | ||
| 51 | - */ | ||
| 52 | - private String accessKeyId; | ||
| 53 | - /** | ||
| 54 | - * 阿里云:权限 accessKeySecret | ||
| 55 | - */ | ||
| 56 | - private String accessKeySecret; | ||
| 57 | - /** | ||
| 58 | - * 阿里云:agentKey | 47 | + * api key |
| 59 | */ | 48 | */ |
| 60 | - private String agentKey; | 49 | + private String apiKey; |
| 61 | /** | 50 | /** |
| 62 | - * 阿里云:agentKey(相当于应用id) | 51 | + * model |
| 63 | */ | 52 | */ |
| 64 | - private String appId; | 53 | + private YiYanChatModel model; |
| 65 | 54 | ||
| 66 | } | 55 | } |
| 67 | 56 | ||
| @@ -93,5 +82,7 @@ public class YudaoAiProperties { | @@ -93,5 +82,7 @@ public class YudaoAiProperties { | ||
| 93 | * token 刷新时间(默认 86400 = 24小时) | 82 | * token 刷新时间(默认 86400 = 24小时) |
| 94 | */ | 83 | */ |
| 95 | private int refreshTokenSecondTime = 86400; | 84 | private int refreshTokenSecondTime = 86400; |
| 85 | + | ||
| 86 | + private YiYanChatModel model; | ||
| 96 | } | 87 | } |
| 97 | } | 88 | } |