Commit 5f0c7790 authored by luojun's avatar luojun

优化

parent 8576a507
......@@ -177,4 +177,33 @@
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>justh5-snapshots</id>
<url>http://120.24.176.53:8081/repository/justh5-snapshots/</url>
</snapshotRepository>
<repository>
<id>justh5-releases</id>
<url>http://120.24.176.53:8081/repository/justh5-releases/</url>
</repository>
</distributionManagement>
<!-- 打包 -->
<build>
<finalName>deep-ask</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- 跳过单元测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
......@@ -7,6 +7,7 @@ import admin.modules.chatgpt.domain.ChatgptRoleRecords;
import admin.modules.chatgpt.service.ChatgptRoleRecordsService;
import admin.service.TextToSpeechService;
import admin.util.DateUtil;
import admin.util.ScreenEnum;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -35,6 +36,7 @@ public class DeepSeekAiListener extends EventSourceListener {
StringBuffer stringBuffer = new StringBuffer();
private Session session;
private String sessionId;
private String userName;
private static TextToSpeechService textToSpeechService;
private static ChatgptRoleRecordsService chatgptRoleRecordsService;
......@@ -47,8 +49,9 @@ public class DeepSeekAiListener extends EventSourceListener {
DeepSeekAiListener.chatgptRoleRecordsService = chatgptRoleRecordsService;
}
public DeepSeekAiListener(Session session,String sessionId) {
public DeepSeekAiListener(Session session,String sessionId,String userName) {
this.session = session;
this.userName = userName;
this.sessionId = sessionId;
}
......@@ -90,7 +93,8 @@ public class DeepSeekAiListener extends EventSourceListener {
//存储聊天记录
ChatgptRoleRecords chatgptRoleRecords = new ChatgptRoleRecords();
chatgptRoleRecords.setMessage(this.stringBuffer.toString());
chatgptRoleRecords.setReceiverId(Integer.valueOf(sessionId));
chatgptRoleRecords.setReceiverId(ScreenEnum.getByUserName(userName));
chatgptRoleRecords.setSessionId(Integer.valueOf(sessionId));
chatgptRoleRecords.setSenderId(10001);
chatgptRoleRecords.setCreateTime(DateUtil.getNowTimestamp());
chatgptRoleRecordsService.save(chatgptRoleRecords);
......
......@@ -114,11 +114,21 @@ public class VoiceWebSocketServer {
chatgptRoleSession.setRoleDescId(10001);
chatgptRoleSession.setUserId(ScreenEnum.getByUserName(webSocketModel.getName()));
chatgptRoleSessionService.save(chatgptRoleSession);
//创建问题记录
ChatgptRoleRecords chatgptRoleRecords = new ChatgptRoleRecords();
chatgptRoleRecords.setMessage(webSocketModel.getData());
chatgptRoleRecords.setReceiverId(10001);
chatgptRoleRecords.setSessionId(Integer.valueOf(webSocketModel.getSessionId()));
chatgptRoleRecords.setSenderId(ScreenEnum.getByUserName(webSocketModel.getName()));
chatgptRoleRecords.setCreateTime(DateUtil.getNowTimestamp());
chatgptRoleRecordsService.save(chatgptRoleRecords);
} else if (byId != null && "sendText".equals(webSocketModel.getAction())) {
ChatgptRoleRecords chatgptRoleRecords = new ChatgptRoleRecords();
chatgptRoleRecords.setMessage(webSocketModel.getData());
chatgptRoleRecords.setReceiverId(10001);
chatgptRoleRecords.setSenderId(Integer.valueOf(webSocketModel.getSessionId()));
chatgptRoleRecords.setSessionId(Integer.valueOf(webSocketModel.getSessionId()));
chatgptRoleRecords.setSenderId(ScreenEnum.getByUserName(webSocketModel.getName()));
chatgptRoleRecords.setCreateTime(DateUtil.getNowTimestamp());
chatgptRoleRecordsService.save(chatgptRoleRecords);
}
......@@ -127,7 +137,7 @@ public class VoiceWebSocketServer {
if ("sendText".equals(webSocketModel.getAction())) {
String msg = webSocketModel.getData();
if (msg != null && !msg.isEmpty()) {
maxkbOpenApiService.talk(msg,webSocketModel.getSessionId(), session);
maxkbOpenApiService.talk(msg,webSocketModel.getSessionId(), session,webSocketModel.getName());
}
// 心跳
}else if("heartbeat".equals(webSocketModel.getAction())){
......
......@@ -17,7 +17,7 @@ public interface MaxkbOpenApiService {
*
* @message message 问题
*/
void chatCompletions(String message,String sessionId,String chatId, Session session);
void chatCompletions(String message,String sessionId,String chatId, Session session,String userName);
void talk(String message,String sessionId, Session seesion);
void talk(String message,String sessionId, Session seesion,String userName);
}
......@@ -34,15 +34,15 @@ public class MaxkbOpenApiServiceImpl implements MaxkbOpenApiService {
}
@Override
public void chatCompletions( String message,String sessionId, String chatId, Session session) {
public void chatCompletions( String message,String sessionId, String chatId, Session session,String userName) {
MaxdbReq maxdbReq = new MaxdbReq();
maxdbReq.setMessage(message);
// WebSocketModel webSocketModel = JSONObject.parseObject(message, WebSocketModel.class);
HttpUtil.postCallBackStream(String.format(maxdbScreenConfig.getTalkUrl(),chatId), maxdbReq, maxdbScreenConfig.getApiKey(),session,sessionId);
HttpUtil.postCallBackStream(String.format(maxdbScreenConfig.getTalkUrl(),chatId), maxdbReq, maxdbScreenConfig.getApiKey(),session,sessionId,userName);
}
@Override
public void talk(String message,String sessionId,Session seesion) {
public void talk(String message,String sessionId,Session seesion,String userName) {
// if (message.contains("中科")){
//
// }else if (message.contains("大屏")){
......@@ -53,6 +53,6 @@ public class MaxkbOpenApiServiceImpl implements MaxkbOpenApiService {
// }
ApiResponse<Object> maxkbSessionId = getMaxkbSessionId(maxdbScreenConfig.getApplicationId());
chatCompletions(message,sessionId, String.valueOf(maxkbSessionId.getData()),seesion);
chatCompletions(message,sessionId, String.valueOf(maxkbSessionId.getData()),seesion,userName);
}
}
......@@ -34,7 +34,7 @@ public class HttpUtil {
}
public static void postCallBackStream(String url, Object data, String apiKey, Session session,String sessionId){
public static void postCallBackStream(String url, Object data, String apiKey, Session session,String sessionId,String userName){
OkHttpClient okHttpClient = new OkHttpClient().newBuilder().build();
// RequestBody body = RequestBody.create(MediaType.parse("application/json"), data);
Request request = null;
......@@ -51,6 +51,6 @@ public class HttpUtil {
throw new RuntimeException(e);
}
EventSource.Factory factory = EventSources.createFactory(okHttpClient);
factory.newEventSource(request,new DeepSeekAiListener(session,sessionId));
factory.newEventSource(request,new DeepSeekAiListener(session,sessionId,userName));
}
}
spring:
# redis:
# #数据库索引
# database: 9
# host: 120.24.176.53
# port: 6580
# password: Hzzy891212
# #连接超时时间
# timeout: 5000
datasource:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://36.138.204.4:3306/chatgpt?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&rewriteBatchedStatements=true
username: chatgpt_rw
password: Chatgpt@20231211
# 初始连接数
initial-size: 5
# 最小连接数
min-idle: 10
# 最大连接数
max-active: 20
# 获取连接超时时间
max-wait: 5000
# 连接有效性检测时间
time-between-eviction-runs-millis: 60000
# 连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
# 连接在池中最大生存的时间
max-evictable-idle-time-millis: 900000
test-while-idle: true
test-on-borrow: true
test-on-return: false
# 检测连接是否有效
validation-query: select 1
# 配置监控统计
webStatFilter:
enabled: true
stat-view-servlet:
enabled: true
url-pattern: /druid/*
reset-enable: false
filter:
stat:
enabled: true
# 记录慢SQL
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
jpa:
properties:
hibernate:
ddl-auto: none
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
open-in-view: true
spring:
# redis:
# #数据库索引
# database: 9
# host: 120.24.176.53
# port: 6580
# password: Hzzy891212
# #连接超时时间
# timeout: 5000
datasource:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://36.138.204.4:3306/chatgpt?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&rewriteBatchedStatements=true
username: chatgpt_rw
password: Chatgpt@20231211
# 初始连接数
initial-size: 5
# 最小连接数
min-idle: 10
# 最大连接数
max-active: 20
# 获取连接超时时间
max-wait: 5000
# 连接有效性检测时间
time-between-eviction-runs-millis: 60000
# 连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
# 连接在池中最大生存的时间
max-evictable-idle-time-millis: 900000
test-while-idle: true
test-on-borrow: true
test-on-return: false
# 检测连接是否有效
validation-query: select 1
# 配置监控统计
webStatFilter:
enabled: true
stat-view-servlet:
enabled: true
url-pattern: /druid/*
reset-enable: false
filter:
stat:
enabled: true
# 记录慢SQL
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
jpa:
properties:
hibernate:
ddl-auto: none
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
open-in-view: true
......@@ -2,72 +2,14 @@ maxdb:
zhongke:
api-key: application-5479ccf9b59c66432e5529febe94719a
application-id: 1a0e5e60-f1bd-11ef-a7de-0242ac110002
chat-url: http://192.168.0.122:8080/api/application/%s/chat/open
talk-url: http://192.168.0.122:8080/api/application/chat_message/%s
chat-url: http://maxdb.justh5.com/api/application/%s/chat/open
talk-url: http://maxdb.justh5.com/api/application/chat_message/%s
screen:
api-key: application-6e8250fa092a566c7c0aea0e08c9b1a3
application-id: adc51c8c-f3f4-11ef-a70b-0242ac110002
chat-url: http://192.168.0.122:8080/api/application/%s/chat/open
talk-url: http://192.168.0.122:8080/api/application/chat_message/%s
chat-url: http://maxdb.justh5.com/api/application/%s/chat/open
talk-url: http://maxdb.justh5.com/api/application/chat_message/%s
spring:
redis:
#数据库索引
database: 9
host: 120.24.176.53
port: 6580
password: Hzzy891212
#连接超时时间
timeout: 5000
datasource:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://36.138.204.4:3306/chatgpt?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&rewriteBatchedStatements=true
username: chatgpt_rw
password: Chatgpt@20231211
# 初始连接数
initial-size: 5
# 最小连接数
min-idle: 10
# 最大连接数
max-active: 20
# 获取连接超时时间
max-wait: 5000
# 连接有效性检测时间
time-between-eviction-runs-millis: 60000
# 连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
# 连接在池中最大生存的时间
max-evictable-idle-time-millis: 900000
test-while-idle: true
test-on-borrow: true
test-on-return: false
# 检测连接是否有效
validation-query: select 1
# 配置监控统计
webStatFilter:
enabled: true
stat-view-servlet:
enabled: true
url-pattern: /druid/*
reset-enable: false
filter:
stat:
enabled: true
# 记录慢SQL
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
jpa:
properties:
hibernate:
ddl-auto: none
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
open-in-view: true
mybatis-plus:
check-config-location: true
configuration:
......@@ -82,4 +24,10 @@ mybatis-plus:
server:
port: 8888
tomcat:
max-swallow-size: 104857600
\ No newline at end of file
max-swallow-size: 104857600
spring:
profiles:
active: ${ACTIVE_ENV:dev}
jackson:
time-zone: GMT+8
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment