refactor(module-llm):优化聊天模型提示和知识库内容添加

- 简化聊天模型提示文本,移除多余的换行符
- 修改知识库内容添加方式,移除多余的格式化
This commit is contained in:
Liuyang 2025-03-11 17:51:06 +08:00
parent 25ece52385
commit 254ea1c477

View File

@ -365,7 +365,7 @@ public class ConversationServiceImpl implements ConversationService {
&& Objects.equals(expectedGroupId, actualGroupId);
}
public static final String PROMPT="Use the following context as your learned knowledge, inside <context></context> XML tags.\\n\\n<context>\\n{{#context#}}\\n</context>\\n\\nWhen answer to user:\\n- If you don't know, just say that you don't know.\\n- If you don't know when you are not sure, ask for clarification.\\nAvoid mentioning that you obtained the information from the context.\\nAnd answer according to the language of the user's question.\\n\\n";
public static final String PROMPT="Use the following context as your learned knowledge, inside <context></context> XML tags.When answer to user:\\n- If you don't know, just say that you don't know.\\n- If you don't know when you are not sure, ask for clarification.\\nAvoid mentioning that you obtained the information from the context.\\nAnd answer according to the language of the user's question.\\n\\n";
/**
* 公共模型聊天流式处理方法
*
@ -649,7 +649,8 @@ public class ConversationServiceImpl implements ConversationService {
}
if (StringUtils.isNotBlank(pageContent)) {
knowledgeBase.append("\n[知识库内容] [内容如下]").append(pageContent);
// knowledgeBase.append("\n[知识库内容] [内容如下]").append(pageContent);
knowledgeBase.append(pageContent);
log.info("{} 添加知识内容,长度: {}", "[KnowledgeBase]", pageContent.length());
ParagraphHitRateVO paragraphHitRateVO = new ParagraphHitRateVO();