java-docs-samples icon indicating copy to clipboard operation
java-docs-samples copied to clipboard

fix: Update GetTokenCount.java

Open davenportjw opened this issue 1 year ago • 1 comments

Description

Fixes #<ISSUE-NUMBER>

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

Checklist

  • [X] 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
  • [X] Please merge this PR for me once it is approved

davenportjw avatar May 16 '24 19:05 davenportjw

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

snippet-bot[bot] avatar May 16 '24 19:05 snippet-bot[bot]

@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.

iennae avatar May 23 '24 04:05 iennae

@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);

minherz avatar May 23 '24 15:05 minherz

@davenportjw @iennae @minherz: GetTokenCount.java has been updated along with other files in another PR (https://github.com/GoogleCloudPlatform/java-docs-samples/pull/9356). We can close this PR. Please let me know if you have any questions.. Thank you!

gericdong avatar Jun 12 '24 13:06 gericdong

No questions

minherz avatar Jun 17 '24 16:06 minherz