update:字段管理添加VLLM和Plugin选项

This commit is contained in:
hrz
2025-06-09 11:39:24 +08:00
parent 24b744b27e
commit 152dbe9dec
5 changed files with 51 additions and 79 deletions
@@ -1,14 +1,15 @@
package xiaozhi.modules.agent.service.impl; package xiaozhi.modules.agent.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import xiaozhi.modules.agent.entity.AgentPluginMapping;
import xiaozhi.modules.agent.service.AgentPluginMappingService;
import xiaozhi.modules.agent.dao.AgentPluginMappingMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import xiaozhi.modules.agent.dao.AgentPluginMappingMapper;
import xiaozhi.modules.agent.entity.AgentPluginMapping;
import xiaozhi.modules.agent.service.AgentPluginMappingService;
/** /**
* @description 针对表【ai_agent_plugin_mapping(Agent与插件的唯一映射表)】的数据库操作Service实现 * @description 针对表【ai_agent_plugin_mapping(Agent与插件的唯一映射表)】的数据库操作Service实现
@@ -26,7 +27,3 @@ public class AgentPluginMappingServiceImpl extends ServiceImpl<AgentPluginMappin
} }
} }
@@ -1,20 +1,21 @@
package xiaozhi.modules.agent.service.impl; package xiaozhi.modules.agent.service.impl;
import java.util.*; import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import xiaozhi.common.constant.Constant; import xiaozhi.common.constant.Constant;
import xiaozhi.common.exception.RenException; import xiaozhi.common.exception.RenException;
import xiaozhi.common.page.PageData; import xiaozhi.common.page.PageData;
@@ -23,7 +24,6 @@ import xiaozhi.common.redis.RedisUtils;
import xiaozhi.common.service.impl.BaseServiceImpl; import xiaozhi.common.service.impl.BaseServiceImpl;
import xiaozhi.common.user.UserDetail; import xiaozhi.common.user.UserDetail;
import xiaozhi.common.utils.JsonUtils; import xiaozhi.common.utils.JsonUtils;
import xiaozhi.common.utils.Result;
import xiaozhi.modules.agent.dao.AgentDao; import xiaozhi.modules.agent.dao.AgentDao;
import xiaozhi.modules.agent.dto.AgentDTO; import xiaozhi.modules.agent.dto.AgentDTO;
import xiaozhi.modules.agent.dto.AgentUpdateDTO; import xiaozhi.modules.agent.dto.AgentUpdateDTO;
@@ -34,7 +34,6 @@ import xiaozhi.modules.agent.service.AgentPluginMappingService;
import xiaozhi.modules.agent.service.AgentService; import xiaozhi.modules.agent.service.AgentService;
import xiaozhi.modules.agent.vo.AgentInfoVO; import xiaozhi.modules.agent.vo.AgentInfoVO;
import xiaozhi.modules.device.service.DeviceService; import xiaozhi.modules.device.service.DeviceService;
import xiaozhi.modules.model.dto.ModelProviderDTO;
import xiaozhi.modules.model.service.ModelConfigService; import xiaozhi.modules.model.service.ModelConfigService;
import xiaozhi.modules.model.service.ModelProviderService; import xiaozhi.modules.model.service.ModelProviderService;
import xiaozhi.modules.security.user.SecurityUser; import xiaozhi.modules.security.user.SecurityUser;
@@ -53,7 +52,6 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
private final ModelProviderService modelProviderService; private final ModelProviderService modelProviderService;
private final AgentChatHistoryService agentChatHistoryService; private final AgentChatHistoryService agentChatHistoryService;
@Override @Override
public PageData<AgentEntity> adminAgentList(Map<String, Object> params) { public PageData<AgentEntity> adminAgentList(Map<String, Object> params) {
IPage<AgentEntity> page = agentDao.selectPage( IPage<AgentEntity> page = agentDao.selectPage(
@@ -262,8 +260,7 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
// 2. 查询当前agent现有的所有映射 // 2. 查询当前agent现有的所有映射
List<AgentPluginMapping> existing = agentPluginMappingService.list( List<AgentPluginMapping> existing = agentPluginMappingService.list(
new QueryWrapper<AgentPluginMapping>() new QueryWrapper<AgentPluginMapping>()
.eq("agent_id", agentId) .eq("agent_id", agentId));
);
Map<String, AgentPluginMapping> existMap = existing.stream() Map<String, AgentPluginMapping> existMap = existing.stream()
.collect(Collectors.toMap(AgentPluginMapping::getPluginId, Function.identity())); .collect(Collectors.toMap(AgentPluginMapping::getPluginId, Function.identity()));
@@ -1,5 +1,5 @@
<template> <template>
<el-drawer :visible.sync="dialogVisible" direction="rtl" size="50%" :wrapperClosable="false" :withHeader="false"> <el-drawer :visible.sync="dialogVisible" direction="rtl" size="70%" :wrapperClosable="false" :withHeader="false">
<!-- 自定义标题区域 --> <!-- 自定义标题区域 -->
<div class="custom-header"> <div class="custom-header">
<div class="header-left"> <div class="header-left">
@@ -64,12 +64,8 @@
<div v-if="currentFunction" class="params-container"> <div v-if="currentFunction" class="params-container">
<el-form :model="currentFunction" size="mini" class="param-form"> <el-form :model="currentFunction" size="mini" class="param-form">
<!-- 遍历 fieldsMeta而不是 params keys --> <!-- 遍历 fieldsMeta而不是 params keys -->
<el-form-item <el-form-item v-for="field in currentFunction.fieldsMeta" :key="field.key" :label="field.label"
v-for="field in currentFunction.fieldsMeta" class="param-item">
:key="field.key"
:label="field.label"
class="param-item"
>
<template #label> <template #label>
<span style="font-size: 16px; margin-right: 6px;">{{ field.key }}</span> <span style="font-size: 16px; margin-right: 6px;">{{ field.key }}</span>
<el-tooltip effect="dark" :content="fieldRemark(field)" placement="top"> <el-tooltip effect="dark" :content="fieldRemark(field)" placement="top">
@@ -77,45 +73,25 @@
</el-tooltip> </el-tooltip>
</template> </template>
<!-- ARRAY --> <!-- ARRAY -->
<el-input <el-input v-if="field.type === 'array'" type="textarea" :rows="4" placeholder="每行一个,回车分隔"
v-if="field.type === 'array'" v-model="textCache[field.key]" @blur="flushArray(field.key)" />
type="textarea"
:rows="4"
placeholder="每行一个,回车分隔"
v-model="textCache[field.key]"
@blur="flushArray(field.key)"
/>
<!-- JSON --> <!-- JSON -->
<el-input <el-input v-else-if="field.type === 'json'" type="textarea" :rows="6" placeholder="请输入合法的 JSON"
v-else-if="field.type === 'json'" v-model="textCache[field.key]" @blur="flushJson(field)" />
type="textarea"
:rows="6"
placeholder="请输入合法的 JSON"
v-model="textCache[field.key]"
@blur="flushJson(field)"
/>
<!-- number --> <!-- number -->
<el-input-number <el-input-number v-else-if="field.type === 'number'" :value="currentFunction.params[field.key]"
v-else-if="field.type === 'number'" @change="val => handleParamChange(currentFunction, field.key, val)" />
:value="currentFunction.params[field.key]"
@change="val => handleParamChange(currentFunction, field.key, val)"
/>
<!-- boolean --> <!-- boolean -->
<el-switch <el-switch v-else-if="field.type === 'boolean' || field.type === 'bool'"
v-else-if="field.type === 'boolean' || field.type === 'bool'"
:value="currentFunction.params[field.key]" :value="currentFunction.params[field.key]"
@change="val => handleParamChange(currentFunction, field.key, val)" @change="val => handleParamChange(currentFunction, field.key, val)" />
/>
<!-- string or fallback --> <!-- string or fallback -->
<el-input <el-input v-else v-model="currentFunction.params[field.key]"
v-else @change="val => handleParamChange(currentFunction, field.key, val)" />
v-model="currentFunction.params[field.key]"
@change="val => handleParamChange(currentFunction, field.key, val)"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
@@ -97,10 +97,10 @@
<el-table-column label="默认值"> <el-table-column label="默认值">
<template slot-scope="scope"> <template slot-scope="scope">
<template v-if="scope.row.editing"> <template v-if="scope.row.editing">
<el-input v-model="scope.row.default_value" placeholder="请输入默认值"></el-input> <el-input v-model="scope.row.default" placeholder="请输入默认值"></el-input>
</template> </template>
<template v-else> <template v-else>
{{ scope.row.default_value }} {{ scope.row.default }}
</template> </template>
</template> </template>
</el-table-column> </el-table-column>
@@ -220,7 +220,7 @@ export default {
key: '', key: '',
label: '', label: '',
type: 'string', type: 'string',
default_value: '', default: '',
selected: false, selected: false,
editing: true editing: true
}); });
@@ -143,9 +143,11 @@ export default {
{ value: "ASR", label: "语音识别" }, { value: "ASR", label: "语音识别" },
{ value: "TTS", label: "语音合成" }, { value: "TTS", label: "语音合成" },
{ value: "LLM", label: "大语言模型" }, { value: "LLM", label: "大语言模型" },
{ value: "VLLM", label: "视觉大语言模型" },
{ value: "Intent", label: "意图识别" }, { value: "Intent", label: "意图识别" },
{ value: "Memory", label: "记忆模块" }, { value: "Memory", label: "记忆模块" },
{ value: "VAD", label: "语音活动检测" } { value: "VAD", label: "语音活动检测" },
{ value: "Plugin", label: "插件工具" }
], ],
currentPage: 1, currentPage: 1,
loading: false, loading: false,