From 4ad3c4a8230e56edf77bc43b5852b189c52021b8 Mon Sep 17 00:00:00 2001 From: Zhenyi Qi Date: Fri, 22 Mar 2024 08:16:22 -0700 Subject: [PATCH] BREAKING_CHANGE: [vertexai] Change the unmodifiable list to immutable list for getHistory. PiperOrigin-RevId: 618183004 --- .../google/cloud/vertexai/generativeai/ChatSession.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/ChatSession.java b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/ChatSession.java index ef49d12f93fe..41df20360c2b 100644 --- a/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/ChatSession.java +++ b/java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/ChatSession.java @@ -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; @@ -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 getHistory() { + public ImmutableList getHistory() { try { checkLastResponseAndEditHistory(); } catch (IllegalStateException e) { @@ -225,7 +225,7 @@ public List getHistory() { } throw e; } - return Collections.unmodifiableList(history); + return ImmutableList.copyOf(history); } /**