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

feat: [vertexai] adding system instruction support #10775

Merged
merged 5 commits into from May 6, 2024

Conversation

glaforge
Copy link
Contributor

@glaforge glaforge commented May 2, 2024

WIP: system instructions support

@glaforge glaforge requested review from a team as code owners May 2, 2024 17:02
Copy link
Contributor

@jaycee-li jaycee-li left a 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;
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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();
Copy link
Contributor

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@glaforge glaforge requested a review from jaycee-li May 2, 2024 19:02
* for the generative model
*/
private GenerativeModel(
String modelName,
GenerationConfig generationConfig,
ImmutableList<SafetySetting> safetySettings,
ImmutableList<Tool> tools,
Optional<Content> systemInstruction,
Copy link
Contributor

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) {
Copy link
Contributor

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?

@glaforge glaforge requested a review from jaycee-li May 3, 2024 06:35
@jaycee-li jaycee-li changed the title feat(systeminstructions): adding system instructions support feat: [vertexai] adding system instructions support May 6, 2024
@jaycee-li jaycee-li changed the title feat: [vertexai] adding system instructions support feat: [vertexai] adding system instruction support May 6, 2024
@jaycee-li jaycee-li merged commit b90c291 into googleapis:main May 6, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants