java-docs-samples
java-docs-samples copied to clipboard
fix: Update GetTokenCount.java
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.xmlparent set to latestshared-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 verifyrequired - [ ] Lint passes:
mvn -P lint checkstyle:checkrequired - [ ] Static Analysis:
mvn -P lint clean compile pmd:cpd-check spotbugs:checkadvisory 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
Here is the summary of changes.
You are about to add 2 region tags.
- vertexai/snippets/src/main/java/vertexai/gemini/GetTokenCount.java:20, tag
generativeaionvertexai_gemini_token_count - vertexai/snippets/src/main/java/vertexai/gemini/GetTokenCount.java:40, tag
generativeaionvertexai_gemini_token_count
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
@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.
@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);
@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!
No questions