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,23 +1,24 @@
package xiaozhi.modules.agent.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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 java.util.List;
import org.springframework.stereotype.Service;
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实现
* @createDate 2025-05-25 22:33:17
*/
* @description 针对表【ai_agent_plugin_mapping(Agent与插件的唯一映射表)】的数据库操作Service实现
* @createDate 2025-05-25 22:33:17
*/
@Service
@RequiredArgsConstructor
public class AgentPluginMappingServiceImpl extends ServiceImpl<AgentPluginMappingMapper, AgentPluginMapping>
implements AgentPluginMappingService{
implements AgentPluginMappingService {
private final AgentPluginMappingMapper agentPluginMappingMapper;
@Override
@@ -26,7 +27,3 @@ public class AgentPluginMappingServiceImpl extends ServiceImpl<AgentPluginMappin
}
}
@@ -1,20 +1,21 @@
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.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.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import xiaozhi.common.constant.Constant;
import xiaozhi.common.exception.RenException;
import xiaozhi.common.page.PageData;
@@ -23,7 +24,6 @@ import xiaozhi.common.redis.RedisUtils;
import xiaozhi.common.service.impl.BaseServiceImpl;
import xiaozhi.common.user.UserDetail;
import xiaozhi.common.utils.JsonUtils;
import xiaozhi.common.utils.Result;
import xiaozhi.modules.agent.dao.AgentDao;
import xiaozhi.modules.agent.dto.AgentDTO;
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.vo.AgentInfoVO;
import xiaozhi.modules.device.service.DeviceService;
import xiaozhi.modules.model.dto.ModelProviderDTO;
import xiaozhi.modules.model.service.ModelConfigService;
import xiaozhi.modules.model.service.ModelProviderService;
import xiaozhi.modules.security.user.SecurityUser;
@@ -53,7 +52,6 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
private final ModelProviderService modelProviderService;
private final AgentChatHistoryService agentChatHistoryService;
@Override
public PageData<AgentEntity> adminAgentList(Map<String, Object> params) {
IPage<AgentEntity> page = agentDao.selectPage(
@@ -262,8 +260,7 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
// 2. 查询当前agent现有的所有映射
List<AgentPluginMapping> existing = agentPluginMappingService.list(
new QueryWrapper<AgentPluginMapping>()
.eq("agent_id", agentId)
);
.eq("agent_id", agentId));
Map<String, AgentPluginMapping> existMap = existing.stream()
.collect(Collectors.toMap(AgentPluginMapping::getPluginId, Function.identity()));
@@ -1,5 +1,5 @@
<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="header-left">
@@ -19,9 +19,9 @@
<div v-if="unselected.length">
<div v-for="func in unselected" :key="func.name" class="function-item">
<el-checkbox :label="func.name" v-model="selectedNames" @change="(val) => handleCheckboxChange(func, val)"
@click.native.stop></el-checkbox>
@click.native.stop></el-checkbox>
<div class="func-tag" @click="handleFunctionClick(func)">
<div class="color-dot" :style="{backgroundColor: getFunctionColor(func.name)}"></div>
<div class="color-dot" :style="{ backgroundColor: getFunctionColor(func.name) }"></div>
<span>{{ func.name }}</span>
</div>
<el-tooltip class="item" effect="dark" :content="func.description || '暂无功能描述'" placement="top">
@@ -30,7 +30,7 @@
</div>
</div>
<div v-else style="display: flex; justify-content: center; align-items: center;">
<el-empty description="没有更多的插件了"/>
<el-empty description="没有更多的插件了" />
</div>
</div>
</div>
@@ -45,15 +45,15 @@
<div v-if="selectedList.length > 0">
<div v-for="func in selectedList" :key="func.name" class="function-item">
<el-checkbox :label="func.name" v-model="selectedNames" @change="(val) => handleCheckboxChange(func, val)"
@click.native.stop></el-checkbox>
@click.native.stop></el-checkbox>
<div class="func-tag" @click="handleFunctionClick(func)">
<div class="color-dot" :style="{backgroundColor: getFunctionColor(func.name)}"></div>
<div class="color-dot" :style="{ backgroundColor: getFunctionColor(func.name) }"></div>
<span>{{ func.name }}</span>
</div>
</div>
</div>
<div v-else style="display: flex; justify-content: center; align-items: center;">
<el-empty description="请选择插件功能"/>
<el-empty description="请选择插件功能" />
</div>
</div>
</div>
@@ -64,12 +64,8 @@
<div v-if="currentFunction" class="params-container">
<el-form :model="currentFunction" size="mini" class="param-form">
<!-- 遍历 fieldsMeta而不是 params keys -->
<el-form-item
v-for="field in currentFunction.fieldsMeta"
:key="field.key"
:label="field.label"
class="param-item"
>
<el-form-item v-for="field in currentFunction.fieldsMeta" :key="field.key" :label="field.label"
class="param-item">
<template #label>
<span style="font-size: 16px; margin-right: 6px;">{{ field.key }}</span>
<el-tooltip effect="dark" :content="fieldRemark(field)" placement="top">
@@ -77,45 +73,25 @@
</el-tooltip>
</template>
<!-- ARRAY -->
<el-input
v-if="field.type === 'array'"
type="textarea"
:rows="4"
placeholder="每行一个,回车分隔"
v-model="textCache[field.key]"
@blur="flushArray(field.key)"
/>
<el-input v-if="field.type === 'array'" type="textarea" :rows="4" placeholder="每行一个,回车分隔"
v-model="textCache[field.key]" @blur="flushArray(field.key)" />
<!-- JSON -->
<el-input
v-else-if="field.type === 'json'"
type="textarea"
:rows="6"
placeholder="请输入合法的 JSON"
v-model="textCache[field.key]"
@blur="flushJson(field)"
/>
<el-input v-else-if="field.type === 'json'" type="textarea" :rows="6" placeholder="请输入合法的 JSON"
v-model="textCache[field.key]" @blur="flushJson(field)" />
<!-- number -->
<el-input-number
v-else-if="field.type === 'number'"
:value="currentFunction.params[field.key]"
@change="val => handleParamChange(currentFunction, field.key, val)"
/>
<el-input-number v-else-if="field.type === 'number'" :value="currentFunction.params[field.key]"
@change="val => handleParamChange(currentFunction, field.key, val)" />
<!-- boolean -->
<el-switch
v-else-if="field.type === 'boolean' || field.type === 'bool'"
:value="currentFunction.params[field.key]"
@change="val => handleParamChange(currentFunction, field.key, val)"
/>
<el-switch v-else-if="field.type === 'boolean' || field.type === 'bool'"
:value="currentFunction.params[field.key]"
@change="val => handleParamChange(currentFunction, field.key, val)" />
<!-- string or fallback -->
<el-input
v-else
v-model="currentFunction.params[field.key]"
@change="val => handleParamChange(currentFunction, field.key, val)"
/>
<el-input v-else v-model="currentFunction.params[field.key]"
@change="val => handleParamChange(currentFunction, field.key, val)" />
</el-form-item>
</el-form>
</div>
@@ -196,7 +172,7 @@ export default {
const idx = this.allFunctions.findIndex(f => f.name === saved.name);
if (idx >= 0) {
// 保留用户之前在 saved.params 上的改动
this.allFunctions[idx].params = {...saved.params};
this.allFunctions[idx].params = { ...saved.params };
}
});
// 右侧默认指向第一个
@@ -211,9 +187,9 @@ export default {
flushArray(key) {
const text = this.textCache[key] || '';
const arr = text
.split('\n')
.map(s => s.trim())
.filter(Boolean);
.split('\n')
.map(s => s.trim())
.filter(Boolean);
this.handleParamChange(this.currentFunction, key, arr);
},
@@ -292,8 +268,8 @@ export default {
id: f.id,
name: f.name,
params: modified
? {...modified.params}
: {...f.params}
? { ...modified.params }
: { ...f.params }
}
});
@@ -97,10 +97,10 @@
<el-table-column label="默认值">
<template slot-scope="scope">
<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 v-else>
{{ scope.row.default_value }}
{{ scope.row.default }}
</template>
</template>
</el-table-column>
@@ -220,7 +220,7 @@ export default {
key: '',
label: '',
type: 'string',
default_value: '',
default: '',
selected: false,
editing: true
});
@@ -143,9 +143,11 @@ export default {
{ value: "ASR", label: "语音识别" },
{ value: "TTS", label: "语音合成" },
{ value: "LLM", label: "大语言模型" },
{ value: "VLLM", label: "视觉大语言模型" },
{ value: "Intent", label: "意图识别" },
{ value: "Memory", label: "记忆模块" },
{ value: "VAD", label: "语音活动检测" }
{ value: "VAD", label: "语音活动检测" },
{ value: "Plugin", label: "插件工具" }
],
currentPage: 1,
loading: false,