From ad4d32a05d73fb02f41a8f47369b2fb0b10139d0 Mon Sep 17 00:00:00 2001 From: rainv123 <2148537152@qq.com> Date: Tue, 21 Apr 2026 11:12:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20agent-models=E6=8E=A5=E5=8F=A3=E8=BF=94?= =?UTF-8?q?=E5=9B=9ESLM=E6=A8=A1=E5=9E=8B=EF=BC=8CLLM=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=BF=94=E5=9B=9E=E6=89=80=E9=80=89SLM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ConfigServiceImpl.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java index 55f23c67..278d4299 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/config/service/impl/ConfigServiceImpl.java @@ -99,6 +99,7 @@ public class ConfigServiceImpl implements ConfigService { null, null, null, + null, result, isCache); @@ -113,7 +114,7 @@ public class ConfigServiceImpl implements ConfigService { // 检查是否为管理控制台请求 String redisKey = RedisKeys.getTmpRegisterMacKey(macAddress); Object isAdminRequest = redisUtils.get(redisKey); - + if (isAdminRequest != null && "true".equals(isAdminRequest)) { // 管理控制台请求,返回getConfig的结果 redisUtils.delete(redisKey); // 使用后清理 @@ -203,10 +204,11 @@ public class ConfigServiceImpl implements ConfigService { mcpEndpoint = mcpEndpoint.replace("/mcp/", "/call/"); result.put("mcp_endpoint", mcpEndpoint); } - + // 获取上下文源配置 AgentContextProviderEntity contextProviderEntity = agentContextProviderService.getByAgentId(agent.getId()); - if (contextProviderEntity != null && contextProviderEntity.getContextProviders() != null && !contextProviderEntity.getContextProviders().isEmpty()) { + if (contextProviderEntity != null && contextProviderEntity.getContextProviders() != null + && !contextProviderEntity.getContextProviders().isEmpty()) { result.put("context_providers", contextProviderEntity.getContextProviders()); } @@ -229,6 +231,7 @@ public class ConfigServiceImpl implements ConfigService { agent.getAsrModelId(), agent.getLlmModelId(), agent.getVllmModelId(), + agent.getSlmModelId(), agent.getTtsModelId(), agent.getMemModelId(), agent.getIntentModelId(), @@ -410,6 +413,7 @@ public class ConfigServiceImpl implements ConfigService { String asrModelId, String llmModelId, String vllmModelId, + String slmModelId, String ttsModelId, String memModelId, String intentModelId, @@ -418,9 +422,9 @@ public class ConfigServiceImpl implements ConfigService { boolean isCache) { Map selectedModule = new HashMap<>(); - String[] modelTypes = { "VAD", "ASR", "TTS", "Memory", "Intent", "LLM", "VLLM", "RAG" }; + String[] modelTypes = { "VAD", "ASR", "TTS", "Memory", "Intent", "LLM", "VLLM", "SLM", "RAG" }; String[] modelIds = { vadModelId, asrModelId, ttsModelId, memModelId, intentModelId, llmModelId, vllmModelId, - ragModelId }; + slmModelId, ragModelId }; String intentLLMModelId = null; String memLocalShortLLMModelId = null; @@ -456,7 +460,7 @@ public class ConfigServiceImpl implements ConfigService { // 火山引擎声音克隆需要替换resource_id Map map = (Map) model.getConfigJson(); if (Constant.VOICE_CLONE_HUOSHAN_DOUBLE_STREAM.equals(map.get("type"))) { - // 如果voice是”S_“开头的,使用seed-icl-1.0 + // 如果voice是”S_”开头的,使用seed-icl-1.0 if (voice != null && voice.startsWith("S_")) { map.put("resource_id", "seed-icl-1.0"); } @@ -474,7 +478,7 @@ public class ConfigServiceImpl implements ConfigService { if (map.get("functions") != null) { String functionStr = (String) map.get("functions"); if (StringUtils.isNotBlank(functionStr)) { - String[] functions = functionStr.split("\\;"); + String[] functions = functionStr.split(";"); map.put("functions", functions); } } @@ -507,6 +511,15 @@ public class ConfigServiceImpl implements ConfigService { typeConfig.put(memLocalShortLLM.getId(), memLocalShortLLM.getConfigJson()); } } + // LLM也返回所选的SLM,如果同名id则不重复显示 + if (StringUtils.isNotBlank(slmModelId) && !slmModelId.equals(llmModelId)) { + if (!typeConfig.containsKey(slmModelId)) { + ModelConfigEntity slmModel = modelConfigService.getModelByIdFromCache(slmModelId); + if (slmModel != null && slmModel.getConfigJson() != null) { + typeConfig.put(slmModel.getId(), slmModel.getConfigJson()); + } + } + } } } result.put(modelTypes[i], typeConfig);