Commit cbf680d1 authored by luojun's avatar luojun

deepseek优化

parent 0116b25c
......@@ -8,6 +8,7 @@ import admin.modules.chatgpt.service.ChatgptRoleRecordsService;
import admin.util.DateUtil;
import admin.util.ScreenEnum;
import admin.util.WebConnectUtil;
import admin.util.WebSocketUtil;
import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import lombok.SneakyThrows;
......@@ -84,15 +85,17 @@ public class DeepSeekAiListener extends EventSourceListener {
map.put("content",completionResponse.getContent());
String msg = JSON.toJSONString(map);
maxKbChatReq.getSession().getBasicRemote().sendText(msg);
List<Session> webMap = WebConnectUtil.getWebMap(maxKbChatReq.getUserName());
if (!webMap.isEmpty()){
webMap.forEach(i->{
try {
i.getBasicRemote().sendText(msg);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
if (maxKbChatReq.getClient().equals(WebSocketUtil.H5)){
List<Session> webMap = WebConnectUtil.getWebMap(maxKbChatReq.getUserName());
if (!webMap.isEmpty()){
webMap.forEach(i->{
try {
i.getBasicRemote().sendText(msg);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
}
}
}catch (Exception e){
......
......@@ -18,6 +18,10 @@ public class MaxKbChatReq {
* sessionId用于h5获取匹配的大屏session
*/
private String sessionId;
/**
* 客户端 H5还是web
*/
private String client;
/**
* maxkb会话id
*/
......
......@@ -167,7 +167,7 @@ public class VoiceWebSocketServer {
String msg = webSocketModel.getData();
if (msg != null && !msg.isEmpty()) {
String showType = getShowType(msg);
SendSseModel sendSseModel = new SendSseModel(msg, webSocketModel.getSessionId(), session, webSocketModel.getName(), memberId.split("__")[0].equals(WebSocketUtil.web),showType);
SendSseModel sendSseModel = new SendSseModel(msg, webSocketModel.getSessionId(), session, webSocketModel.getName(), memberId.split("__")[0].equals(WebSocketUtil.H5),showType);
maxkbOpenApiService.talk(sendSseModel);
}
// 心跳
......
......@@ -10,6 +10,7 @@ import admin.modules.chatgpt.service.ChatgptRoleRecordsService;
import admin.resp.ApiResponse;
import admin.service.MaxkbOpenApiService;
import admin.util.HttpUtil;
import admin.util.WebSocketUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
......@@ -63,6 +64,7 @@ public class MaxkbOpenApiServiceImpl implements MaxkbOpenApiService {
maxKbChatReq.setSessionId(sendSseModel.getSessionId());
maxKbChatReq.setUserName(sendSseModel.getUserName());
maxKbChatReq.setShowType(sendSseModel.getShowType());
maxKbChatReq.setClient(sendSseModel.isH5() ? WebSocketUtil.H5 : WebSocketUtil.web);
maxKbChatReq.setSession(sendSseModel.getSeesion());
chatCompletions(maxKbChatReq);
}
......
......@@ -5,7 +5,9 @@ import lombok.Data;
import lombok.Getter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author lj
......@@ -57,13 +59,17 @@ public enum ScreenEnum {
return ScreenEnum.ALL_PARK.userId;
}
public static List<ScreenEnum> getScreen(){
List<ScreenEnum> list = new ArrayList<>();
public static List<Map<String,Object>> getScreen(){
List<Map<String,Object>> list = new ArrayList<>();
for(ScreenEnum value:ScreenEnum.values()){
if(value.isShow.equals(1)){
list.add(value);
Map<String,Object> map = new HashMap<>();
map.put("name",value.name);
map.put("userId",value.userId);
map.put("isShow",value.isShow);
map.put("screenName",value.screenName);
list.add(map);
}
}
return list;
}
......
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