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); } /**