[go: up one dir, main page]

Skip to content

Commit

Permalink
fix: [vertexai] make a copy of the list in ChatSession.setHistory() (
Browse files Browse the repository at this point in the history
…#10608)

PiperOrigin-RevId: 618209294

Co-authored-by: Jaycee Li <jayceeli@google.com>
  • Loading branch information
copybara-service[bot] and jaycee-li committed Mar 22, 2024
1 parent 3f68001 commit 3e3e35a
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -92,7 +92,7 @@ public ChatSession withSafetySettings(List<SafetySetting> safetySettings) {
ChatSession rootChat = rootChatSession.orElse(this);
ChatSession newChatSession =
new ChatSession(model.withSafetySettings(safetySettings), Optional.of(rootChat));
newChatSession.setHistory(history);
newChatSession.history = history;
return newChatSession;
}

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

Expand Down Expand Up @@ -253,7 +253,7 @@ private Optional<ResponseStream<GenerateContentResponse>> getCurrentResponseStre

/** Set the history to a list of Content */
public void setHistory(List<Content> history) {
this.history = history;
this.history = new ArrayList<>(history);
}

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

0 comments on commit 3e3e35a

Please sign in to comment.