Skip to content

Commit

Permalink
Address review comments and suggestions.
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Lee <[email protected]>
  • Loading branch information
austintlee committed Sep 5, 2023
1 parent a1df6a1 commit e076c92
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.client.Client;
import org.opensearch.core.common.util.CollectionUtils;
import org.opensearch.ml.common.conversation.Interaction;
import org.opensearch.ml.memory.action.conversation.CreateConversationAction;
import org.opensearch.ml.memory.action.conversation.CreateConversationRequest;
Expand Down Expand Up @@ -51,7 +52,7 @@ public class ConversationalMemoryClient {
public String createConversation(String name) {

CreateConversationResponse response = client.execute(CreateConversationAction.INSTANCE, new CreateConversationRequest(name)).actionGet();

log.info("createConversation: id: {}", response.getId());
return response.getId();
}

Expand All @@ -67,6 +68,8 @@ public String createInteraction(String conversationId, String input, String prom

public List<Interaction> getInteractions(String conversationId, int lastN) {

Preconditions.checkArgument(lastN > 0, "lastN must be at least 1.");

log.info("In getInteractions, conversationId {}, lastN {}", conversationId, lastN);

List<Interaction> interactions = new ArrayList<>();
Expand All @@ -77,7 +80,7 @@ public List<Interaction> getInteractions(String conversationId, int lastN) {
GetInteractionsResponse response =
client.execute(GetInteractionsAction.INSTANCE, new GetInteractionsRequest(conversationId, maxResults, from)).actionGet();
List<Interaction> list = response.getInteractions();
if (list != null && !list.isEmpty()) {
if (list != null && !CollectionUtils.isEmpty(list)) {
interactions.addAll(list);
from += list.size();
maxResults -= list.size();
Expand Down

0 comments on commit e076c92

Please sign in to comment.