Skip to content

Commit 0f8662f

Browse files
committed
fix:修复对话时系统Prompt被覆盖问题
1 parent fee583f commit 0f8662f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/com/xiaozhi/dialogue/llm/ChatService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,9 @@ public Flux<ChatResponse> chatStream(ChatSession session,SysDevice device, Strin
170170
List<Message> historyMessages = session.getHistoryMessages();
171171

172172
UserMessage userMessage = new UserMessage(message);
173-
Prompt prompt = Prompt.builder().messages(historyMessages).messages(userMessage).
174-
chatOptions(chatOptions).build();
173+
historyMessages.add(userMessage);
174+
Prompt prompt = Prompt.builder().messages(historyMessages).chatOptions(chatOptions).build();
175+
175176
// 调用实际的流式聊天方法
176177
// return chatModel.stream(prompt).map(response -> (response.getResult() == null || response.getResult().getOutput() == null
177178
// || response.getResult().getOutput().getText() == null) ? ""

0 commit comments

Comments
 (0)