mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
fix: 撤掉崩溃的扩展字段编辑器 + 去掉「换角色/恢复自动匹配」按钮
- roleConfig.vue/agent.js 还原到 ext 编辑器之前(编辑器运行时崩页面,先撤)
- DeviceItem.vue 去掉换角色/恢复自动匹配按钮及处理函数(用户不要)
- ext 后端(表/API/{{ext.key}} 替换)保留,家长期望仍在乐宝生效
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
b0b1b10bbf
commit
3b75520a9b
3 changed files with 1 additions and 101 deletions
|
|
@ -18,37 +18,6 @@ export default {
|
||||||
});
|
});
|
||||||
}).send();
|
}).send();
|
||||||
},
|
},
|
||||||
// 取 agent 扩展字段
|
|
||||||
getExt(agentId, callback) {
|
|
||||||
RequestService.sendRequest()
|
|
||||||
.url(`${getServiceUrl()}/agent/${agentId}/ext`)
|
|
||||||
.method('GET')
|
|
||||||
.success((res) => {
|
|
||||||
RequestService.clearRequestTime();
|
|
||||||
callback(res);
|
|
||||||
})
|
|
||||||
.networkFail(() => {
|
|
||||||
RequestService.reAjaxFun(() => {
|
|
||||||
this.getExt(agentId, callback);
|
|
||||||
});
|
|
||||||
}).send();
|
|
||||||
},
|
|
||||||
// 整体覆盖 agent 扩展字段
|
|
||||||
saveExt(agentId, extObj, callback) {
|
|
||||||
RequestService.sendRequest()
|
|
||||||
.url(`${getServiceUrl()}/agent/${agentId}/ext`)
|
|
||||||
.method('PUT')
|
|
||||||
.data(extObj)
|
|
||||||
.success((res) => {
|
|
||||||
RequestService.clearRequestTime();
|
|
||||||
callback(res);
|
|
||||||
})
|
|
||||||
.networkFail(() => {
|
|
||||||
RequestService.reAjaxFun(() => {
|
|
||||||
this.saveExt(agentId, extObj, callback);
|
|
||||||
});
|
|
||||||
}).send();
|
|
||||||
},
|
|
||||||
// 添加智能体
|
// 添加智能体
|
||||||
addAgent(agentName, callback) {
|
addAgent(agentName, callback) {
|
||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
|
|
|
||||||
|
|
@ -25,17 +25,6 @@
|
||||||
<div class="settings-btn" @click="handleConfigure">
|
<div class="settings-btn" @click="handleConfigure">
|
||||||
{{ $t('home.configureRole') }}
|
{{ $t('home.configureRole') }}
|
||||||
</div>
|
</div>
|
||||||
<el-dropdown trigger="click" @command="handleSwitchPersona">
|
|
||||||
<div class="settings-btn">
|
|
||||||
换角色<i class="el-icon-arrow-down el-icon--right"></i>
|
|
||||||
</div>
|
|
||||||
<el-dropdown-menu slot="dropdown">
|
|
||||||
<el-dropdown-item v-for="a in personaOptions" :key="a.id" :command="a.id">{{ a.agentName }}</el-dropdown-item>
|
|
||||||
</el-dropdown-menu>
|
|
||||||
</el-dropdown>
|
|
||||||
<div class="settings-btn" @click="handleResetAuto">
|
|
||||||
恢复自动匹配
|
|
||||||
</div>
|
|
||||||
<div v-if="featureStatus.voiceprintRecognition" class="settings-btn" @click="handleVoicePrint">
|
<div v-if="featureStatus.voiceprintRecognition" class="settings-btn" @click="handleVoicePrint">
|
||||||
{{ $t('home.voiceprintRecognition') }}
|
{{ $t('home.voiceprintRecognition') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -79,10 +68,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return { switchValue: false, personaOptions: [] }
|
return { switchValue: false }
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.fetchPersonaOptions();
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
formattedLastConnectedTime() {
|
formattedLastConnectedTime() {
|
||||||
|
|
@ -122,33 +108,6 @@ export default {
|
||||||
handleDeviceManage() {
|
handleDeviceManage() {
|
||||||
this.$router.push({ path: '/device-management', query: { agentId: this.device.agentId } });
|
this.$router.push({ path: '/device-management', query: { agentId: this.device.agentId } });
|
||||||
},
|
},
|
||||||
fetchPersonaOptions() {
|
|
||||||
Api.persona.candidates(({ data }) => {
|
|
||||||
if (data?.data) {
|
|
||||||
this.personaOptions = data.data.map(item => ({ id: item.id, agentName: item.agentName }));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleSwitchPersona(agentId) {
|
|
||||||
Api.persona.switchPersona(agentId, (res) => {
|
|
||||||
if (res.data.code === 0) {
|
|
||||||
this.$message.success({ message: '已切换角色', showClose: true });
|
|
||||||
this.$emit('persona-changed');
|
|
||||||
} else {
|
|
||||||
this.$message.error({ message: res.data.msg || '切换失败', showClose: true });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleResetAuto() {
|
|
||||||
Api.persona.resetAuto((res) => {
|
|
||||||
if (res.data.code === 0) {
|
|
||||||
this.$message.success({ message: '已恢复自动匹配', showClose: true });
|
|
||||||
this.$emit('persona-changed');
|
|
||||||
} else {
|
|
||||||
this.$message.error({ message: res.data.msg || '操作失败', showClose: true });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleChatHistory() {
|
handleChatHistory() {
|
||||||
if (this.device.memModelId === 'Memory_nomem') {
|
if (this.device.memModelId === 'Memory_nomem') {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -127,21 +127,6 @@
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
|
||||||
<template #label>
|
|
||||||
<span>扩展字段:</span>
|
|
||||||
</template>
|
|
||||||
<div style="color:#888;font-size:12px;margin-bottom:6px;">
|
|
||||||
作为 system_prompt 模板变量,在提示词里用 {{ext.字段名}} 引用。
|
|
||||||
</div>
|
|
||||||
<div v-for="(item, idx) in form.extFields" :key="idx" style="margin-bottom:6px;">
|
|
||||||
<el-input v-model="item.key" placeholder="字段名(如 age_group)" style="width:35%;" />
|
|
||||||
<el-input v-model="item.value" placeholder="值(如 5岁)" style="width:45%;margin-left:4px;" />
|
|
||||||
<el-button type="danger" size="small" style="margin-left:4px;" @click="form.extFields.splice(idx,1)">删</el-button>
|
|
||||||
</div>
|
|
||||||
<el-button size="small" @click="form.extFields.push({key:'',value:''})">+ 添加字段</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<template #label>
|
<template #label>
|
||||||
<el-tooltip :content="$t('roleConfig.tooltip.memoryHis')" placement="top" effect="light" popper-class="custom-tooltip">
|
<el-tooltip :content="$t('roleConfig.tooltip.memoryHis')" placement="top" effect="light" popper-class="custom-tooltip">
|
||||||
|
|
@ -512,7 +497,6 @@ export default {
|
||||||
ttsPitch: null,
|
ttsPitch: null,
|
||||||
chatHistoryConf: 0,
|
chatHistoryConf: 0,
|
||||||
systemPrompt: "",
|
systemPrompt: "",
|
||||||
extFields: [],
|
|
||||||
summaryMemory: "",
|
summaryMemory: "",
|
||||||
langCode: "",
|
langCode: "",
|
||||||
language: "",
|
language: "",
|
||||||
|
|
@ -618,10 +602,6 @@ export default {
|
||||||
if (this.form.ttsPitch !== null && this.form.ttsPitch !== undefined) {
|
if (this.form.ttsPitch !== null && this.form.ttsPitch !== undefined) {
|
||||||
configData.ttsPitch = this.form.ttsPitch;
|
configData.ttsPitch = this.form.ttsPitch;
|
||||||
}
|
}
|
||||||
// 保存扩展字段(整体覆盖)
|
|
||||||
const extObj = {};
|
|
||||||
(this.form.extFields || []).forEach(f => { if (f.key) extObj[f.key] = f.value; });
|
|
||||||
Api.agent.saveExt(this.$route.query.agentId, extObj, () => {});
|
|
||||||
Api.agent.updateAgentConfig(this.$route.query.agentId, configData, ({ data }) => {
|
Api.agent.updateAgentConfig(this.$route.query.agentId, configData, ({ data }) => {
|
||||||
if (data.code === 0) {
|
if (data.code === 0) {
|
||||||
this.$message.success({
|
this.$message.success({
|
||||||
|
|
@ -650,7 +630,6 @@ export default {
|
||||||
ttsVoiceId: "",
|
ttsVoiceId: "",
|
||||||
chatHistoryConf: 0,
|
chatHistoryConf: 0,
|
||||||
systemPrompt: "",
|
systemPrompt: "",
|
||||||
extFields: [],
|
|
||||||
summaryMemory: "",
|
summaryMemory: "",
|
||||||
langCode: "",
|
langCode: "",
|
||||||
language: "",
|
language: "",
|
||||||
|
|
@ -743,13 +722,6 @@ export default {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载扩展字段
|
|
||||||
this.form.extFields = [];
|
|
||||||
Api.agent.getExt(agentId, ({ data }) => {
|
|
||||||
const obj = data && data.code === 0 && data.data ? data.data : {};
|
|
||||||
this.form.extFields = Object.keys(obj).map(k => ({ key: k, value: obj[k] }));
|
|
||||||
});
|
|
||||||
|
|
||||||
// 同步TTS设置到ttsSettings
|
// 同步TTS设置到ttsSettings
|
||||||
this.ttsSettings = {
|
this.ttsSettings = {
|
||||||
volume: this.form.ttsVolume || 0,
|
volume: this.form.ttsVolume || 0,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue