Skip to content

Commit

Permalink
BREAKING_CHANGE: [vertexai] Change the unmodifiable list to immutable…
Browse files Browse the repository at this point in the history
… list for getHistory. (#10606)

PiperOrigin-RevId: 618183004

Co-authored-by: Zhenyi Qi <zhenyiqi@google.com>
  • Loading branch information
copybara-service[bot] and ZhenyiQ committed Mar 22, 2024
1 parent 1be133f commit 3f68001
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -27,9 +27,9 @@
import com.google.cloud.vertexai.api.GenerationConfig;
import com.google.cloud.vertexai.api.SafetySetting;
import com.google.cloud.vertexai.api.Tool;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -210,9 +210,9 @@ private void checkFinishReasonAndRemoveLastContent(GenerateContentResponse respo
/**
* Returns the history of the conversation.
*
* @return an unmodifiable history of the conversation.
* @return a history of the conversation as an immutable list of {@link Content}.
*/
public List<Content> getHistory() {
public ImmutableList<Content> getHistory() {
try {
checkLastResponseAndEditHistory();
} catch (IllegalStateException e) {
Expand All @@ -225,7 +225,7 @@ public List<Content> getHistory() {
}
throw e;
}
return Collections.unmodifiableList(history);
return ImmutableList.copyOf(history);
}

/**
Expand Down

0 comments on commit 3f68001

Please sign in to comment.