Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No public description #10824

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,16 @@ private ApiFuture<GenerateContentResponse> generateContentAsync(GenerateContentR
return vertexAi.getPredictionServiceClient().generateContentCallable().futureCall(request);
}

/**
* Removes the role in the system instruction content.
*
* @param systemInstruction a {@link com.google.cloud.vertexai.api.Content} instance
* @return a {@link com.google.cloud.vertexai.api.Content} instance with the role removed
*/
private Content removeRoleInSystemInstructionContent(Content systemInstruction) {
return systemInstruction.toBuilder().clearRole().build();
}

/**
* Builds a {@link com.google.cloud.vertexai.api.GenerateContentRequest} based on a list of
* contents and model configurations.
Expand All @@ -519,7 +529,8 @@ private GenerateContentRequest buildGenerateContentRequest(List<Content> content
.addAllTools(tools);

if (systemInstruction.isPresent()) {
requestBuilder.setSystemInstruction(systemInstruction.get());
requestBuilder.setSystemInstruction(
removeRoleInSystemInstructionContent(systemInstruction.get()));
}

return requestBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ public void testGenerateContentwithSystemInstruction() throws Exception {
verify(mockUnaryCallable).call(request.capture());
assertThat(request.getValue().getSystemInstruction().getParts(0).getText())
.isEqualTo(systemInstructionText);
assertThat(request.getValue().getSystemInstruction().getRole()).isEqualTo("");
}

@Test
Expand Down
Loading