Skip to content

Commit

Permalink
AI默认切换成DeepSeek v3模型,提供更优的速度和质量
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangdaiscott committed Jan 14, 2025
1 parent d9737c8 commit 8fc27bb
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.unfbx.chatgpt.exception.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.chatgpt.prop.AiChatProperties;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.vo.LoginUser;
Expand Down Expand Up @@ -58,6 +59,11 @@ public class ChatServiceImpl implements ChatService {

private OpenAiStreamClient openAiStreamClient = null;

/**
* ai聊天配置
* for [QQYUN-10943]【AI 重要】jeecg-boot-starter-chatgpt 支持deepseek等国产模型
*/
private AiChatProperties aiChatProperties;
//update-begin---author:chenrui ---date:20240131 for:[QQYUN-8212]fix 没有配置启动报错------------

/**
Expand All @@ -66,17 +72,17 @@ public class ChatServiceImpl implements ChatService {
* @author chenrui
* @date 2024/2/3 23:08
*/
private OpenAiStreamClient ensureClient(){
private void ensureClient(){
if (null == this.openAiStreamClient){
//update-begin---author:chenrui ---date:20240625 for:[TV360X-1570]给于更友好的提示,提示未配置ai------------
try {
this.openAiStreamClient = SpringContextUtils.getBean(OpenAiStreamClient.class);
this.aiChatProperties = SpringContextUtils.getBean(AiChatProperties.class);
} catch (Exception ignored) {
sendErrorMsg("如果您想使用AI助手,请先设置相应配置!");
}
//update-end---author:chenrui ---date:20240625 for:[TV360X-1570]给于更友好的提示,提示未配置ai------------
}
return this.openAiStreamClient;
}
//update-end---author:chenrui ---date:20240131 for:[QQYUN-8212]fix 没有配置启动报错------------

Expand Down Expand Up @@ -138,6 +144,7 @@ public void closeChat() {

@Override
public void sendMessage(String topicId, String message) {
ensureClient();
String uid = getUserId();
if (StrUtil.isBlank(message)) {
log.info("参数异常,message为null");
Expand All @@ -164,18 +171,16 @@ public void sendMessage(String topicId, String message) {
throw new JeecgBootException("聊天消息推送失败uid:[{}],没有创建连接,请重试。~");
}
//update-begin---author:chenrui ---date:20240625 for:[TV360X-1570]给于更友好的提示,提示未配置ai------------
OpenAiStreamClient client = ensureClient();
if (null != client) {
if (null != openAiStreamClient) {
OpenAISSEEventSourceListener openAIEventSourceListener = new OpenAISSEEventSourceListener(topicId, sseEmitter);
ChatCompletion completion = ChatCompletion
.builder()
.messages(msgHistory)
.model(ChatCompletion.Model.GPT_3_5_TURBO.getName())
.model(aiChatProperties.getModel())
.build();
client.streamChatCompletion(completion, openAIEventSourceListener);
openAiStreamClient.streamChatCompletion(completion, openAIEventSourceListener);
redisTemplate.opsForHash().put(cacheKey, CACHE_KEY_MSG_CONTEXT, JSONUtil.toJsonStr(msgHistory));
//update-end---author:chenrui ---date:20240223 for:[QQYUN-8225]聊天记录保存------------
Result.ok(completion.tokens());
}
//update-end---author:chenrui ---date:20240625 for:[TV360X-1570]给于更友好的提示,提示未配置ai------------
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ mybatis-plus:
minidao:
base-package: org.jeecg.modules.jmreport.*,org.jeecg.modules.drag.*
jeecg:
# AI集成
ai-chat:
enabled: true
model: deepseek-chat
apiKey: ??
apiHost: https://api.deepseek.com
timeout: 60
# 平台上线安全配置
firewall:
# 数据源安全 (开启后,Online报表和图表的数据源为必填)
Expand Down Expand Up @@ -240,11 +247,6 @@ jeecg:
SMS_465391221:
# 注册账号短信模板编码
SMS_175430166:
# ElasticSearch 6设置
elasticsearch:
cluster-name: jeecg-ES
cluster-nodes: 127.0.0.1:9200
check-enabled: false
# 在线预览文件服务器地址配置
file-view-domain: http://fileview.jeecg.com
# minio文件上传
Expand Down Expand Up @@ -280,26 +282,16 @@ jeecg:
password:
type: STANDALONE
enabled: true
# ai-chat
ai-chat:
# 是否开启;必须。
enabled: false
# openAi接口秘钥,填写自己的apiKey;必须。
apiKey: "????"
# openAi域名,有代理就填代理的域名。默认:openAI官方apiHost
apiHost: "https://api.openai.com"
# 超时时间单位:s。默认 60s
timeout: 60
# 本地代理地址
# proxy:
# host: "http://127.0.0.1"
# port: "7890"
# 百度开放API配置
baidu-api:
app-id: ??
api-key: ??
secret-key: ??

# ElasticSearch 6设置
elasticsearch:
cluster-name: jeecg-ES
cluster-nodes: 127.0.0.1:9200
check-enabled: false
#cas单点登录
cas:
prefixUrl: http://cas.example.org:8443/cas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ mybatis-plus:
minidao:
base-package: org.jeecg.modules.jmreport.*,org.jeecg.modules.drag.*
jeecg:
# AI集成
ai-chat:
enabled: true
model: deepseek-chat
apiKey: ??
apiHost: https://api.deepseek.com
timeout: 60
# 平台上线安全配置
firewall:
# 数据源安全 (开启后,Online报表和图表的数据源为必填)
Expand Down Expand Up @@ -189,11 +196,6 @@ jeecg:
secretKey: ??
endpoint: oss-cn-beijing.aliyuncs.com
bucketName: jeecgdev
# ElasticSearch 6设置
elasticsearch:
cluster-name: jeecg-ES
cluster-nodes: 127.0.0.1:9200
check-enabled: false
# 在线预览文件服务器地址配置
file-view-domain: http://fileview.jeecg.com
# minio文件上传
Expand Down Expand Up @@ -229,20 +231,11 @@ jeecg:
password:
type: STANDALONE
enabled: true
# ai-chat
ai-chat:
# 是否开启;必须。
enabled: false
# openAi接口秘钥,填写自己的apiKey;必须。
apiKey: "????"
# openAi域名,有代理就填代理的域名。默认:openAI官方apiHost
apiHost: "https://api.openai.com"
# 超时时间单位:s。默认 60s
timeout: 60
# 本地代理地址
# proxy:
# host: "http://127.0.0.1"
# port: "7890"
# ElasticSearch 6设置
elasticsearch:
cluster-name: jeecg-ES
cluster-nodes: 127.0.0.1:9200
check-enabled: false
#cas单点登录
cas:
prefixUrl: http://cas.example.org:8443/cas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ mybatis-plus:
minidao:
base-package: org.jeecg.modules.jmreport.*,org.jeecg.modules.drag.*
jeecg:
# AI集成
ai-chat:
enabled: true
model: deepseek-chat
apiKey: ??
apiHost: https://api.deepseek.com
timeout: 60
# 平台上线安全配置
firewall:
# 数据源安全 (开启后,Online报表和图表的数据源为必填)
Expand Down Expand Up @@ -243,20 +250,6 @@ jeecg:
password:
type: STANDALONE
enabled: true
# ai-chat
ai-chat:
# 是否开启;必须。
enabled: false
# openAi接口秘钥,填写自己的apiKey;必须。
apiKey: "????"
# openAi域名,有代理就填代理的域名。默认:openAI官方apiHost
apiHost: "https://api.openai.com"
# 超时时间单位:s。默认 60s
timeout: 60
# 本地代理地址
# proxy:
# host: "http://127.0.0.1"
# port: "7890"
#cas单点登录
cas:
prefixUrl: http://cas.example.org:8443/cas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ mybatis-plus:
minidao:
base-package: org.jeecg.modules.jmreport.*,org.jeecg.modules.drag.*
jeecg:
# AI集成
ai-chat:
enabled: true
model: deepseek-chat
apiKey: ??
apiHost: https://api.deepseek.com
timeout: 60
# 平台上线安全配置
firewall:
# 数据源安全 (开启后,Online报表和图表的数据源为必填)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ mybatis-plus:
minidao:
base-package: org.jeecg.modules.jmreport.*,org.jeecg.modules.drag.*
jeecg:
# AI集成
ai-chat:
enabled: true
model: deepseek-chat
apiKey: ??
apiHost: https://api.deepseek.com
timeout: 60
# 平台上线安全配置
firewall:
# 数据源安全 (开启后,Online报表和图表的数据源为必填)
Expand Down Expand Up @@ -241,11 +248,6 @@ jeecg:
SMS_465391221:
# 注册账号短信模板编码
SMS_175430166:
# ElasticSearch 设置
elasticsearch:
cluster-name: jeecg-ES
cluster-nodes: 192.168.1.188:9200
check-enabled: false
# 在线预览文件服务器地址配置
file-view-domain: http://127.0.0.1:8012
# minio文件上传
Expand Down Expand Up @@ -286,7 +288,11 @@ jeecg:
app-id: ??
api-key: ??
secret-key: ??

# ElasticSearch 设置
elasticsearch:
cluster-name: jeecg-ES
cluster-nodes: 192.168.1.188:9200
check-enabled: false
#Mybatis输出sql日志
logging:
level:
Expand Down
4 changes: 2 additions & 2 deletions jeecg-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,11 @@
<artifactId>jimubi-spring-boot-starter</artifactId>
<version>${jimureport-spring-boot-starter.version}</version>
</dependency>
<!-- chatgpt -->
<!-- AI集成 -->
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-starter-chatgpt</artifactId>
<version>${jeecgboot.version}</version>
<version>3.7.3</version>
</dependency>
<!--flyway 支持 mysql5.7+、MariaDB10.3.16-->
<!--mysql5.6,需要把版本号改成5.2.1-->
Expand Down

0 comments on commit 8fc27bb

Please sign in to comment.