Content-Length: 290833 | pFad | https://github.com/googleapis/google-cloud-java/commit/3e3e35a5c1184a486f904858f3647c9313bd5b23

FE fix: [vertexai] make a copy of the list in `ChatSession.setHistory()`… · googleapis/google-cloud-java@3e3e35a · GitHub
Skip to content

Commit 3e3e35a

Browse files
fix: [vertexai] make a copy of the list in ChatSession.setHistory() (#10608)
PiperOrigin-RevId: 618209294 Co-authored-by: Jaycee Li <jayceeli@google.com>
1 parent 3f68001 commit 3e3e35a

File tree

1 file changed

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

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public ChatSession withSafetySettings(List<SafetySetting> safetySettings) {
9292
ChatSession rootChat = rootChatSession.orElse(this);
9393
ChatSession newChatSession =
9494
new ChatSession(model.withSafetySettings(safetySettings), Optional.of(rootChat));
95-
newChatSession.setHistory(history);
95+
newChatSession.history = history;
9696
return newChatSession;
9797
}
9898

@@ -106,7 +106,7 @@ public ChatSession withSafetySettings(List<SafetySetting> safetySettings) {
106106
public ChatSession withTools(List<Tool> tools) {
107107
ChatSession rootChat = rootChatSession.orElse(this);
108108
ChatSession newChatSession = new ChatSession(model.withTools(tools), Optional.of(rootChat));
109-
newChatSession.setHistory(history);
109+
newChatSession.history = history;
110110
return newChatSession;
111111
}
112112

@@ -253,7 +253,7 @@ private Optional<ResponseStream<GenerateContentResponse>> getCurrentResponseStre
253253

254254
/** Set the history to a list of Content */
255255
public void setHistory(List<Content> history) {
256-
this.history = history;
256+
this.history = new ArrayList<>(history);
257257
}
258258

259259
/** Sets the current response of the root chat session (if exists) or the current chat session. */

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/googleapis/google-cloud-java/commit/3e3e35a5c1184a486f904858f3647c9313bd5b23

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy