mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
Merge branch 'xinnan-tech:main' into main
This commit is contained in:
commit
3021ecde8c
8 changed files with 128 additions and 100 deletions
|
|
@ -1,6 +1,12 @@
|
||||||
package xiaozhi.modules.agent.service.impl;
|
package xiaozhi.modules.agent.service.impl;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -81,9 +87,9 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
|
||||||
|
|
||||||
if (agent.getMemModelId() != null && agent.getMemModelId().equals(Constant.MEMORY_NO_MEM)) {
|
if (agent.getMemModelId() != null && agent.getMemModelId().equals(Constant.MEMORY_NO_MEM)) {
|
||||||
agent.setChatHistoryConf(Constant.ChatHistoryConfEnum.IGNORE.getCode());
|
agent.setChatHistoryConf(Constant.ChatHistoryConfEnum.IGNORE.getCode());
|
||||||
if (agent.getChatHistoryConf() == null) {
|
}
|
||||||
agent.setChatHistoryConf(Constant.ChatHistoryConfEnum.RECORD_TEXT_AUDIO.getCode());
|
if (agent.getChatHistoryConf() == null) {
|
||||||
}
|
agent.setChatHistoryConf(Constant.ChatHistoryConfEnum.RECORD_TEXT_AUDIO.getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询上下文源配置
|
// 查询上下文源配置
|
||||||
|
|
@ -132,7 +138,8 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(keyword)) {
|
||||||
if ("mac".equals(searchType)) {
|
if ("mac".equals(searchType)) {
|
||||||
// 按MAC地址搜索:先搜索设备,再获取对应的智能体
|
// 按MAC地址搜索:先搜索设备,再获取对应的智能体
|
||||||
List<DeviceEntity> devices = Optional.ofNullable(deviceService.searchDevicesByMacAddress(keyword, userId)).orElseGet(ArrayList::new);
|
List<DeviceEntity> devices = Optional
|
||||||
|
.ofNullable(deviceService.searchDevicesByMacAddress(keyword, userId)).orElseGet(ArrayList::new);
|
||||||
// 获取设备对应的智能体ID列表
|
// 获取设备对应的智能体ID列表
|
||||||
List<String> agentIds = devices.stream()
|
List<String> agentIds = devices.stream()
|
||||||
.map(DeviceEntity::getAgentId)
|
.map(DeviceEntity::getAgentId)
|
||||||
|
|
|
||||||
81
main/manager-web/public/generator/assets/index-B8r0c7xg.js
Normal file
81
main/manager-web/public/generator/assets/index-B8r0c7xg.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
main/manager-web/public/generator/favicon.ico
Normal file
BIN
main/manager-web/public/generator/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
|
|
@ -4,9 +4,10 @@
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<link rel="icon" href="./favicon.ico">
|
||||||
<title>Xiaozhi AI Customization</title>
|
<title>Xiaozhi AI Customization</title>
|
||||||
<script type="module" crossorigin src="./assets/index-FKVSBRAB.js"></script>
|
<script type="module" crossorigin src="./assets/index-B8r0c7xg.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="./assets/index-NXxBVrod.css">
|
<link rel="stylesheet" crossorigin href="./assets/index-CrIJdTCK.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
<el-button size="mini" type="text" @click="handleUnbind(scope.row.device_id)">
|
<el-button size="mini" type="text" @click="handleUnbind(scope.row.device_id)">
|
||||||
{{ $t('device.unbind') }}
|
{{ $t('device.unbind') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button v-if="isGenerate(scope.row)" size="mini" type="text" @click="handleGenertor">
|
<el-button v-if="isGenerate(scope.row)" size="mini" type="text" @click="handleGenertor(scope.row)">
|
||||||
{{ $t('device.deviceThemeGeneration') }}
|
{{ $t('device.deviceThemeGeneration') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -337,10 +337,10 @@ export default {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleGenertor() {
|
handleGenertor(row) {
|
||||||
const pathname = window.location.pathname;
|
const pathname = window.location.pathname;
|
||||||
const basePath = pathname.split('/').slice(0, -1).join('/');
|
const basePath = pathname.split('/').slice(0, -1).join('/');
|
||||||
const url = `${window.location.origin}${basePath}/generator/`;
|
const url = `${window.location.origin}${basePath}/generator/?deviceId=${row.device_id}`;
|
||||||
sessionStorage.setItem('devicePath', window.location.href);
|
sessionStorage.setItem('devicePath', window.location.href);
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
// WebSocket消息处理模块
|
// WebSocket消息处理模块
|
||||||
import { log } from '../../utils/logger.js';
|
|
||||||
import { webSocketConnect } from './ota-connector.js';
|
|
||||||
import { getConfig, saveConnectionUrls } from '../../config/manager.js';
|
import { getConfig, saveConnectionUrls } from '../../config/manager.js';
|
||||||
|
import { uiController } from '../../ui/controller.js';
|
||||||
|
import { log } from '../../utils/logger.js';
|
||||||
import { getAudioPlayer } from '../audio/player.js';
|
import { getAudioPlayer } from '../audio/player.js';
|
||||||
import { getAudioRecorder } from '../audio/recorder.js';
|
import { getAudioRecorder } from '../audio/recorder.js';
|
||||||
import { getMcpTools, executeMcpTool, setWebSocket as setMcpWebSocket } from '../mcp/tools.js';
|
import { executeMcpTool, getMcpTools, setWebSocket as setMcpWebSocket } from '../mcp/tools.js';
|
||||||
import { uiController } from '../../ui/controller.js'
|
import { webSocketConnect } from './ota-connector.js';
|
||||||
|
|
||||||
// WebSocket处理器类
|
// WebSocket处理器类
|
||||||
export class WebSocketHandler {
|
export class WebSocketHandler {
|
||||||
|
|
@ -101,10 +101,10 @@ export class WebSocketHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 触发Live2D情绪动作
|
// 触发Live2D情绪动作
|
||||||
if (message.emotion) {
|
if (message.emotion) {
|
||||||
console.log(`收到情绪消息: emotion=${message.emotion}, text=${message.text}`);
|
console.log(`收到情绪消息: emotion=${message.emotion}, text=${message.text}`);
|
||||||
this.triggerLive2DEmotionAction(message.emotion);
|
this.triggerLive2DEmotionAction(message.emotion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 只有当文本不仅仅是表情时,才添加到对话中
|
// 只有当文本不仅仅是表情时,才添加到对话中
|
||||||
|
|
@ -273,6 +273,26 @@ export class WebSocketHandler {
|
||||||
this.websocket.send(replyMessage);
|
this.websocket.send(replyMessage);
|
||||||
} else if (payload.method === 'initialize') {
|
} else if (payload.method === 'initialize') {
|
||||||
log(`收到工具初始化请求: ${JSON.stringify(payload.params)}`, 'info');
|
log(`收到工具初始化请求: ${JSON.stringify(payload.params)}`, 'info');
|
||||||
|
const replyMessage = JSON.stringify({
|
||||||
|
"session_id": message.session_id || "",
|
||||||
|
"type": "mcp",
|
||||||
|
"payload": {
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": payload.id,
|
||||||
|
"result": {
|
||||||
|
"protocolVersion": "2024-11-05",
|
||||||
|
"capabilities": {
|
||||||
|
"tools": {}
|
||||||
|
},
|
||||||
|
"serverInfo": {
|
||||||
|
"name": "xiaozhi-web-test",
|
||||||
|
"version": "2.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
log(`回复初始化响应`, 'info');
|
||||||
|
this.websocket.send(replyMessage);
|
||||||
} else {
|
} else {
|
||||||
log(`未知的MCP方法: ${payload.method}`, 'warning');
|
log(`未知的MCP方法: ${payload.method}`, 'warning');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue