mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-16 21:33:40 +00:00
feat: 发布3.0版本,新增文档处理能力和演示模式
- 升级langchain4j版本至1.13.0 - 新增docx/pdf/xlsx文档处理技能模块 - 添加演示模式配置和切面拦截 - 优化聊天服务和可观测性监听器 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -202,12 +202,14 @@ public class SseEmitterManager {
|
||||
public void sendEvent(Long userId, SseEventDto eventDto) {
|
||||
Map<String, SseEmitter> emitters = USER_TOKEN_EMITTERS.get(userId);
|
||||
if (MapUtil.isNotEmpty(emitters)) {
|
||||
log.debug("【SSE发送】userId: {}, emitter数量: {}, event: {}", userId, emitters.size(), eventDto.getEvent());
|
||||
for (Map.Entry<String, SseEmitter> entry : emitters.entrySet()) {
|
||||
try {
|
||||
entry.getValue().send(SseEmitter.event()
|
||||
.name(eventDto.getEvent())
|
||||
.data(JSONUtil.toJsonStr(eventDto)));
|
||||
} catch (Exception e) {
|
||||
log.error("【SSE发送失败】userId: {}, token: {}, error: {}", userId, entry.getKey(), e.getMessage());
|
||||
SseEmitter remove = emitters.remove(entry.getKey());
|
||||
if (remove != null) {
|
||||
remove.complete();
|
||||
@@ -215,6 +217,7 @@ public class SseEmitterManager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("【SSE发送失败】userId: {} 没有活跃的SSE连接, 当前连接用户: {}", userId, USER_TOKEN_EMITTERS.keySet());
|
||||
USER_TOKEN_EMITTERS.remove(userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,4 +89,21 @@ public class SseEventDto implements Serializable {
|
||||
.error(error)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 MCP 工具事件
|
||||
*/
|
||||
public static SseEventDto mcpTool(String toolName, String status, String result) {
|
||||
return SseEventDto.builder()
|
||||
.event("mcp_tool")
|
||||
.content(buildMcpJson(toolName, status, result))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static String buildMcpJson(String toolName, String status, String result) {
|
||||
return String.format("{\"toolName\":\"%s\",\"status\":\"%s\",\"result\":\"%s\"}",
|
||||
toolName != null ? toolName.replace("\"", "\\\"") : "",
|
||||
status != null ? status : "",
|
||||
result != null ? result.replace("\"", "\\\"").replace("\n", "\\n") : "");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user