8000 Upgrade Java snippets to Gemini 2.0 Flash (#10056) · rebeccaellis/java-docs-samples@1256f59 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1256f59

Browse files
authored
Upgrade Java snippets to Gemini 2.0 Flash (GoogleCloudPlatform#10056)
* 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) * feat(vertexai): Use gemini-1.5-flash-001 instead of the preview model * Reset the initial backoff time to its original setting * feat(vertexai): Updated to use Gemini 1.5 Flash and new samples - added some advanced variants of existing snippets - added grounding with private data and with Google Search web results - added new multimodality streaming/non-streaming examples - updated some samples with Gemini 1.5 Flash - updated/added some region tags for integration in the documentation * fix assertion in the grounding with private data test case * - split the token count and grounding samples to have one file per feature - disable a flaky test assertion * - added some extra comments for clarity - updated the region tag locations * - added a couple more comments for clarity and reference * feat(vertexai): Add controlled generation (constrained decoding) * feat(vertexai): Add controlled generation (constrained decoding) (small typo) * feat(vertexai): Upgrade most snippets to use Gemini 2.0 Flash
1 parent 05df080 commit 1256f59

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

vertexai/snippets/src/test/java/vertexai/gemini/SnippetsIT.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public class SnippetsIT {
4747

4848
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
4949
private static final String LOCATION = "us-central1";
50-
private static final String GEMINI_FLASH = "gemini-1.5-flash-001";
51-
private static final String GEMINI_PRO = "gemini-1.5-pro-001";
50+
private static final String GEMINI_FLASH = "gemini-2.0-flash-001";
51+
private static final String GEMINI_FLASH_1_5 = "gemini-1.5-flash-001";
5252
private static final String DATASTORE_ID = "grounding-test-datastore_1716831150046";
5353
private static final int MAX_ATTEMPT_COUNT = 3;
5454
private static final int INITIAL_BACKOFF_MILLIS = 120000;
@@ -183,7 +183,7 @@ public void testSimpleQuestionAnswer() throws Exception {
183183
@Test
184184
public void testQuickstart() throws IOException {
185185
String output = Quickstart.quickstart(PROJECT_ID, LOCATION, GEMINI_FLASH);
186-
assertThat(output).contains("scones");
186+
assertThat(output).contains("cookie");
187187
}
188188

189189
@Test
@@ -229,7 +229,7 @@ public void testTokenCount() throws Exception {
229229
@Test
230230
public void testMediaTokenCount() throws Exception {
231231
int tokenCount = GetMediaTokenCount.getMediaTokenCount(PROJECT_ID, LOCATION, GEMINI_FLASH);
232-
assertThat(tokenCount).isEqualTo(16822);
232+
assertThat(tokenCount).isEqualTo(16252);
233233
}
234234

235235
@Test
@@ -314,7 +314,7 @@ public void testSystemInstruction() throws Exception {
314314
@Test
315315
public void testGroundingWithPublicData() throws Exception {
316316
String output =
317-
GroundingWithPublicData.groundWithPublicData(PROJECT_ID, LOCATION, GEMINI_FLASH);
317+
GroundingWithPublicData.groundWithPublicData(PROJECT_ID, LOCATION, GEMINI_FLASH_1_5);
318318

319319
assertThat(output).ignoringCase().contains("Rayleigh");
320320
}
@@ -364,7 +364,7 @@ public void testControlledGenerationWithMimeType() throws Exception {
364364
@Test
365365
public void testControlledGenerationWithJsonSchema() throws Exception {
366366
String output = ControlledGenerationSchema
367-
.controlGenerationWithJsonSchema(PROJECT_ID, LOCATION, GEMINI_PRO);
367+
.controlGenerationWithJsonSchema(PROJECT_ID, LOCATION, GEMINI_FLASH);
368368
Recipe[] recipes = new Gson().fromJson(output, Recipe[].class);
369369

370370
assertThat(recipes).isNotEmpty();
@@ -379,7 +379,7 @@ private class Review {
379379
@Test
380380
public void testControlledGenerationWithJsonSchema2() throws Exception {
381381
String output = ControlledGenerationSchema2
382-
.controlGenerationWithJsonSchema2(PROJECT_ID, LOCATION, GEMINI_PRO);
382+
.controlGenerationWithJsonSchema2(PROJECT_ID, LOCATION, GEMINI_FLASH);
383383
Review[] recipes = new Gson().fromJson(output, Review[].class);
384384

385385
assertThat(recipes).hasLength(2);
@@ -409,7 +409,7 @@ private class DayForecast {
409409
@Test
410410
public void testControlledGenerationWithJsonSchema3() throws Exception {
411411
String output = ControlledGenerationSchema3
412-
.controlGenerationWithJsonSchema3(PROJECT_ID, LOCATION, GEMINI_PRO);
412+
.controlGenerationWithJsonSchema3(PROJECT_ID, LOCATION, GEMINI_FLASH);
413413
WeatherForecast weatherForecast = new Gson().fromJson(output, WeatherForecast.class);
414414

415415
assertThat(weatherForecast.forecast).hasLength(7);
@@ -473,7 +473,7 @@ private class Item {
473473
@Test
474474
public void testControlledGenerationWithJsonSchema4() throws Exception {
475475
String output = ControlledGenerationSchema4
476-
.controlGenerationWithJsonSchema4(PROJECT_ID, LOCATION, GEMINI_PRO);
476+
.controlGenerationWithJsonSchema4(PROJECT_ID, LOCATION, GEMINI_FLASH);
477477
Item[] items = new Gson().fromJson(output, Item[].class);
478478

479479
assertThat(items).isNotEmpty();
@@ -486,7 +486,7 @@ private class Obj {
486486
@Test
487487
public void testControlledGenerationWithJsonSchema6() throws Exception {
488488
String output = ControlledGenerationSchema6
489-
.controlGenerationWithJsonSchema6(PROJECT_ID, LOCATION, GEMINI_PRO);
489+
.controlGenerationWithJsonSchema6(PROJECT_ID, LOCATION, GEMINI_FLASH);
490490

491491
Obj[] objects = new Gson().fromJson(output, Obj[].class);
492492
String recognizedObjects = Arrays.stream(objects)
@@ -503,7 +503,7 @@ public void testControlledGenerationWithJsonSchema6() throws Exception {
503503
@Test
504504
public void testGeminiTranslate() throws Exception {
505505
String output = GeminiTranslate.geminiTranslate(
506-
PROJECT_ID, LOCATION, GEMINI_PRO, TEXT_TO_TRANSLATE, TARGET_LANGUAGE_CODE);
506+
PROJECT_ID, LOCATION, GEMINI_FLASH, TEXT_TO_TRANSLATE, TARGET_LANGUAGE_CODE);
507507

508508
assertThat(output).ignoringCase().contains("Bonjour");
509509
assertThat(output).ignoringCase().contains("aujourd'hui");

0 commit comments

Comments
 (0)
0