mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 11:13:55 +08:00
完成“配置智能体“功能
This commit is contained in:
@@ -221,5 +221,22 @@ export default {
|
|||||||
});
|
});
|
||||||
}).send();
|
}).send();
|
||||||
},
|
},
|
||||||
|
// 智能体配置
|
||||||
|
updateAgentConfig(agentId, configData, callback) {
|
||||||
|
RequestService.sendRequest()
|
||||||
|
.url(`${getServiceUrl()}/api/v1/user/agent/${agentId}`)
|
||||||
|
.method('PUT')
|
||||||
|
.data(configData)
|
||||||
|
.success((res) => {
|
||||||
|
RequestService.clearRequestTime();
|
||||||
|
callback(res);
|
||||||
|
})
|
||||||
|
.fail((err) => {
|
||||||
|
console.error('保存配置失败:', err);
|
||||||
|
RequestService.reAjaxFun(() => {
|
||||||
|
this.updateAgentConfig(agentId, configData, callback);
|
||||||
|
});
|
||||||
|
}).send();
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="welcome">
|
<div class="welcome">
|
||||||
<!-- 公共头部 -->
|
|
||||||
<HeaderBar/>
|
<HeaderBar/>
|
||||||
<el-main style="padding: 16px;display: flex;flex-direction: column;">
|
<el-main style="padding: 16px;display: flex;flex-direction: column;">
|
||||||
<div style="border-radius: 16px;background: #fafcfe; border: 1px solid #e8f0ff;">
|
<div style="border-radius: 16px;background: #fafcfe; border: 1px solid #e8f0ff;">
|
||||||
@@ -51,16 +50,16 @@
|
|||||||
<el-form-item label="记忆体:">
|
<el-form-item label="记忆体:">
|
||||||
<div class="textarea-box">
|
<div class="textarea-box">
|
||||||
<el-input type="textarea" rows="5" resize="none" placeholder="请输入内容"
|
<el-input type="textarea" rows="5" resize="none" placeholder="请输入内容"
|
||||||
v-model="form.memModelld" maxlength="1000"/>
|
v-model="form.langCode" maxlength="1000"/>
|
||||||
<div class="prompt-bottom">
|
<div class="prompt-bottom">
|
||||||
<div style="display: flex;gap: 8px;align-items: center;">
|
<div style="display: flex;gap: 8px;align-items: center;">
|
||||||
<div style="color: #979db1;font-size: 11px;">当前记忆(每次对话后重新生成)</div>
|
<div style="color: #979db1;font-size: 11px;">当前记忆(每次对话后重新生成)</div>
|
||||||
<div class="clear-btn">
|
<div class="clear-btn" @click="clearMemory">
|
||||||
<i class="el-icon-delete-solid" style="font-size: 11px;"/>
|
<i class="el-icon-delete-solid" style="font-size: 11px;"/>
|
||||||
清除
|
清除
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="color: #979db1;font-size:11px;">{{ form.systemPrompt.length }}/1000</div>
|
<div style="color: #979db1;font-size:11px;">{{ form.langCode.length }}/1000</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -127,20 +126,42 @@ export default {
|
|||||||
{ value: '选项2', label: '双皮奶' }
|
{ value: '选项2', label: '双皮奶' }
|
||||||
],
|
],
|
||||||
models: [
|
models: [
|
||||||
{ label: '大语言模型(LLM)', key: 'llm' },
|
{ label: '大语言模型(LLM)', key: 'llmModelId' },
|
||||||
{ label: '语音识别(ASR)', key: 'asr' },
|
{ label: '语音识别(ASR)', key: 'asrModelId' },
|
||||||
{ label: '语音活动检测模型(VAD)', key: 'vad' },
|
{ label: '语音活动检测模型(VAD)', key: 'vadModelId' },
|
||||||
{ label: '语音合成模型(TTS)', key: 'tts' },
|
{ label: '语音合成模型(TTS)', key: 'ttsModelId' },
|
||||||
{ label: '意图识别模型(Intent)', key: 'intent' },
|
{ label: '意图识别模型(Intent)', key: 'intentModelId' },
|
||||||
{ label: '记忆模型(Memory)', key: 'memory' }
|
{ label: '记忆模型(Memory)', key: 'memModelId' }
|
||||||
],
|
],
|
||||||
templates: ['台湾女友', '土豆子', '英语老师', '好奇小男孩', '汪汪队队长']
|
templates: ['台湾女友', '土豆子', '英语老师', '好奇小男孩', '汪汪队队长']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
saveConfig() {
|
saveConfig() {
|
||||||
// 此处写保存配置逻辑
|
const configData = {
|
||||||
this.$message.success('配置已保存')
|
agentCode: this.form.agentCode,
|
||||||
|
agentName: this.form.agentName,
|
||||||
|
asrModelId: this.form.model.asrModelId,
|
||||||
|
vadModelId: this.form.model.vadModelId,
|
||||||
|
llmModelId: this.form.model.llmModelId,
|
||||||
|
ttsModelId: this.form.model.ttsModelId,
|
||||||
|
ttsVoiceId: this.form.ttsVoiceId,
|
||||||
|
memModelId: this.form.model.memModelId,
|
||||||
|
intentModelId: this.form.model.intentModelId,
|
||||||
|
systemPrompt: this.form.systemPrompt,
|
||||||
|
langCode: this.form.langCode,
|
||||||
|
language: this.form.language,
|
||||||
|
sort: this.form.sort
|
||||||
|
};
|
||||||
|
import('@/apis/module/user').then(({ default: userApi }) => {
|
||||||
|
userApi.updateAgentConfig(this.$route.query.agentId, configData, ({data}) => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.$message.success('配置保存成功');
|
||||||
|
} else {
|
||||||
|
this.$message.error(data.msg || '配置保存失败');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
resetConfig() {
|
resetConfig() {
|
||||||
this.$confirm('确定要重置配置吗?', '提示', {
|
this.$confirm('确定要重置配置吗?', '提示', {
|
||||||
@@ -174,28 +195,33 @@ export default {
|
|||||||
this.form.name = template;
|
this.form.name = template;
|
||||||
this.$message.success(`已选择模板:${template}`);
|
this.$message.success(`已选择模板:${template}`);
|
||||||
},
|
},
|
||||||
fetchAgentConfig(agentId) {
|
fetchAgentConfig(agentId) {
|
||||||
import('@/apis/module/user').then(({ default: userApi }) => {
|
import('@/apis/module/user').then(({ default: userApi }) => {
|
||||||
userApi.getDeviceConfig(agentId, ({ data }) => {
|
userApi.getDeviceConfig(agentId, ({ data }) => {
|
||||||
if (data.code === 0) {
|
if (data.code === 0) {
|
||||||
this.form = {
|
this.form = {
|
||||||
...this.form,
|
...this.form,
|
||||||
...data.data,
|
...data.data,
|
||||||
model: {
|
model: {
|
||||||
ttsModelId: data.data.ttsModelId,
|
ttsModelId: data.data.ttsModelId,
|
||||||
vadModelId: data.data.vadModelId,
|
vadModelId: data.data.vadModelId,
|
||||||
asrModelId: data.data.asrModelId,
|
asrModelId: data.data.asrModelId,
|
||||||
llmModelId: data.data.llmModelId,
|
llmModelId: data.data.llmModelId,
|
||||||
memModelId: data.data.memModelId,
|
memModelId: data.data.memModelId,
|
||||||
intentModelId: data.data.intentModelId
|
intentModelId: data.data.intentModelId
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(data.msg || '获取配置失败');
|
this.$message.error(data.msg || '获取配置失败');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
}
|
// 清空记忆体内容
|
||||||
|
clearMemory() {
|
||||||
|
this.form.langCode = "";
|
||||||
|
this.$message.success("记忆体已清空");
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
const agentId = this.$route.query.agentId;
|
const agentId = this.$route.query.agentId;
|
||||||
|
|||||||
Reference in New Issue
Block a user