Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@ public ChatClientRequest before(ChatClientRequest chatClientRequest, AdvisorChai
@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),
Expand Down