mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
Merge pull request #2574 from xinnan-tech/fix_chatHistoryConf
fix:设置默认记忆不是【无记忆】时,默认chatHistoryConf=2
This commit is contained in:
+14
-1
@@ -395,7 +395,20 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
|
||||
entity.setIntentModelId(template.getIntentModelId());
|
||||
entity.setSystemPrompt(template.getSystemPrompt());
|
||||
entity.setSummaryMemory(template.getSummaryMemory());
|
||||
entity.setChatHistoryConf(template.getChatHistoryConf());
|
||||
|
||||
// 根据记忆模型类型设置默认的chatHistoryConf值
|
||||
if (template.getMemModelId() != null) {
|
||||
if (template.getMemModelId().equals("Memory_nomem")) {
|
||||
// 无记忆功能的模型,默认不记录聊天记录
|
||||
entity.setChatHistoryConf(0);
|
||||
} else {
|
||||
// 有记忆功能的模型,默认记录文本和语音
|
||||
entity.setChatHistoryConf(2);
|
||||
}
|
||||
} else {
|
||||
entity.setChatHistoryConf(template.getChatHistoryConf());
|
||||
}
|
||||
|
||||
entity.setLangCode(template.getLangCode());
|
||||
entity.setLanguage(template.getLanguage());
|
||||
}
|
||||
|
||||
@@ -200,6 +200,13 @@ export default {
|
||||
confirm() {
|
||||
this.saving = true;
|
||||
|
||||
// 校验模型ID不能为纯文字或空格
|
||||
if (this.formData.id && !this.validateModelId(this.formData.id)) {
|
||||
this.$message.error(this.$t('modelConfigDialog.invalidModelId'));
|
||||
this.saving = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.formData.supplier) {
|
||||
this.$message.error(this.$t('addModelDialog.requiredSupplier'));
|
||||
this.saving = false;
|
||||
@@ -254,6 +261,38 @@ export default {
|
||||
this.providerFields = [];
|
||||
this.currentProvider = null;
|
||||
},
|
||||
|
||||
// 校验模型ID:不能为纯文字或空格
|
||||
validateModelId(modelId) {
|
||||
if (!modelId || typeof modelId !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 去除首尾空格
|
||||
const trimmedId = modelId.trim();
|
||||
|
||||
// 检查是否为空或纯空格
|
||||
if (trimmedId === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查是否只包含字母(纯文字)
|
||||
if (/^[a-zA-Z]+$/.test(trimmedId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查是否包含空格
|
||||
if (/\s/.test(trimmedId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 允许字母、数字、下划线、连字符
|
||||
if (!/^[a-zA-Z0-9_-]+$/.test(trimmedId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
+1209
-1208
File diff suppressed because it is too large
Load Diff
@@ -849,6 +849,7 @@ export default {
|
||||
'modelConfigDialog.setDefault': 'Set as Default',
|
||||
'modelConfigDialog.modelId': 'Model ID',
|
||||
'modelConfigDialog.enterModelId': 'If not filled in, it will be generated automatically',
|
||||
'modelConfigDialog.invalidModelId': 'Model ID cannot be pure text or spaces, please use letters, numbers, underscores, or hyphens',
|
||||
'modelConfigDialog.modelName': 'Model Name',
|
||||
'modelConfigDialog.enterModelName': 'Please enter model name',
|
||||
'modelConfigDialog.modelCode': 'Model Code',
|
||||
|
||||
+1209
-1208
File diff suppressed because it is too large
Load Diff
@@ -849,6 +849,7 @@ export default {
|
||||
'modelConfigDialog.setDefault': '设为默认',
|
||||
'modelConfigDialog.modelId': '模型ID',
|
||||
'modelConfigDialog.enterModelId': '未填写将自动生成模型ID',
|
||||
'modelConfigDialog.invalidModelId': '模型ID不能为纯文字或空格,请使用字母、数字、下划线或连字符组合',
|
||||
'modelConfigDialog.modelName': '模型名称',
|
||||
'modelConfigDialog.enterModelName': '请输入模型名称',
|
||||
'modelConfigDialog.modelCode': '模型编码',
|
||||
|
||||
@@ -849,6 +849,7 @@ export default {
|
||||
'modelConfigDialog.setDefault': '設為默認',
|
||||
'modelConfigDialog.modelId': '模型ID',
|
||||
'modelConfigDialog.enterModelId': '未填冩將自動生成模型ID',
|
||||
'modelConfigDialog.invalidModelId': '模型ID不能為純文字或空格,請使用字母、數字、底線或連字符組合',
|
||||
'modelConfigDialog.modelName': '模型名稱',
|
||||
'modelConfigDialog.enterModelName': '請輸入模型名稱',
|
||||
'modelConfigDialog.modelCode': '模型編碼',
|
||||
|
||||
@@ -604,15 +604,14 @@ export default {
|
||||
if (type === "Intent" && value !== "Intent_nointent") {
|
||||
this.fetchAllFunctions();
|
||||
}
|
||||
if (type === "Memory" && value === "Memory_nomem") {
|
||||
this.form.chatHistoryConf = 0;
|
||||
}
|
||||
if (
|
||||
type === "Memory" &&
|
||||
value !== "Memory_nomem" &&
|
||||
(this.form.chatHistoryConf === 0 || this.form.chatHistoryConf === null)
|
||||
) {
|
||||
this.form.chatHistoryConf = 2;
|
||||
if (type === "Memory") {
|
||||
if (value === "Memory_nomem") {
|
||||
// 无记忆功能的模型,默认不记录聊天记录
|
||||
this.form.chatHistoryConf = 0;
|
||||
} else {
|
||||
// 有记忆功能的模型,默认记录文本和语音
|
||||
this.form.chatHistoryConf = 2;
|
||||
}
|
||||
}
|
||||
if (type === "LLM") {
|
||||
// 当LLM类型改变时,更新意图识别选项的可见性
|
||||
|
||||
Reference in New Issue
Block a user