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): support system instruction #9330

Merged
merged 20 commits into from
May 15, 2024

Conversation

glaforge
Copy link
Contributor

Description

Fixes b/338204721
(internal bug reference)

Add support for system instruction.

@glaforge glaforge requested review from yoshi-approver and a team as code owners May 13, 2024 22:45
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label May 13, 2024
Copy link

snippet-bot bot commented May 13, 2024

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

System.out.println(output);
}

// Ask the model to translate from English to French thanks to a system instruction.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Ask the model to translate from English to French thanks to a system instruction.
// Ask the model to translate from English to French with a system instruction.

Copy link
Contributor

@Sita04 Sita04 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, just one nit in the comment.

@Sita04 Sita04 assigned Sita04 and unassigned minherz May 13, 2024
@glaforge glaforge added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 15, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 15, 2024
@gericdong gericdong merged commit 043d422 into GoogleCloudPlatform:main May 15, 2024
8 checks passed
Comment on lines +28 to +36
public static void main(String[] args) throws Exception {
// TODO(developer): Replace these variables before running the sample.
String projectId = "your-google-cloud-project-id";
String location = "us-central1";
String modelName = "gemini-1.5-pro-preview-0409";

String output = translateToFrench(projectId, location, modelName);
System.out.println(output);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: It is a good practice to exclude the code of main() from the code snippet. To do this you need to place TWO region tag START/END comments around necessary imports and around the code sample method.

Comment on lines +52 to +53
output = ResponseHandler.getText(response);
return output;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think it can be a direct return.

rafaelMurata pushed a commit to rafaelMurata/java-docs-samples that referenced this pull request May 27, 2024
* Remove the preview package
Add a function calling example

* Missing license header

* chore(Checkstyle tweak)

* Add missing region tag
Fix typo in project ID string

* Use the latest libraries-bom that references the 0.4.0 version of the google-cloud-vertexai SDK
Use the same example for the token count as in Python and Golang

* feat(vertexai): Multimodal snippets using Gemini 1.5

* feat(vertexai): Multimodal snippets using Gemini 1.5 (checkstyle and header tweaks)

* feat(vertexai): Multimodal snippets using Gemini 1.5 (incorporating feedback, fixing region tags, and clarifying comments)

* chore(vertexai): Update to the latest version of the libraries-bom

* chore(vertexai): tweak tests

* feat(vertexai): System instruction example

* feat(vertexai): Add region tag for system instruction test

* feat(vertexai): Add region tag for system instruction test (comment nit)

* feat(vertexai): Add region tag for system instruction test (non-predictable output, removing an assert)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants