Commit 17f7970259d3e3456fce1235fbdfaebf64268403
1 parent
ec6ad9da
增加自动配置
Showing
4 changed files
with
146 additions
and
9 deletions
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/config/YudaoAiAutoConfiguration.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.ai.config; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.ai.chatxinghuo.XingHuoChatClient; | ||
| 4 | +import cn.iocoder.yudao.framework.ai.chatxinghuo.XingHuoOptions; | ||
| 5 | +import cn.iocoder.yudao.framework.ai.chatxinghuo.api.XingHuoApi; | ||
| 6 | +import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
| 7 | +import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 8 | +import org.springframework.context.annotation.Bean; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * ai 自动配置 | ||
| 12 | + * | ||
| 13 | + * @author fansili | ||
| 14 | + * @time 2024/4/12 16:29 | ||
| 15 | + * @since 1.0 | ||
| 16 | + */ | ||
| 17 | +@AutoConfiguration | ||
| 18 | +@EnableConfigurationProperties(YudaoAiProperties.class) | ||
| 19 | +public class YudaoAiAutoConfiguration { | ||
| 20 | + | ||
| 21 | + @Bean | ||
| 22 | + public XingHuoChatClient xingHuoChatClient(YudaoAiProperties yudaoAiProperties) { | ||
| 23 | + return new XingHuoChatClient( | ||
| 24 | + new XingHuoApi( | ||
| 25 | + yudaoAiProperties.getXingHuo().getAppId(), | ||
| 26 | + yudaoAiProperties.getXingHuo().getAppKey(), | ||
| 27 | + yudaoAiProperties.getXingHuo().getSecretKey() | ||
| 28 | + ), | ||
| 29 | + new XingHuoOptions().setChatModel(yudaoAiProperties.getXingHuo().getChatModel()) | ||
| 30 | + ); | ||
| 31 | + } | ||
| 32 | +} |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/config/YudaoAiProperties.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.ai.config; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.ai.chatxinghuo.XingHuoChatModel; | ||
| 4 | +import cn.iocoder.yudao.framework.ai.chatyiyan.YiYanChatModel; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.experimental.Accessors; | ||
| 7 | +import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * ai 自动配置 | ||
| 11 | + * | ||
| 12 | + * @author fansili | ||
| 13 | + * @time 2024/4/12 16:29 | ||
| 14 | + * @since 1.0 | ||
| 15 | + */ | ||
| 16 | +@Data | ||
| 17 | +@ConfigurationProperties(prefix = "yudao.ai") | ||
| 18 | +public class YudaoAiProperties { | ||
| 19 | + | ||
| 20 | + private QianWenProperties qianWen; | ||
| 21 | + private XingHuoProperties xingHuo; | ||
| 22 | + private YiYanProperties yiYan; | ||
| 23 | + | ||
| 24 | + @Data | ||
| 25 | + @Accessors(chain = true) | ||
| 26 | + public static class ChatProperties { | ||
| 27 | + | ||
| 28 | + private Float temperature; | ||
| 29 | + | ||
| 30 | + private Float topP; | ||
| 31 | + | ||
| 32 | + private Integer topK; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @Data | ||
| 36 | + @Accessors(chain = true) | ||
| 37 | + public static class QianWenProperties extends ChatProperties { | ||
| 38 | + /** | ||
| 39 | + * 阿里云:服务器接入点 | ||
| 40 | + */ | ||
| 41 | + private String endpoint = "bailian.cn-beijing.aliyuncs.com"; | ||
| 42 | + /** | ||
| 43 | + * 阿里云:权限 accessKeyId | ||
| 44 | + */ | ||
| 45 | + private String accessKeyId; | ||
| 46 | + /** | ||
| 47 | + * 阿里云:权限 accessKeySecret | ||
| 48 | + */ | ||
| 49 | + private String accessKeySecret; | ||
| 50 | + /** | ||
| 51 | + * 阿里云:agentKey(相当于应用id) | ||
| 52 | + */ | ||
| 53 | + private String agentKey; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Data | ||
| 57 | + @Accessors(chain = true) | ||
| 58 | + public static class XingHuoProperties extends ChatProperties { | ||
| 59 | + private String appId; | ||
| 60 | + private String appKey; | ||
| 61 | + private String secretKey; | ||
| 62 | + private XingHuoChatModel chatModel; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @Data | ||
| 66 | + @Accessors(chain = true) | ||
| 67 | + public static class YiYanProperties extends ChatProperties { | ||
| 68 | + /** | ||
| 69 | + * appKey | ||
| 70 | + */ | ||
| 71 | + private String appKey; | ||
| 72 | + /** | ||
| 73 | + * secretKey | ||
| 74 | + */ | ||
| 75 | + private String secretKey; | ||
| 76 | + /** | ||
| 77 | + * 模型 | ||
| 78 | + */ | ||
| 79 | + private YiYanChatModel chatModel = YiYanChatModel.ERNIE4_3_5_8K; | ||
| 80 | + /** | ||
| 81 | + * token 刷新时间(默认 86400 = 24小时) | ||
| 82 | + */ | ||
| 83 | + private int refreshTokenSecondTime = 86400; | ||
| 84 | + } | ||
| 85 | +} |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
0 → 100644
| 1 | +cn.iocoder.yudao.framework.ai.config.YudaoAiAutoConfiguration |
yudao-server/src/main/resources/application-local.yaml
| @@ -54,7 +54,7 @@ spring: | @@ -54,7 +54,7 @@ spring: | ||
| 54 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 | 54 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 |
| 55 | # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 | 55 | # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 |
| 56 | username: root | 56 | username: root |
| 57 | - password: 123456 | 57 | + password: root |
| 58 | # username: sa | 58 | # username: sa |
| 59 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W | 59 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W |
| 60 | # username: SYSDBA # DM 连接的示例 | 60 | # username: SYSDBA # DM 连接的示例 |
| @@ -68,7 +68,7 @@ spring: | @@ -68,7 +68,7 @@ spring: | ||
| 68 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 | 68 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 |
| 69 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 | 69 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 |
| 70 | username: root | 70 | username: root |
| 71 | - password: 123456 | 71 | + password: root |
| 72 | # username: sa | 72 | # username: sa |
| 73 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W | 73 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W |
| 74 | 74 | ||
| @@ -196,12 +196,12 @@ debug: false | @@ -196,12 +196,12 @@ debug: false | ||
| 196 | --- #################### 微信公众号、小程序相关配置 #################### | 196 | --- #################### 微信公众号、小程序相关配置 #################### |
| 197 | wx: | 197 | wx: |
| 198 | mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 | 198 | mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 |
| 199 | -# app-id: wx041349c6f39b268b # 测试号(牛希尧提供的) | ||
| 200 | -# secret: 5abee519483bc9f8cb37ce280e814bd0 | 199 | + # app-id: wx041349c6f39b268b # 测试号(牛希尧提供的) |
| 200 | + # secret: 5abee519483bc9f8cb37ce280e814bd0 | ||
| 201 | app-id: wx5b23ba7a5589ecbb # 测试号(自己的) | 201 | app-id: wx5b23ba7a5589ecbb # 测试号(自己的) |
| 202 | secret: 2a7b3b20c537e52e74afd395eb85f61f | 202 | secret: 2a7b3b20c537e52e74afd395eb85f61f |
| 203 | -# app-id: wxa69ab825b163be19 # 测试号(Kongdy 提供的) | ||
| 204 | -# secret: bd4f9fab889591b62aeac0d7b8d8b4a0 | 203 | + # app-id: wxa69ab825b163be19 # 测试号(Kongdy 提供的) |
| 204 | + # secret: bd4f9fab889591b62aeac0d7b8d8b4a0 | ||
| 205 | # 存储配置,解决 AccessToken 的跨节点的共享 | 205 | # 存储配置,解决 AccessToken 的跨节点的共享 |
| 206 | config-storage: | 206 | config-storage: |
| 207 | type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 | 207 | type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 |
| @@ -212,8 +212,8 @@ wx: | @@ -212,8 +212,8 @@ wx: | ||
| 212 | # secret: 333ae72f41552af1e998fe1f54e1584a | 212 | # secret: 333ae72f41552af1e998fe1f54e1584a |
| 213 | appid: wx63c280fe3248a3e7 # wenhualian的接口测试号 | 213 | appid: wx63c280fe3248a3e7 # wenhualian的接口测试号 |
| 214 | secret: 6f270509224a7ae1296bbf1c8cb97aed | 214 | secret: 6f270509224a7ae1296bbf1c8cb97aed |
| 215 | -# appid: wxc4598c446f8a9cb3 # 测试号(Kongdy 提供的) | ||
| 216 | -# secret: 4a1a04e07f6a4a0751b39c3064a92c8b | 215 | + # appid: wxc4598c446f8a9cb3 # 测试号(Kongdy 提供的) |
| 216 | + # secret: 4a1a04e07f6a4a0751b39c3064a92c8b | ||
| 217 | config-storage: | 217 | config-storage: |
| 218 | type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 | 218 | type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 |
| 219 | key-prefix: wa # Redis Key 的前缀 | 219 | key-prefix: wa # Redis Key 的前缀 |
| @@ -223,6 +223,25 @@ wx: | @@ -223,6 +223,25 @@ wx: | ||
| 223 | 223 | ||
| 224 | # 芋道配置项,设置当前项目所有自定义的配置 | 224 | # 芋道配置项,设置当前项目所有自定义的配置 |
| 225 | yudao: | 225 | yudao: |
| 226 | + ai: | ||
| 227 | + temperature: 1 | ||
| 228 | + topP: 1 | ||
| 229 | + topK: 1 | ||
| 230 | + qianWen: | ||
| 231 | + endpoint: bailian.cn-beijing.aliyuncs.com | ||
| 232 | + accessKeyId: LTAI5tNTVhXW4fLKUjMrr98z | ||
| 233 | + accessKeySecret: ZJ0JQeyjzxxm5CfeTV6k1wNE9UsvZP | ||
| 234 | + agentKey: f0c1088824594f589c8f10567ccd929f_p_efm | ||
| 235 | + xingHuo: | ||
| 236 | + appId: 13c8cca6 | ||
| 237 | + appKey: cb6415c19d6162cda07b47316fcb0416 | ||
| 238 | + secretKey: Y2JiYTIxZjA3MDMxMjNjZjQzYzVmNzdh | ||
| 239 | + chatModel: XING_HUO_3_5 | ||
| 240 | + yiYan: | ||
| 241 | + appKey: x0cuLZ7XsaTCU08vuJWO87Lg | ||
| 242 | + secretKey: R9mYF9dl9KASgi5RUq0FQt3wRisSnOcK | ||
| 243 | + refreshTokenSecondTime: 86400 | ||
| 244 | + chatModel: ERNIE4_3_5_8K | ||
| 226 | captcha: | 245 | captcha: |
| 227 | enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试; | 246 | enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试; |
| 228 | security: | 247 | security: |
| @@ -235,6 +254,7 @@ yudao: | @@ -235,6 +254,7 @@ yudao: | ||
| 235 | pay: | 254 | pay: |
| 236 | order-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/order # 支付渠道的【支付】回调地址 | 255 | order-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/order # 支付渠道的【支付】回调地址 |
| 237 | refund-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址 | 256 | refund-notify-url: http://yunai.natapp1.cc/admin-api/pay/notify/refund # 支付渠道的【退款】回调地址 |
| 257 | + | ||
| 238 | access-log: # 访问日志的配置项 | 258 | access-log: # 访问日志的配置项 |
| 239 | enable: false | 259 | enable: false |
| 240 | error-code: # 错误码相关配置项 | 260 | error-code: # 错误码相关配置项 |
| @@ -267,7 +287,6 @@ justauth: | @@ -267,7 +287,6 @@ justauth: | ||
| 267 | type: REDIS | 287 | type: REDIS |
| 268 | prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: | 288 | prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: |
| 269 | timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 | 289 | timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 |
| 270 | - | ||
| 271 | # TODO 赤焰:这个配置的目的是? | 290 | # TODO 赤焰:这个配置的目的是? |
| 272 | #ureport配置 | 291 | #ureport配置 |
| 273 | #ureport: | 292 | #ureport: |