【优化】自动配置,适配新的千问

This commit is contained in:
cherishsince 2024-04-26 18:24:57 +08:00
parent be8d9c1a5f
commit 2ef64a0a50
3 changed files with 13 additions and 24 deletions

View File

@ -18,11 +18,6 @@ import java.util.List;
@Accessors @Accessors
public class QianWenOptions implements ChatOptions { public class QianWenOptions implements ChatOptions {
private String appId;
/**
* 是否流式输出, 默认为否
*/
private Boolean stream;
/** /**
* 用户与模型的对话历史 * 用户与模型的对话历史
*/ */

View File

@ -44,13 +44,16 @@ public class YudaoAiAutoConfiguration {
@ConditionalOnProperty(value = "yudao.ai.qianwen.enable", havingValue = "true") @ConditionalOnProperty(value = "yudao.ai.qianwen.enable", havingValue = "true")
public QianWenChatClient qianWenChatClient(YudaoAiProperties yudaoAiProperties) { public QianWenChatClient qianWenChatClient(YudaoAiProperties yudaoAiProperties) {
YudaoAiProperties.QianWenProperties qianWenProperties = yudaoAiProperties.getQianwen(); YudaoAiProperties.QianWenProperties qianWenProperties = yudaoAiProperties.getQianwen();
QianWenOptions qianWenOptions = new QianWenOptions();
qianWenOptions.setTopK(qianWenProperties.getTopK());
qianWenOptions.setTopP(qianWenProperties.getTopP());
qianWenOptions.setTemperature(qianWenProperties.getTemperature());
return new QianWenChatClient( return new QianWenChatClient(
new QianWenApi( new QianWenApi(
qianWenProperties.getAgentKey(), qianWenProperties.getApiKey(),
QianWenChatModal.QWEN_72B_CHAT QianWenChatModal.QWEN_72B_CHAT
), ),
new QianWenOptions() qianWenOptions
.setAppId(qianWenProperties.getAppId())
); );
} }

View File

@ -42,26 +42,15 @@ public class YudaoAiProperties {
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public static class QianWenProperties extends ChatProperties { public static class QianWenProperties extends ChatProperties {
/** /**
* 阿里云服务器接入点 * api key
*/ */
private String endpoint = "bailian.cn-beijing.aliyuncs.com"; private String apiKey;
/** /**
* 阿里云权限 accessKeyId * model
*/ */
private String accessKeyId; private YiYanChatModel model;
/**
* 阿里云权限 accessKeySecret
*/
private String accessKeySecret;
/**
* 阿里云agentKey
*/
private String agentKey;
/**
* 阿里云agentKey(相当于应用id)
*/
private String appId;
} }
@ -93,5 +82,7 @@ public class YudaoAiProperties {
* token 刷新时间(默认 86400 = 24小时) * token 刷新时间(默认 86400 = 24小时)
*/ */
private int refreshTokenSecondTime = 86400; private int refreshTokenSecondTime = 86400;
private YiYanChatModel model;
} }
} }