mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
Merge branch 'main' of https://github.com/xinnan-tech/xiaozhi-esp32-server
This commit is contained in:
commit
0795b5de35
15 changed files with 193 additions and 76 deletions
|
|
@ -227,7 +227,7 @@ public interface Constant {
|
||||||
/**
|
/**
|
||||||
* 版本号
|
* 版本号
|
||||||
*/
|
*/
|
||||||
public static final String VERSION = "0.5.6";
|
public static final String VERSION = "0.5.7";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 无效固件URL
|
* 无效固件URL
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,9 @@ public class AgentTemplateServiceImpl extends ServiceImpl<AgentTemplateDao, Agen
|
||||||
wrapper.set("tts_model_id", modelId);
|
wrapper.set("tts_model_id", modelId);
|
||||||
wrapper.set("tts_voice_id", null);
|
wrapper.set("tts_voice_id", null);
|
||||||
break;
|
break;
|
||||||
|
case "VLLM":
|
||||||
|
wrapper.set("vllm_model_id", modelId);
|
||||||
|
break;
|
||||||
case "MEMORY":
|
case "MEMORY":
|
||||||
wrapper.set("mem_model_id", modelId);
|
wrapper.set("mem_model_id", modelId);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import xiaozhi.common.exception.ErrorCode;
|
import xiaozhi.common.exception.ErrorCode;
|
||||||
import xiaozhi.common.redis.RedisKeys;
|
import xiaozhi.common.redis.RedisKeys;
|
||||||
|
|
@ -22,6 +24,7 @@ import xiaozhi.common.user.UserDetail;
|
||||||
import xiaozhi.common.utils.Result;
|
import xiaozhi.common.utils.Result;
|
||||||
import xiaozhi.modules.device.dto.DeviceRegisterDTO;
|
import xiaozhi.modules.device.dto.DeviceRegisterDTO;
|
||||||
import xiaozhi.modules.device.dto.DeviceUnBindDTO;
|
import xiaozhi.modules.device.dto.DeviceUnBindDTO;
|
||||||
|
import xiaozhi.modules.device.dto.DeviceUpdateDTO;
|
||||||
import xiaozhi.modules.device.entity.DeviceEntity;
|
import xiaozhi.modules.device.entity.DeviceEntity;
|
||||||
import xiaozhi.modules.device.service.DeviceService;
|
import xiaozhi.modules.device.service.DeviceService;
|
||||||
import xiaozhi.modules.security.user.SecurityUser;
|
import xiaozhi.modules.security.user.SecurityUser;
|
||||||
|
|
@ -80,15 +83,19 @@ public class DeviceController {
|
||||||
return new Result<Void>();
|
return new Result<Void>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/enableOta/{id}/{status}")
|
@PutMapping("/update/{id}")
|
||||||
@Operation(summary = "启用/关闭OTA自动升级")
|
@Operation(summary = "更新设备信息")
|
||||||
@RequiresPermissions("sys:role:normal")
|
@RequiresPermissions("sys:role:normal")
|
||||||
public Result<Void> enableOtaUpgrade(@PathVariable String id, @PathVariable Integer status) {
|
public Result<Void> updateDeviceInfo(@PathVariable String id, @Valid @RequestBody DeviceUpdateDTO deviceUpdateDTO) {
|
||||||
DeviceEntity entity = deviceService.selectById(id);
|
DeviceEntity entity = deviceService.selectById(id);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return new Result<Void>().error("设备不存在");
|
return new Result<Void>().error("设备不存在");
|
||||||
}
|
}
|
||||||
entity.setAutoUpdate(status);
|
UserDetail user = SecurityUser.getUser();
|
||||||
|
if (!entity.getUserId().equals(user.getId())) {
|
||||||
|
return new Result<Void>().error("设备不存在");
|
||||||
|
}
|
||||||
|
BeanUtils.copyProperties(deviceUpdateDTO, entity);
|
||||||
deviceService.updateById(entity);
|
deviceService.updateById(entity);
|
||||||
return new Result<Void>();
|
return new Result<Void>();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package xiaozhi.modules.device.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.Max;
|
||||||
|
import jakarta.validation.constraints.Min;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备更新DTO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DeviceUpdateDTO implements Serializable {
|
||||||
|
/**
|
||||||
|
* 自动更新状态
|
||||||
|
*/
|
||||||
|
@Max(1)
|
||||||
|
@Min(0)
|
||||||
|
private Integer autoUpdate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备别名
|
||||||
|
*/
|
||||||
|
@Size(max = 64)
|
||||||
|
private String alias;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
|
|
@ -51,10 +51,11 @@ export default {
|
||||||
});
|
});
|
||||||
}).send();
|
}).send();
|
||||||
},
|
},
|
||||||
enableOtaUpgrade(id, status, callback) {
|
updateDeviceInfo(id, payload, callback) {
|
||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
.url(`${getServiceUrl()}/device/enableOta/${id}/${status}`)
|
.url(`${getServiceUrl()}/device/update/${id}`)
|
||||||
.method('PUT')
|
.method('PUT')
|
||||||
|
.data(payload)
|
||||||
.success((res) => {
|
.success((res) => {
|
||||||
RequestService.clearRequestTime()
|
RequestService.clearRequestTime()
|
||||||
callback(res)
|
callback(res)
|
||||||
|
|
@ -63,7 +64,7 @@ export default {
|
||||||
console.error('更新OTA状态失败:', err)
|
console.error('更新OTA状态失败:', err)
|
||||||
this.$message.error(err.msg || '更新OTA状态失败')
|
this.$message.error(err.msg || '更新OTA状态失败')
|
||||||
RequestService.reAjaxFun(() => {
|
RequestService.reAjaxFun(() => {
|
||||||
this.enableOtaUpgrade(id, status, callback)
|
this.updateDeviceInfo(id, payload, callback)
|
||||||
})
|
})
|
||||||
}).send()
|
}).send()
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@
|
||||||
<div class="content-area">
|
<div class="content-area">
|
||||||
<el-card class="device-card" shadow="never">
|
<el-card class="device-card" shadow="never">
|
||||||
<el-table ref="deviceTable" :data="paginatedDeviceList" class="transparent-table"
|
<el-table ref="deviceTable" :data="paginatedDeviceList" class="transparent-table"
|
||||||
:header-cell-class-name="headerCellClassName" v-loading="loading" element-loading-text="拼命加载中"
|
:header-cell-class-name="headerCellClassName" v-loading="loading"
|
||||||
|
element-loading-text="拼命加载中"
|
||||||
element-loading-spinner="el-icon-loading" element-loading-background="rgba(255, 255, 255, 0.7)">
|
element-loading-spinner="el-icon-loading" element-loading-background="rgba(255, 255, 255, 0.7)">
|
||||||
<el-table-column label="选择" align="center" width="120">
|
<el-table-column label="选择" align="center" width="120">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
|
@ -33,14 +34,24 @@
|
||||||
<el-table-column label="绑定时间" prop="bindTime" align="center"></el-table-column>
|
<el-table-column label="绑定时间" prop="bindTime" align="center"></el-table-column>
|
||||||
<el-table-column label="最近对话" prop="lastConversation" align="center"></el-table-column>
|
<el-table-column label="最近对话" prop="lastConversation" align="center"></el-table-column>
|
||||||
<el-table-column label="备注" align="center">
|
<el-table-column label="备注" align="center">
|
||||||
<template slot-scope="scope">
|
<template #default="{ row }">
|
||||||
<el-input v-if="scope.row.isEdit" v-model="scope.row.remark" size="mini"
|
<el-input
|
||||||
@blur="stopEditRemark(scope.$index)"></el-input>
|
v-show="row.isEdit"
|
||||||
<span v-else>
|
v-model="row.remark"
|
||||||
<i v-if="!scope.row.remark" class="el-icon-edit"
|
size="mini"
|
||||||
@click="startEditRemark(scope.$index, scope.row)"></i>
|
maxlength="64"
|
||||||
<span v-else @click="startEditRemark(scope.$index, scope.row)">
|
show-word-limit
|
||||||
{{ scope.row.remark }}
|
@blur="onRemarkBlur(row)"
|
||||||
|
@keyup.enter.native="onRemarkEnter(row)"
|
||||||
|
/>
|
||||||
|
<span v-show="!row.isEdit" class="remark-view">
|
||||||
|
<i
|
||||||
|
class="el-icon-edit"
|
||||||
|
@click="row.isEdit = true"
|
||||||
|
style="cursor: pointer;"
|
||||||
|
></i>
|
||||||
|
<span @click="row.isEdit = true">
|
||||||
|
{{ row.remark || '—' }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -133,10 +144,7 @@ export default {
|
||||||
paginatedDeviceList() {
|
paginatedDeviceList() {
|
||||||
const start = (this.currentPage - 1) * this.pageSize;
|
const start = (this.currentPage - 1) * this.pageSize;
|
||||||
const end = start + this.pageSize;
|
const end = start + this.pageSize;
|
||||||
return this.filteredDeviceList.slice(start, end).map(item => ({
|
return this.filteredDeviceList.slice(start, end);
|
||||||
...item,
|
|
||||||
selected: false
|
|
||||||
}));
|
|
||||||
},
|
},
|
||||||
pageCount() {
|
pageCount() {
|
||||||
return Math.ceil(this.filteredDeviceList.length / this.pageSize);
|
return Math.ceil(this.filteredDeviceList.length / this.pageSize);
|
||||||
|
|
@ -212,7 +220,6 @@ export default {
|
||||||
this.batchUnbindDevices(deviceIds);
|
this.batchUnbindDevices(deviceIds);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
batchUnbindDevices(deviceIds) {
|
batchUnbindDevices(deviceIds) {
|
||||||
const promises = deviceIds.map(id => {
|
const promises = deviceIds.map(id => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
@ -225,7 +232,6 @@ export default {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$message.success({
|
this.$message.success({
|
||||||
|
|
@ -243,15 +249,44 @@ export default {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
handleAddDevice() {
|
handleAddDevice() {
|
||||||
this.addDeviceDialogVisible = true;
|
this.addDeviceDialogVisible = true;
|
||||||
},
|
},
|
||||||
startEditRemark(index, row) {
|
submitRemark(row) {
|
||||||
this.deviceList[index].isEdit = true;
|
if (row._submitting) return;
|
||||||
|
|
||||||
|
const text = (row.remark || '').trim();
|
||||||
|
if (text.length > 64) {
|
||||||
|
this.$message.warning('备注不能超过 64 字符');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (text === row._originalRemark) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
row._submitting = true;
|
||||||
|
this.updateDeviceInfo(row.device_id, { alias: text }, (ok, resp) => {
|
||||||
|
if (ok) {
|
||||||
|
row._originalRemark = text;
|
||||||
|
this.$message.success('备注已保存');
|
||||||
|
} else {
|
||||||
|
row.remark = row._originalRemark;
|
||||||
|
this.$message.error(resp.msg || '备注保存失败');
|
||||||
|
}
|
||||||
|
row._submitting = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
stopEditRemark(index) {
|
// 备注输入框:失焦时提交
|
||||||
this.deviceList[index].isEdit = false;
|
onRemarkBlur(row) {
|
||||||
|
row.isEdit = false;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.submitRemark(row);
|
||||||
|
}, 100); // 延迟 100ms,避开 enter+blur 同时触发的窗口
|
||||||
|
},
|
||||||
|
// 备注输入框:按回车时提交
|
||||||
|
onRemarkEnter(row) {
|
||||||
|
row.isEdit = false;
|
||||||
|
this.submitRemark(row);
|
||||||
},
|
},
|
||||||
handleUnbind(device_id) {
|
handleUnbind(device_id) {
|
||||||
this.$confirm('确认要解绑该设备吗?', '警告', {
|
this.$confirm('确认要解绑该设备吗?', '警告', {
|
||||||
|
|
@ -302,7 +337,9 @@ export default {
|
||||||
bindTime: device.createDate,
|
bindTime: device.createDate,
|
||||||
lastConversation: device.lastConnectedAt,
|
lastConversation: device.lastConnectedAt,
|
||||||
remark: device.alias,
|
remark: device.alias,
|
||||||
|
_originalRemark: device.alias,
|
||||||
isEdit: false,
|
isEdit: false,
|
||||||
|
_submitting: false,
|
||||||
otaSwitch: device.autoUpdate === 1,
|
otaSwitch: device.autoUpdate === 1,
|
||||||
rawBindTime: new Date(device.createDate).getTime()
|
rawBindTime: new Date(device.createDate).getTime()
|
||||||
};
|
};
|
||||||
|
|
@ -325,14 +362,19 @@ export default {
|
||||||
const firmwareType = this.firmwareTypes.find(item => item.key === type)
|
const firmwareType = this.firmwareTypes.find(item => item.key === type)
|
||||||
return firmwareType ? firmwareType.name : type
|
return firmwareType ? firmwareType.name : type
|
||||||
},
|
},
|
||||||
|
updateDeviceInfo(device_id, payload, callback) {
|
||||||
|
return Api.device.updateDeviceInfo(device_id, payload, ({data}) => {
|
||||||
|
callback(data.code === 0, data);
|
||||||
|
})
|
||||||
|
},
|
||||||
handleOtaSwitchChange(row) {
|
handleOtaSwitchChange(row) {
|
||||||
Api.device.enableOtaUpgrade(row.device_id, row.otaSwitch ? 1 : 0, ({ data }) => {
|
this.updateDeviceInfo(row.device_id, {autoUpdate: row.otaSwitch ? 1 : 0}, (result, {msg}) => {
|
||||||
if (data.code === 0) {
|
if (result) {
|
||||||
this.$message.success(row.otaSwitch ? '已设置成自动升级' : '已关闭自动升级')
|
this.$message.success(row.otaSwitch ? '已设置成自动升级' : '已关闭自动升级');
|
||||||
} else {
|
return;
|
||||||
row.otaSwitch = !row.otaSwitch
|
|
||||||
this.$message.error(data.msg || '操作失败')
|
|
||||||
}
|
}
|
||||||
|
row.otaSwitch = !row.otaSwitch
|
||||||
|
this.$message.error(msg || '操作失败')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -645,7 +687,6 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:deep(.el-table .el-button--text) {
|
:deep(.el-table .el-button--text) {
|
||||||
color: #7079aa;
|
color: #7079aa;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ from config.config_loader import load_config
|
||||||
from config.settings import check_config_file
|
from config.settings import check_config_file
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
SERVER_VERSION = "0.5.6"
|
SERVER_VERSION = "0.5.7"
|
||||||
_logger_initialized = False
|
_logger_initialized = False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ from config.config_loader import get_private_config_from_api
|
||||||
from core.utils.auth import AuthToken
|
from core.utils.auth import AuthToken
|
||||||
import base64
|
import base64
|
||||||
from typing import Tuple, Optional
|
from typing import Tuple, Optional
|
||||||
|
from plugins_func.register import Action
|
||||||
|
|
||||||
TAG = __name__
|
TAG = __name__
|
||||||
|
|
||||||
|
|
@ -122,7 +123,8 @@ class VisionHandler:
|
||||||
|
|
||||||
return_json = {
|
return_json = {
|
||||||
"success": True,
|
"success": True,
|
||||||
"result": result,
|
"action": Action.RESPONSE.name,
|
||||||
|
"response": result,
|
||||||
}
|
}
|
||||||
|
|
||||||
response = web.Response(
|
response = web.Response(
|
||||||
|
|
|
||||||
|
|
@ -751,6 +751,28 @@ class ConnectionHandler:
|
||||||
self.loop,
|
self.loop,
|
||||||
).result()
|
).result()
|
||||||
self.logger.bind(tag=TAG).debug(f"MCP工具调用结果: {result}")
|
self.logger.bind(tag=TAG).debug(f"MCP工具调用结果: {result}")
|
||||||
|
|
||||||
|
resultJson = None
|
||||||
|
if isinstance(result, str):
|
||||||
|
try:
|
||||||
|
resultJson = json.loads(result)
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.bind(tag=TAG).error(
|
||||||
|
f"解析MCP工具返回结果失败: {e}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# 视觉大模型不经过二次LLM处理
|
||||||
|
if (
|
||||||
|
resultJson is not None
|
||||||
|
and isinstance(resultJson, dict)
|
||||||
|
and "action" in resultJson
|
||||||
|
):
|
||||||
|
result = ActionResponse(
|
||||||
|
action=Action[resultJson["action"]],
|
||||||
|
result=None,
|
||||||
|
response=resultJson.get("response", ""),
|
||||||
|
)
|
||||||
|
else:
|
||||||
result = ActionResponse(
|
result = ActionResponse(
|
||||||
action=Action.REQLLM, result=result, response=""
|
action=Action.REQLLM, result=result, response=""
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,10 @@ class FunctionHandler:
|
||||||
self.functions_desc = self.function_registry.get_all_function_desc()
|
self.functions_desc = self.function_registry.get_all_function_desc()
|
||||||
self.finish_init = True
|
self.finish_init = True
|
||||||
|
|
||||||
|
def upload_functions_desc(self):
|
||||||
|
self.functions_desc = self.function_registry.get_all_function_desc()
|
||||||
|
|
||||||
|
|
||||||
def current_support_functions(self):
|
def current_support_functions(self):
|
||||||
func_names = []
|
func_names = []
|
||||||
for func in self.functions_desc:
|
for func in self.functions_desc:
|
||||||
|
|
|
||||||
|
|
@ -338,6 +338,8 @@ async def handleIotDescriptors(conn, descriptors):
|
||||||
|
|
||||||
# 如果注册了新函数,更新function描述列表
|
# 如果注册了新函数,更新function描述列表
|
||||||
if functions_changed and hasattr(conn, "func_handler"):
|
if functions_changed and hasattr(conn, "func_handler"):
|
||||||
|
conn.func_handler.upload_functions_desc()
|
||||||
|
|
||||||
func_names = conn.func_handler.current_support_functions()
|
func_names = conn.func_handler.current_support_functions()
|
||||||
conn.logger.bind(tag=TAG).info(f"设备类型: {type_id}")
|
conn.logger.bind(tag=TAG).info(f"设备类型: {type_id}")
|
||||||
conn.logger.bind(tag=TAG).info(
|
conn.logger.bind(tag=TAG).info(
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ class MCPManager:
|
||||||
self.conn.logger.bind(tag=TAG).error(
|
self.conn.logger.bind(tag=TAG).error(
|
||||||
f"Failed to initialize MCP server {name}: {e}"
|
f"Failed to initialize MCP server {name}: {e}"
|
||||||
)
|
)
|
||||||
|
self.conn.func_handler.upload_functions_desc()
|
||||||
|
|
||||||
def get_all_tools(self) -> List[Dict[str, Any]]:
|
def get_all_tools(self) -> List[Dict[str, Any]]:
|
||||||
"""获取所有服务的工具function定义
|
"""获取所有服务的工具function定义
|
||||||
|
|
|
||||||
|
|
@ -93,9 +93,7 @@ class ASRProvider(ASRProviderBase):
|
||||||
|
|
||||||
# 检查初始化响应
|
# 检查初始化响应
|
||||||
if "code" in result and result["code"] != 1000:
|
if "code" in result and result["code"] != 1000:
|
||||||
error_msg = f"ASR服务初始化失败: {result.get('payload_msg', {}).get('message', '未知错误')}"
|
error_msg = f"ASR服务初始化失败: {result.get('payload_msg', {}).get('error', '未知错误')}"
|
||||||
if "payload_msg" in result:
|
|
||||||
error_msg += f"\n详细错误信息: {json.dumps(result['payload_msg'], ensure_ascii=False)}"
|
|
||||||
logger.bind(tag=TAG).error(error_msg)
|
logger.bind(tag=TAG).error(error_msg)
|
||||||
raise Exception(error_msg)
|
raise Exception(error_msg)
|
||||||
|
|
||||||
|
|
@ -309,9 +307,10 @@ class ASRProvider(ASRProviderBase):
|
||||||
|
|
||||||
# 如果是错误响应
|
# 如果是错误响应
|
||||||
if message_type == 0x0F: # SERVER_ERROR_RESPONSE
|
if message_type == 0x0F: # SERVER_ERROR_RESPONSE
|
||||||
code = int.from_bytes(header[4:8], "big", signed=False)
|
code = int.from_bytes(res[4:8], "big", signed=False)
|
||||||
error_msg = res[8:].decode("utf-8")
|
msg_length = int.from_bytes(res[8:12], "big", signed=False)
|
||||||
return {"code": code, "error": error_msg}
|
error_msg = json.loads(res[12:].decode("utf-8"))
|
||||||
|
return {"code": code, "msg_length": msg_length, "payload_msg": error_msg}
|
||||||
|
|
||||||
# 获取JSON数据(跳过12字节头部)
|
# 获取JSON数据(跳过12字节头部)
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import os
|
||||||
import yaml
|
import yaml
|
||||||
from config.config_loader import get_project_dir
|
from config.config_loader import get_project_dir
|
||||||
from config.manage_api_client import save_mem_local_short
|
from config.manage_api_client import save_mem_local_short
|
||||||
|
from core.utils.util import check_model_key
|
||||||
|
|
||||||
|
|
||||||
short_term_memory_prompt = """
|
short_term_memory_prompt = """
|
||||||
|
|
@ -145,6 +146,10 @@ class MemoryProvider(MemoryProviderBase):
|
||||||
# 打印使用的模型信息
|
# 打印使用的模型信息
|
||||||
model_info = getattr(self.llm, "model_name", str(self.llm.__class__.__name__))
|
model_info = getattr(self.llm, "model_name", str(self.llm.__class__.__name__))
|
||||||
logger.bind(tag=TAG).debug(f"使用记忆保存模型: {model_info}")
|
logger.bind(tag=TAG).debug(f"使用记忆保存模型: {model_info}")
|
||||||
|
api_key = getattr(self.llm, "api_key", None)
|
||||||
|
memory_key_msg = check_model_key("记忆总结专用LLM", api_key)
|
||||||
|
if memory_key_msg:
|
||||||
|
logger.bind(tag=TAG).error(memory_key_msg)
|
||||||
if self.llm is None:
|
if self.llm is None:
|
||||||
logger.bind(tag=TAG).error("LLM is not set for memory provider")
|
logger.bind(tag=TAG).error("LLM is not set for memory provider")
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ hass_set_state_function_desc = {
|
||||||
"description": "只有在设置静音操作时才需要,设置静音的时候该值为true,取消静音时该值为false",
|
"description": "只有在设置静音操作时才需要,设置静音的时候该值为true,取消静音时该值为false",
|
||||||
},
|
},
|
||||||
"rgb_color": {
|
"rgb_color": {
|
||||||
"type": "list",
|
"type": "array",
|
||||||
|
"items": {"type": "integer"},
|
||||||
"description": "只有在设置颜色时需要,这里填目标颜色的rgb值",
|
"description": "只有在设置颜色时需要,这里填目标颜色的rgb值",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue