Commit cbf680d1 authored by luojun's avatar luojun

deepseek优化

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