mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
Merge pull request #2522 from xinnan-tech/KnowledgeBase_fix
Knowledge base fix
This commit is contained in:
+2
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import xiaozhi.common.utils.JsonUtils;
|
||||
import xiaozhi.modules.agent.dao.AgentPluginMappingMapper;
|
||||
import xiaozhi.modules.agent.entity.AgentPluginMapping;
|
||||
@@ -27,6 +28,7 @@ import xiaozhi.modules.model.service.ModelConfigService;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AgentPluginMappingServiceImpl extends ServiceImpl<AgentPluginMappingMapper, AgentPluginMapping>
|
||||
implements AgentPluginMappingService {
|
||||
private final AgentPluginMappingMapper agentPluginMappingMapper;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package xiaozhi.modules.knowledge.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import xiaozhi.common.dao.BaseDao;
|
||||
import xiaozhi.modules.knowledge.entity.KnowledgeBaseEntity;
|
||||
@@ -11,4 +12,11 @@ import xiaozhi.modules.knowledge.entity.KnowledgeBaseEntity;
|
||||
@Mapper
|
||||
public interface KnowledgeBaseDao extends BaseDao<KnowledgeBaseEntity> {
|
||||
|
||||
/**
|
||||
* 根据知识库ID删除相关的插件映射记录
|
||||
*
|
||||
* @param knowledgeBaseId 知识库ID
|
||||
*/
|
||||
void deletePluginMappingByKnowledgeBaseId(@Param("knowledgeBaseId") String knowledgeBaseId);
|
||||
|
||||
}
|
||||
+6
@@ -314,6 +314,12 @@ public class KnowledgeBaseServiceImpl extends BaseServiceImpl<KnowledgeBaseDao,
|
||||
|
||||
// API删除成功后再删除本地记录
|
||||
if (apiDeleteSuccess) {
|
||||
log.info("开始删除ai_agent_plugin_mapping表中与知识库ID '{}' 相关的映射记录", entity.getId());
|
||||
|
||||
// 先删除相关的插件映射记录
|
||||
knowledgeBaseDao.deletePluginMappingByKnowledgeBaseId(entity.getId());
|
||||
log.info("插件映射记录删除完成");
|
||||
|
||||
int deleteCount = knowledgeBaseDao.deleteById(entity.getId());
|
||||
log.info("本地数据库删除结果: {}", deleteCount > 0 ? "成功" : "失败");
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
UPDATE `ai_model_config` SET
|
||||
`doc_link` = 'https://github.com/infiniflow/ragflow/blob/main/README_zh.md',
|
||||
`remark` = '详细部署教程参考:https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/ragflow-integration.md
|
||||
部署成功,注冊登录后,点击右上角头像,获得RAGFlow的API KEY和API服务器地址。使用RAGFlow前请在Model Provider中添加模型和设置默认模型。' WHERE `id` = 'RAG_RAGFlow';
|
||||
|
||||
update `ai_model_config` set `model_name` = '外挂的大模型意图识别' where `id` = 'Intent_intent_llm';
|
||||
update `ai_model_config` set `model_name` = '大模型自主函数调用' where `id` = 'Intent_function_call';
|
||||
|
||||
update `ai_model_provider` set `name` = '外挂的大模型意图识别' , `fields` = '[{"key":"llm","label":"引用的LLM模型","type":"string"}]' where id = 'SYSTEM_Intent_intent_llm';
|
||||
update `ai_model_provider` set `name` = '大模型自主函数调用' where id = 'SYSTEM_Intent_function_call';
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
UPDATE `ai_model_config` SET
|
||||
`doc_link` = 'https://github.com/infiniflow/ragflow/blob/main/README_zh.md',
|
||||
`remark` = '详细部署教程参考:https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/ragflow-integration.md
|
||||
部署成功,注冊登录后,点击右上角头像,获得RAGFlow的API KEY和API服务器地址。使用RAGFlow前请在Model Provider中添加模型和设置默认模型。' WHERE `id` = 'RAG_RAGFlow';
|
||||
|
||||
update `ai_model_config` set `model_name` = '外挂的大模型意图识别' where `id` = 'Intent_intent_llm';
|
||||
update `ai_model_config` set `model_name` = '大模型自主函数调用' where `id` = 'Intent_function_call';
|
||||
update `ai_model_config` set `model_name` = '百炼智能体应用' where `id` = 'LLM_AliAppLLM';
|
||||
|
||||
update `ai_model_provider` set `name` = '外挂的大模型意图识别' , `fields` = '[{"key":"llm","label":"引用的LLM模型","type":"string"}]' where id = 'SYSTEM_Intent_intent_llm';
|
||||
update `ai_model_provider` set `name` = '大模型自主函数调用' where id = 'SYSTEM_Intent_function_call';
|
||||
|
||||
UPDATE ai_model_config set model_name = 'Linkerai(流式)' where id = 'TTS_LinkeraiTTS';
|
||||
UPDATE ai_model_config set model_name = '火山引擎(流式)' where id = 'TTS_HuoshanDoubleStreamTTS';
|
||||
UPDATE ai_model_config set model_name = '阿里百炼(流式)' where id = 'TTS_AliBLStreamTTS';
|
||||
UPDATE ai_model_config set model_name = '科大讯飞(流式)' where id = 'TTS_XunFeiStreamTTS';
|
||||
UPDATE ai_model_config set model_name = 'Minimax(流式)' where id = 'TTS_MinimaxStreamTTS';
|
||||
UPDATE ai_model_config set model_name = '阿里云(流式)' where id = 'TTS_AliyunStreamTTS';
|
||||
UPDATE ai_model_config set model_name = 'PaddleSpeech(流式)' where id = 'TTS_PaddleSpeechTTS';
|
||||
UPDATE ai_model_config set model_name = 'IndexTTS(流式)' where id = 'TTS_IndexStreamTTS';
|
||||
|
||||
update ai_model_config SET sort = 2 where id = 'TTS_LinkeraiTTS';
|
||||
update ai_model_config SET sort = 3 where id = 'TTS_HuoshanDoubleStreamTTS';
|
||||
update ai_model_config SET sort = 4 where id = 'TTS_AliBLStreamTTS';
|
||||
update ai_model_config SET sort = 5 where id = 'TTS_XunFeiStreamTTS';
|
||||
update ai_model_config SET sort = 6 where id = 'TTS_MinimaxStreamTTS';
|
||||
update ai_model_config SET sort = 7 where id = 'TTS_AliyunStreamTTS';
|
||||
update ai_model_config SET sort = 8 where id = 'TTS_IndexStreamTTS';
|
||||
update ai_model_config SET sort = 9 where id = 'TTS_PaddleSpeechTTS';
|
||||
update ai_model_config SET sort = 10 where id = 'TTS_DoubaoTTS';
|
||||
update ai_model_config SET sort = 11 where id = 'TTS_TencentTTS';
|
||||
update ai_model_config SET sort = 12 where id = 'TTS_AliyunTTS';
|
||||
update ai_model_config SET sort = 13 where id = 'TTS_OpenAITTS';
|
||||
update ai_model_config SET sort = 14 where id = 'TTS_CosyVoiceSiliconflow';
|
||||
update ai_model_config SET sort = 15 where id = 'TTS_CozeCnTTS';
|
||||
update ai_model_config SET sort = 16 where id = 'TTS_FishSpeech';
|
||||
update ai_model_config SET sort = 17 where id = 'TTS_GPT_SOVITS_V3';
|
||||
update ai_model_config SET sort = 18 where id = 'TTS_GPT_SOVITS_V2';
|
||||
update ai_model_config SET sort = 19 where id = 'TTS_TTS302AI';
|
||||
update ai_model_config SET sort = 20 where id = 'TTS_GizwitsTTS';
|
||||
update ai_model_config SET sort = 21 where id = 'TTS_VolcesAiGatewayTTS';
|
||||
update ai_model_config SET sort = 22 where id = 'TTS_ACGNTTS';
|
||||
update ai_model_config SET sort = 23 where id = 'TTS_CustomTTS';
|
||||
|
||||
UPDATE ai_model_config set model_name = '讯飞语音识别(流式)' where id = 'ASR_XunfeiStream';
|
||||
UPDATE ai_model_config set model_name = 'Qwen3Flash语音识别' where id = 'ASR_Qwen3Flash';
|
||||
|
||||
update ai_model_config SET sort = 2 where id = 'ASR_FunASRServer';
|
||||
update ai_model_config SET sort = 3 where id = 'ASR_XunfeiStream';
|
||||
update ai_model_config SET sort = 4 where id = 'ASR_AliyunStreamASR';
|
||||
update ai_model_config SET sort = 5 where id = 'ASR_DoubaoStreamASR';
|
||||
update ai_model_config SET sort = 6 where id = 'ASR_TencentASR';
|
||||
update ai_model_config SET sort = 7 where id = 'ASR_BaiduASR';
|
||||
update ai_model_config SET sort = 8 where id = 'ASR_DoubaoASR';
|
||||
update ai_model_config SET sort = 9 where id = 'ASR_AliyunASR';
|
||||
update ai_model_config SET sort = 10 where id = 'ASR_SherpaASR';
|
||||
update ai_model_config SET sort = 11 where id = 'ASR_OpenaiASR';
|
||||
update ai_model_config SET sort = 12 where id = 'ASR_GroqASR';
|
||||
update ai_model_config SET sort = 13 where id = 'ASR_VoskASR';
|
||||
update ai_model_config SET sort = 14 where id = 'ASR_Qwen3Flash';
|
||||
|
||||
UPDATE ai_model_config SET config_json='{\"type\": \"openai\", \"base_url\": \"https://ark.cn-beijing.volces.com/api/v3\", \"model_name\": \"doubao-1-5-pro-32k-250115\", \"api_key\": \"你的api_key\"}' where id = 'LLM_DoubaoLLM' AND config_json LIKE '%你的api_key"%';
|
||||
@@ -417,9 +417,9 @@ databaseChangeLog:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202510251150.sql
|
||||
- changeSet:
|
||||
id: 202511131020
|
||||
id: 202511131023
|
||||
author: hrz
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202511131020.sql
|
||||
path: classpath:db/changelog/202511131023.sql
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="xiaozhi.modules.knowledge.dao.KnowledgeBaseDao">
|
||||
|
||||
<resultMap id="BaseResultMap" type="xiaozhi.modules.knowledge.entity.KnowledgeBaseEntity">
|
||||
<id property="id" column="id" jdbcType="VARCHAR"/>
|
||||
<result property="datasetId" column="dataset_id" jdbcType="VARCHAR"/>
|
||||
<result property="ragModelId" column="rag_model_id" jdbcType="VARCHAR"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="description" column="description" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="status" jdbcType="TINYINT"/>
|
||||
<result property="creator" column="creator" jdbcType="BIGINT"/>
|
||||
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
||||
<result property="updater" column="updater" jdbcType="BIGINT"/>
|
||||
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 根据知识库ID删除相关的插件映射记录 -->
|
||||
<delete id="deletePluginMappingByKnowledgeBaseId">
|
||||
DELETE FROM ai_agent_plugin_mapping
|
||||
WHERE plugin_id = #{knowledgeBaseId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -6,7 +6,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('knowledgeBaseDialog.description')" prop="description">
|
||||
<el-input v-model="form.description" :placeholder="$t('knowledgeBaseDialog.descriptionPlaceholder')"
|
||||
type="textarea" :rows="4" maxlength="200" show-word-limit></el-input>
|
||||
type="textarea" :rows="4" maxlength="300" show-word-limit></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('knowledgeBaseDialog.ragModel')" prop="ragModelId">
|
||||
<el-select v-model="form.ragModelId" :placeholder="$t('knowledgeBaseDialog.ragModelPlaceholder')" clearable
|
||||
@@ -78,7 +78,7 @@ export default {
|
||||
trigger: "blur"
|
||||
},
|
||||
{
|
||||
max: 200,
|
||||
max: 300,
|
||||
message: this.$t("knowledgeBaseDialog.descriptionLength"),
|
||||
trigger: "blur"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user