-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: [vertexai] adding system instruction support #10775
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Guillaume for implementing this feature and fixing javadoc issues!
@@ -45,6 +45,7 @@ public final class GenerativeModel { | |||
private final GenerationConfig generationConfig; | |||
private final ImmutableList<SafetySetting> safetySettings; | |||
private final ImmutableList<Tool> tools; | |||
private final Content systemInstructions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename to systemInstruction
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
@@ -114,20 +118,22 @@ public static class Builder { | |||
private GenerationConfig generationConfig = GenerationConfig.getDefaultInstance(); | |||
private ImmutableList<SafetySetting> safetySettings = ImmutableList.of(); | |||
private ImmutableList<Tool> tools = ImmutableList.of(); | |||
private Content systemInstructions = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Java readability reviewers, using null
is discouraged. Can we switch to Content.getDefaultInstance()
or Optional
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll go with Optional
as it's clearer when system instructions have been set or not (otherwise I'd have to examine the Content
instance to see if it's a default one or a normal one).
I think it'll be clearer / cleaner that way.
Content systemInstructions = | ||
Content.newBuilder() | ||
.addParts(Part.newBuilder().setText(systemInstructionText).build()) | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use ContentMaker.fromString(systemInstructionText)
here
.thenReturn(mockGenerateContentResponse); | ||
|
||
Content content = | ||
Content.newBuilder().setRole("user").addParts(Part.newBuilder().setText(TEXT)).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
* for the generative model | ||
*/ | ||
private GenerativeModel( | ||
String modelName, | ||
GenerationConfig generationConfig, | ||
ImmutableList<SafetySetting> safetySettings, | ||
ImmutableList<Tool> tools, | ||
Optional<Content> systemInstruction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a setSystemInstruction
in the GenerativeModel.Builder class? Also a getter method in the GenerativeModel
* instructions. | ||
* @return a new {@link GenerativeModel} instance with the specified tools. | ||
*/ | ||
public GenerativeModel withSystemInstructions(Content systemInstructions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we replace all SystemInstructions
with SystemInstruction
?
WIP: system instructions support