mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-23 23:53:55 +08:00
update:优化逻辑
This commit is contained in:
@@ -356,6 +356,9 @@ export default {
|
||||
});
|
||||
// 备份原始,以备取消时恢复
|
||||
this.originalFunctions = JSON.parse(JSON.stringify(this.currentFunctions));
|
||||
|
||||
// 确保意图识别选项的可见性正确
|
||||
this.updateIntentOptionsVisibility();
|
||||
});
|
||||
} else {
|
||||
this.$message.error(data.msg || '获取配置失败');
|
||||
@@ -372,6 +375,11 @@ export default {
|
||||
label: item.modelName,
|
||||
isHidden: false
|
||||
})));
|
||||
|
||||
// 如果是意图识别选项,需要根据当前LLM类型更新可见性
|
||||
if (model.type === 'Intent') {
|
||||
this.updateIntentOptionsVisibility();
|
||||
}
|
||||
} else {
|
||||
this.$message.error(data.msg || '获取模型列表失败');
|
||||
}
|
||||
@@ -431,22 +439,8 @@ export default {
|
||||
this.form.chatHistoryConf = 2;
|
||||
}
|
||||
if (type === 'LLM') {
|
||||
let llmType = this.llmModeTypeMap.get(value)
|
||||
let memory
|
||||
for (let item of this.modelOptions['Intent']) {
|
||||
if(item.value == "Intent_nointent" ) {
|
||||
memory = item
|
||||
break
|
||||
}
|
||||
}
|
||||
if (llmType == "openai" || llmType == "ollama") {
|
||||
memory.isHidden = false
|
||||
}else{
|
||||
memory.isHidden = true
|
||||
}
|
||||
if(this.form.model.intentModelId == "Intent_nointent"){
|
||||
this.form.model.intentModelId = '';
|
||||
}
|
||||
// 当LLM类型改变时,更新意图识别选项的可见性
|
||||
this.updateIntentOptionsVisibility();
|
||||
}
|
||||
},
|
||||
fetchAllFunctions() {
|
||||
@@ -488,6 +482,42 @@ export default {
|
||||
}
|
||||
this.showFunctionDialog = false;
|
||||
},
|
||||
updateIntentOptionsVisibility() {
|
||||
// 根据当前选择的LLM类型更新意图识别选项的可见性
|
||||
const currentLlmId = this.form.model.llmModelId;
|
||||
if (!currentLlmId || !this.modelOptions['Intent']) return;
|
||||
|
||||
const llmType = this.llmModeTypeMap.get(currentLlmId);
|
||||
if (!llmType) return;
|
||||
|
||||
this.modelOptions['Intent'].forEach(item => {
|
||||
if (item.value === "Intent_function_call") {
|
||||
// 如果llmType是openai或ollama,允许选择function_call
|
||||
// 否则隐藏function_call选项
|
||||
if (llmType === "openai" || llmType === "ollama") {
|
||||
item.isHidden = false;
|
||||
} else {
|
||||
item.isHidden = true;
|
||||
}
|
||||
} else {
|
||||
// 其他意图识别选项始终可见
|
||||
item.isHidden = false;
|
||||
}
|
||||
});
|
||||
|
||||
// 如果当前选择的意图识别是function_call,但LLM类型不支持,则设置为可选的第一项
|
||||
if (this.form.model.intentModelId === "Intent_function_call" &&
|
||||
llmType !== "openai" && llmType !== "ollama") {
|
||||
// 找到第一个可见的选项
|
||||
const firstVisibleOption = this.modelOptions['Intent'].find(item => !item.isHidden);
|
||||
if (firstVisibleOption) {
|
||||
this.form.model.intentModelId = firstVisibleOption.value;
|
||||
} else {
|
||||
// 如果没有可见选项,设置为Intent_nointent
|
||||
this.form.model.intentModelId = 'Intent_nointent';
|
||||
}
|
||||
}
|
||||
},
|
||||
updateChatHistoryConf() {
|
||||
if (this.form.model.memModelId === 'Memory_nomem') {
|
||||
this.form.chatHistoryConf = 0;
|
||||
|
||||
Reference in New Issue
Block a user