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

fix: Update GetTokenCount.java #9334

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

davenportjw
Copy link

Description

Fixes #

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed Sample Format Guide
  • pom.xml parent set to latest shared-configuration
  • Appropriate changes to README are included in PR
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • Tests pass: mvn clean verify required
  • Lint passes: mvn -P lint checkstyle:check required
  • Static Analysis: mvn -P lint clean compile pmd:cpd-check spotbugs:check advisory only
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

@davenportjw davenportjw requested review from yoshi-approver and a team as code owners May 16, 2024 19:35
Copy link

snippet-bot bot commented May 16, 2024

Here is the summary of changes.

You are about to add 2 region tags.

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

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label May 16, 2024
Copy link
Contributor

@minherz minherz left a comment

Choose a reason for hiding this comment

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

please, ensure that PR pass all checks

@@ -17,24 +17,27 @@
package vertexai.gemini;

// [START aiplatform_gemini_token_count]
// [START generativeaionvertexai_gemini_token_count]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is there a reason to duplicate region tags?

Copy link
Contributor

Choose a reason for hiding this comment

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

@minherz the wrong region tag was used; correct region tag is the generativeai one. Once the region tag has been updated, doc CL would be issued and then the original region tag can be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

In my experience this approach results in redundant and incorrect region tags in the code samples. It is because there is no good way to track documentation CL and following changes.. 🙁
If this code sample should not be used for aiplatform why not to remove the region tag now?
Alternatively why not to batch replacing the region tags to the doc CL?

Copy link
Author

Choose a reason for hiding this comment

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

i dont understand the 'no good way to track comment'. can you please elaborate?

@iennae
Copy link
Contributor

iennae commented May 23, 2024

@davenportjw any idea why change in model name might cause the error

tmpfs/docker/overlay2/85ba26e363cfea28217e7dc8e3c0363a0d8f95a8c884410d2f380c5b415db5f2/merged/sys/fs/cgroup/cpuset.
[ERROR] Tests run: 21, Failures: 0, Errors: 3, Skipped: 1, Time elapsed: 1,210.961 s <<< FAILURE! - in vertexai.gemini.SnippetsIT
[ERROR] vertexai.gemini.SnippetsIT.testMultimodalQuery Time elapsed: 591.885 s <<< ERROR!
java.lang.IllegalArgumentException: The response is blocked due to unauthorized citations.

@minherz
Copy link
Contributor

minherz commented May 23, 2024

@davenportjw any idea why change in model name might cause the error

It looks like you need to revise the input or to adjust the safety settings by updating the model with:

  SafetySetting safetySettings = SafetySetting.newBuilder()
         .setThreshold(SafetySetting.HarmBlockThreshold.BLOCK_NONE)
         .build();
  GenerativeModel model = new GenerativeModel(modelName, vertexAI)
         .withSafetySettings(safetySettings);

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

3 participants