From 6d907b6adf2b6fdecb8675e483c7f2d308915a80 Mon Sep 17 00:00:00 2001 From: wangyong <48429126+wangyong00@users.noreply.github.com> Date: Tue, 15 Jul 2025 10:17:03 +0800 Subject: [PATCH] =?UTF-8?q?(fix)(headless-chat)=20=20=E4=BF=AE=E5=A4=8DEmb?= =?UTF-8?q?eddingMatchStrategy.detectByBatch()=20NPE=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=EF=BC=8C=E5=BD=93chatQueryContext.getRequest().getChatAppConfi?= =?UTF-8?q?g()=E4=B8=BAnull=20(#2333)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../headless/chat/mapper/EmbeddingMatchStrategy.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/EmbeddingMatchStrategy.java b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/EmbeddingMatchStrategy.java index da06ed831..a7016c558 100644 --- a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/EmbeddingMatchStrategy.java +++ b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/mapper/EmbeddingMatchStrategy.java @@ -3,6 +3,7 @@ package com.tencent.supersonic.headless.chat.mapper; import com.alibaba.fastjson.JSONObject; import com.google.common.collect.Lists; import com.hankcs.hanlp.seg.common.Term; +import com.tencent.supersonic.common.pojo.ChatModelConfig; import com.tencent.supersonic.headless.api.pojo.response.S2Term; import com.tencent.supersonic.headless.chat.ChatQueryContext; import com.tencent.supersonic.headless.chat.knowledge.EmbeddingResult; @@ -167,9 +168,13 @@ public class EmbeddingMatchStrategy extends BatchMatchStrategy variable.put("retrievedInfo", JSONObject.toJSONString(results)); Prompt prompt = PromptTemplate.from(LLM_FILTER_PROMPT).apply(variable); - ChatLanguageModel chatLanguageModel = - ModelProvider.getChatModel(chatQueryContext.getRequest().getChatAppConfig() - .get("REWRITE_MULTI_TURN").getChatModelConfig()); + + ChatModelConfig chatModelConfig=null; + if(chatQueryContext.getRequest().getChatAppConfig()!=null + && chatQueryContext.getRequest().getChatAppConfig().containsKey("REWRITE_MULTI_TURN")){ + chatModelConfig=chatQueryContext.getRequest().getChatAppConfig().get("REWRITE_MULTI_TURN").getChatModelConfig(); + } + ChatLanguageModel chatLanguageModel = ModelProvider.getChatModel(chatModelConfig); String response = chatLanguageModel.generate(prompt.toUserMessage().singleText()); if (StringUtils.isBlank(response)) {