mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 09:11:52 +08:00
【代码评审】AI:讯飞星火的接入调整
This commit is contained in:
parent
04021ce068
commit
645dfae003
@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum;
|
||||
import org.springframework.ai.chat.ChatClient;
|
||||
import org.springframework.ai.chat.StreamingChatClient;
|
||||
import org.springframework.ai.models.tongyi.QianWenChatClient;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoChatClient;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatClient;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatClient;
|
||||
import org.springframework.ai.ollama.OllamaChatClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -27,7 +27,7 @@ public class AiChatClientFactory {
|
||||
public ChatClient getChatClient(AiPlatformEnum platformEnum) {
|
||||
if (AiPlatformEnum.QIAN_WEN == platformEnum) {
|
||||
return applicationContext.getBean(QianWenChatClient.class);
|
||||
} else if (AiPlatformEnum.YIYAN == platformEnum) {
|
||||
} else if (AiPlatformEnum.YI_YAN == platformEnum) {
|
||||
return applicationContext.getBean(YiYanChatClient.class);
|
||||
} else if (AiPlatformEnum.XING_HUO == platformEnum) {
|
||||
return applicationContext.getBean(XingHuoChatClient.class);
|
||||
@ -42,7 +42,7 @@ public class AiChatClientFactory {
|
||||
// }
|
||||
if (AiPlatformEnum.QIAN_WEN == platformEnum) {
|
||||
return applicationContext.getBean(QianWenChatClient.class);
|
||||
} else if (AiPlatformEnum.YIYAN == platformEnum) {
|
||||
} else if (AiPlatformEnum.YI_YAN == platformEnum) {
|
||||
return applicationContext.getBean(YiYanChatClient.class);
|
||||
} else if (AiPlatformEnum.XING_HUO == platformEnum) {
|
||||
return applicationContext.getBean(XingHuoChatClient.class);
|
||||
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.ai.dal.vo;
|
||||
import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoChatModel;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatModel;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.yiyan.api.YiYanChatModel;
|
||||
|
||||
/**
|
||||
|
@ -5,9 +5,9 @@ import org.springframework.ai.models.tongyi.QianWenChatClient;
|
||||
import org.springframework.ai.models.tongyi.QianWenChatModal;
|
||||
import org.springframework.ai.models.tongyi.QianWenOptions;
|
||||
import org.springframework.ai.models.tongyi.api.QianWenApi;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoChatClient;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoOptions;
|
||||
import org.springframework.ai.models.xinghuo.api.XingHuoApi;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatClient;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoOptions;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoApi;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatClient;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatOptions;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.yiyan.api.YiYanApi;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.framework.ai.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoChatModel;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoOptions;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatModel;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoOptions;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.yiyan.api.YiYanChatModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.framework.ai.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoChatModel;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatModel;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.yiyan.api.YiYanChatModel;
|
||||
import cn.iocoder.yudao.framework.ai.core.enums.OpenAiImageModelEnum;
|
||||
import cn.iocoder.yudao.framework.ai.core.enums.OpenAiImageStyleEnum;
|
||||
@ -21,7 +21,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ConfigurationProperties(prefix = "yudao.ai")
|
||||
public class YudaoAiProperties {
|
||||
|
||||
private String initSource;
|
||||
private QianWenProperties qianwen;
|
||||
private XingHuoProperties xinghuo;
|
||||
private YiYanProperties yiyan;
|
||||
|
@ -16,16 +16,23 @@ public enum AiPlatformEnum {
|
||||
|
||||
OPENAI("OpenAI", "OpenAI"),
|
||||
OLLAMA("Ollama", "Ollama"),
|
||||
YIYAN("YiYan", "文心一言"),
|
||||
YI_YAN("YiYan", "文心一言"), // 百度
|
||||
XING_HUO("XingHuo", "星火"), // 讯飞
|
||||
|
||||
QIAN_WEN("qianwen", "千问"), // 阿里
|
||||
|
||||
QIAN_WEN("qianwen", "千问"),
|
||||
XING_HUO("xinghuo", "星火"),
|
||||
OPEN_AI_DALL("dall", "dall"),
|
||||
MIDJOURNEY("midjourney", "midjourney"),
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 平台
|
||||
*/
|
||||
private final String platform;
|
||||
/**
|
||||
* 平台名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
// public static List<AiPlatformEnum> CHAT_PLATFORM_LIST = Lists.newArrayList(
|
||||
|
@ -1,14 +1,14 @@
|
||||
package org.springframework.ai.models.xinghuo;
|
||||
package cn.iocoder.yudao.framework.ai.core.model.xinghuo;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.iocoder.yudao.framework.ai.core.exception.ChatException;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoApi;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoChatCompletion;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoChatCompletionRequest;
|
||||
import org.springframework.ai.chat.*;
|
||||
import org.springframework.ai.chat.prompt.ChatOptions;
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
import org.springframework.ai.models.xinghuo.api.XingHuoApi;
|
||||
import org.springframework.ai.models.xinghuo.api.XingHuoChatCompletion;
|
||||
import org.springframework.ai.models.xinghuo.api.XingHuoChatCompletionRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.retry.RetryCallback;
|
||||
@ -21,6 +21,7 @@ import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// TODO @fan:参考 yiyan 的修改建议,调整下 xinghuo 的实现;可以等 yiyan 修改完建议,然后我 review 完,再改这个哈;
|
||||
/**
|
||||
* 讯飞星火 client
|
||||
* <p>
|
@ -1,4 +1,4 @@
|
||||
package org.springframework.ai.models.xinghuo;
|
||||
package cn.iocoder.yudao.framework.ai.core.model.xinghuo;
|
||||
|
||||
import lombok.Getter;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.springframework.ai.models.xinghuo;
|
||||
package cn.iocoder.yudao.framework.ai.core.model.xinghuo;
|
||||
|
||||
import org.springframework.ai.chat.prompt.ChatOptions;
|
||||
import lombok.Data;
|
@ -1,8 +1,8 @@
|
||||
package org.springframework.ai.models.xinghuo.api;
|
||||
package cn.iocoder.yudao.framework.ai.core.model.xinghuo.api;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoChatModel;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatModel;
|
||||
import lombok.Data;
|
||||
import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -21,6 +21,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// TODO @fan:讯飞使用 spring websocket 接入,还是 okhttp?确认了,未使用的最好删除下,反正 git 也能找回 history
|
||||
/**
|
||||
* 讯飞星火 属性、api
|
||||
* <p>
|
@ -1,4 +1,4 @@
|
||||
package org.springframework.ai.models.xinghuo.api;
|
||||
package cn.iocoder.yudao.framework.ai.core.model.xinghuo.api;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
@ -1,4 +1,4 @@
|
||||
package org.springframework.ai.models.xinghuo.api;
|
||||
package cn.iocoder.yudao.framework.ai.core.model.xinghuo.api;
|
||||
|
||||
/**
|
||||
* author: fansili
|
@ -1,4 +1,4 @@
|
||||
package org.springframework.ai.models.xinghuo.api;
|
||||
package cn.iocoder.yudao.framework.ai.core.model.xinghuo.api;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
@ -2,8 +2,8 @@ package cn.iocoder.yudao.framework.ai.chat;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.springframework.ai.models.xinghuo.api.XingHuoChatCompletion;
|
||||
import org.springframework.ai.models.xinghuo.api.XingHuoChatCompletionRequest;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoChatCompletion;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoChatCompletionRequest;
|
||||
import org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient;
|
||||
import org.springframework.web.reactive.socket.client.WebSocketClient;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
@ -5,10 +5,10 @@ import org.springframework.ai.chat.messages.Message;
|
||||
import org.springframework.ai.chat.messages.SystemMessage;
|
||||
import org.springframework.ai.chat.messages.UserMessage;
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoChatClient;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoChatModel;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoOptions;
|
||||
import org.springframework.ai.models.xinghuo.api.XingHuoApi;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatClient;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatModel;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoOptions;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoApi;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
@ -2,9 +2,9 @@ package cn.iocoder.yudao.framework.ai.chat;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoChatClient;
|
||||
import org.springframework.ai.models.xinghuo.api.XingHuoChatCompletion;
|
||||
import org.springframework.ai.models.xinghuo.api.XingHuoChatCompletionRequest;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatClient;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoChatCompletion;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XingHuoChatCompletionRequest;
|
||||
import okhttp3.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -209,37 +209,6 @@ wx:
|
||||
|
||||
# 芋道配置项,设置当前项目所有自定义的配置
|
||||
yudao:
|
||||
ai:
|
||||
initSource: yaml
|
||||
qianwen:
|
||||
enable: true
|
||||
aiPlatform: QIAN_WEN
|
||||
max-tokens: 1500
|
||||
temperature: 0.85
|
||||
topP: 0.8
|
||||
topK: 0
|
||||
api-key: sk-Zsd81gZYg7
|
||||
xinghuo:
|
||||
enable: true
|
||||
aiPlatform: XING_HUO
|
||||
max-tokens: 1500
|
||||
temperature: 0.85
|
||||
topP: 0.8
|
||||
topK: 0
|
||||
appId: 13c8cca6
|
||||
appKey: cb6415c19d6162cda07b47316fcb0416
|
||||
secretKey: Y2JiYTIxZjA3MDMxMjNjZjQzYzVmNzdh
|
||||
model: XING_HUO_3_5
|
||||
openAiImage:
|
||||
enable: true
|
||||
api-key: ${OPEN_AI_KEY}
|
||||
model: dall_e_2
|
||||
style: vivid
|
||||
midjourney:
|
||||
enable: true
|
||||
token: MTE4MjE3MjY2MjkxNTY3ODIzOA.GEV1SG.c49F8lZoGCUHwsj8O0UdodmM6nyQHvuD2fXflw
|
||||
guild-id: 1237948819677904956
|
||||
channel-id: 1237948819677904960
|
||||
captcha:
|
||||
enable: false # 本地环境,暂时关闭图片验证码,方便登录等接口的测试;
|
||||
security:
|
||||
|
@ -153,7 +153,7 @@ spring.ai:
|
||||
yudao.ai:
|
||||
yiyan:
|
||||
enable: true
|
||||
aiPlatform: YIYAN # TODO @fan:建议每个都独立配置属性类
|
||||
aiPlatform: YI_YAN # TODO @fan:建议每个都独立配置属性类
|
||||
max-tokens: 1500
|
||||
temperature: 0.85
|
||||
topP: 0.8
|
||||
@ -162,6 +162,35 @@ yudao.ai:
|
||||
secretKey: R9mYF9dl9KASgi5RUq0FQt3wRisSnOcK
|
||||
refreshTokenSecondTime: 86400
|
||||
model: ERNIE4_3_5_8K
|
||||
xinghuo:
|
||||
enable: true
|
||||
aiPlatform: XING_HUO # TODO @fan:建议每个都独立配置属性类
|
||||
max-tokens: 1500
|
||||
temperature: 0.85
|
||||
topP: 0.8
|
||||
topK: 0
|
||||
appId: 13c8cca6
|
||||
appKey: cb6415c19d6162cda07b47316fcb0416
|
||||
secretKey: Y2JiYTIxZjA3MDMxMjNjZjQzYzVmNzdh
|
||||
model: XING_HUO_3_5
|
||||
qianwen:
|
||||
enable: true
|
||||
aiPlatform: QIAN_WEN
|
||||
max-tokens: 1500
|
||||
temperature: 0.85
|
||||
topP: 0.8
|
||||
topK: 0
|
||||
api-key: sk-Zsd81gZYg7
|
||||
openAiImage:
|
||||
enable: true
|
||||
api-key: ${OPEN_AI_KEY}
|
||||
model: dall_e_2
|
||||
style: vivid
|
||||
midjourney:
|
||||
enable: true
|
||||
token: MTE4MjE3MjY2MjkxNTY3ODIzOA.GEV1SG.c49F8lZoGCUHwsj8O0UdodmM6nyQHvuD2fXflw
|
||||
guild-id: 1237948819677904956
|
||||
channel-id: 1237948819677904960
|
||||
|
||||
--- #################### 芋道相关配置 ####################
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user