Skip to content

Commit 3f68001

Browse files
copybara-service[bot]Zhenyi Qi
andauthored
BREAKING_CHANGE: [vertexai] Change the unmodifiable list to immutable list for getHistory. (#10606)
PiperOrigin-RevId: 618183004 Co-authored-by: Zhenyi Qi <zhenyiqi@google.com>
1 parent 1be133f commit 3f68001

File tree

1 file changed

+4
-4
lines changed
  • java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai

1 file changed

+4
-4
lines changed

java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/ChatSession.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
import com.google.cloud.vertexai.api.GenerationConfig;
2828
import com.google.cloud.vertexai.api.SafetySetting;
2929
import com.google.cloud.vertexai.api.Tool;
30+
import com.google.common.collect.ImmutableList;
3031
import java.io.IOException;
3132
import java.util.ArrayList;
32-
import java.util.Collections;
3333
import java.util.List;
3434
import java.util.Optional;
3535

@@ -210,9 +210,9 @@ private void checkFinishReasonAndRemoveLastContent(GenerateContentResponse respo
210210
/**
211211
* Returns the history of the conversation.
212212
*
213-
* @return an unmodifiable history of the conversation.
213+
* @return a history of the conversation as an immutable list of {@link Content}.
214214
*/
215-
public List<Content> getHistory() {
215+
public ImmutableList<Content> getHistory() {
216216
try {
217217
checkLastResponseAndEditHistory();
218218
} catch (IllegalStateException e) {
@@ -225,7 +225,7 @@ public List<Content> getHistory() {
225225
}
226226
throw e;
227227
}
228-
return Collections.unmodifiableList(history);
228+
return ImmutableList.copyOf(history);
229229
}
230230

231231
/**

0 commit comments

Comments
 (0)