mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 17:13:54 +08:00
update:字段管理添加VLLM和Plugin选项
This commit is contained in:
+13
-16
@@ -1,23 +1,24 @@
|
|||||||
package xiaozhi.modules.agent.service.impl;
|
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 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实现
|
* @description 针对表【ai_agent_plugin_mapping(Agent与插件的唯一映射表)】的数据库操作Service实现
|
||||||
* @createDate 2025-05-25 22:33:17
|
* @createDate 2025-05-25 22:33:17
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AgentPluginMappingServiceImpl extends ServiceImpl<AgentPluginMappingMapper, AgentPluginMapping>
|
public class AgentPluginMappingServiceImpl extends ServiceImpl<AgentPluginMappingMapper, AgentPluginMapping>
|
||||||
implements AgentPluginMappingService{
|
implements AgentPluginMappingService {
|
||||||
private final AgentPluginMappingMapper agentPluginMappingMapper;
|
private final AgentPluginMappingMapper agentPluginMappingMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -26,7 +27,3 @@ public class AgentPluginMappingServiceImpl extends ServiceImpl<AgentPluginMappin
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-9
@@ -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">
|
||||||
@@ -19,9 +19,9 @@
|
|||||||
<div v-if="unselected.length">
|
<div v-if="unselected.length">
|
||||||
<div v-for="func in unselected" :key="func.name" class="function-item">
|
<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)"
|
<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="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>
|
<span>{{ func.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
<el-tooltip class="item" effect="dark" :content="func.description || '暂无功能描述'" placement="top">
|
<el-tooltip class="item" effect="dark" :content="func.description || '暂无功能描述'" placement="top">
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else style="display: flex; justify-content: center; align-items: center;">
|
<div v-else style="display: flex; justify-content: center; align-items: center;">
|
||||||
<el-empty description="没有更多的插件了"/>
|
<el-empty description="没有更多的插件了" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -45,15 +45,15 @@
|
|||||||
<div v-if="selectedList.length > 0">
|
<div v-if="selectedList.length > 0">
|
||||||
<div v-for="func in selectedList" :key="func.name" class="function-item">
|
<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)"
|
<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="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>
|
<span>{{ func.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else style="display: flex; justify-content: center; align-items: center;">
|
<div v-else style="display: flex; justify-content: center; align-items: center;">
|
||||||
<el-empty description="请选择插件功能"/>
|
<el-empty description="请选择插件功能" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -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>
|
||||||
@@ -196,7 +172,7 @@ export default {
|
|||||||
const idx = this.allFunctions.findIndex(f => f.name === saved.name);
|
const idx = this.allFunctions.findIndex(f => f.name === saved.name);
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
// 保留用户之前在 saved.params 上的改动
|
// 保留用户之前在 saved.params 上的改动
|
||||||
this.allFunctions[idx].params = {...saved.params};
|
this.allFunctions[idx].params = { ...saved.params };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 右侧默认指向第一个
|
// 右侧默认指向第一个
|
||||||
@@ -211,9 +187,9 @@ export default {
|
|||||||
flushArray(key) {
|
flushArray(key) {
|
||||||
const text = this.textCache[key] || '';
|
const text = this.textCache[key] || '';
|
||||||
const arr = text
|
const arr = text
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(s => s.trim())
|
.map(s => s.trim())
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
this.handleParamChange(this.currentFunction, key, arr);
|
this.handleParamChange(this.currentFunction, key, arr);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -292,8 +268,8 @@ export default {
|
|||||||
id: f.id,
|
id: f.id,
|
||||||
name: f.name,
|
name: f.name,
|
||||||
params: modified
|
params: modified
|
||||||
? {...modified.params}
|
? { ...modified.params }
|
||||||
: {...f.params}
|
: { ...f.params }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user