fix: Remove unreachable else-if branch in PromptChatMemoryAdvisor (#3395)
Fixes: #3395 Auto-cherry-pick to 1.0.x Signed-off-by: aliqingdong <229436569@qq.com> Co-authored-by: aliqingdong <229436569@qq.com>
This commit is contained in:
@@ -141,18 +141,18 @@ public final class PromptChatMemoryAdvisor implements BaseChatMemoryAdvisor {
|
||||
@Override
|
||||
public ChatClientResponse after(ChatClientResponse chatClientResponse, AdvisorChain advisorChain) {
|
||||
List<Message> assistantMessages = new ArrayList<>();
|
||||
if (chatClientResponse.chatResponse() != null) {
|
||||
// Handle streaming case where we have a single result
|
||||
if (chatClientResponse.chatResponse() != null && chatClientResponse.chatResponse().getResult() != null
|
||||
&& chatClientResponse.chatResponse().getResult().getOutput() != null) {
|
||||
assistantMessages = List.of((Message) chatClientResponse.chatResponse().getResult().getOutput());
|
||||
}
|
||||
else if (chatClientResponse.chatResponse() != null) {
|
||||
assistantMessages = chatClientResponse.chatResponse()
|
||||
.getResults()
|
||||
.stream()
|
||||
.map(g -> (Message) g.getOutput())
|
||||
.toList();
|
||||
}
|
||||
// Handle streaming case where we have a single result
|
||||
else if (chatClientResponse.chatResponse() != null && chatClientResponse.chatResponse().getResult() != null
|
||||
&& chatClientResponse.chatResponse().getResult().getOutput() != null) {
|
||||
assistantMessages = List.of((Message) chatClientResponse.chatResponse().getResult().getOutput());
|
||||
}
|
||||
|
||||
if (!assistantMessages.isEmpty()) {
|
||||
this.chatMemory.add(this.getConversationId(chatClientResponse.context(), this.defaultConversationId),
|
||||
|
||||
Reference in New Issue
Block a user