Skip to content

Commit dd25bf0

Browse files
committed
fix: clear unsed samples
1 parent b9ce5e6 commit dd25bf0

File tree

3 files changed

+146
-146
lines changed

3 files changed

+146
-146
lines changed
Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
1-
/*
2-
* Copyright 2024 Google LLC
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
1+
// /*
2+
// * Copyright 2024 Google LLC
3+
// *
4+
// * Licensed under the Apache License, Version 2.0 (the "License");
5+
// * you may not use this file except in compliance with the License.
6+
// * You may obtain a copy of the License at
7+
// *
8+
// * http://www.apache.org/licenses/LICENSE-2.0
9+
// *
10+
// * Unless required by applicable law or agreed to in writing, software
11+
// * distributed under the License is distributed on an "AS IS" BASIS,
12+
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// * See the License for the specific language governing permissions and
14+
// * limitations under the License.
15+
// */
1616

17-
package vertexai.gemini;
17+
// package vertexai.gemini;
1818

19-
// [START generativeaionvertexai_grounding_private_data_basic]
20-
import com.google.cloud.vertexai.VertexAI;
21-
import com.google.cloud.vertexai.api.GenerateContentResponse;
22-
import com.google.cloud.vertexai.api.GroundingMetadata;
23-
import com.google.cloud.vertexai.api.Retrieval;
24-
import com.google.cloud.vertexai.api.Tool;
25-
import com.google.cloud.vertexai.api.VertexAISearch;
26-
import com.google.cloud.vertexai.generativeai.GenerativeModel;
27-
import com.google.cloud.vertexai.generativeai.ResponseHandler;
28-
import java.io.IOException;
29-
import java.util.Collections;
19+
// // [START generativeaionvertexai_grounding_private_data_basic]
20+
// import com.google.cloud.vertexai.VertexAI;
21+
// import com.google.cloud.vertexai.api.GenerateContentResponse;
22+
// import com.google.cloud.vertexai.api.GroundingMetadata;
23+
// import com.google.cloud.vertexai.api.Retrieval;
24+
// import com.google.cloud.vertexai.api.Tool;
25+
// import com.google.cloud.vertexai.api.VertexAISearch;
26+
// import com.google.cloud.vertexai.generativeai.GenerativeModel;
27+
// import com.google.cloud.vertexai.generativeai.ResponseHandler;
28+
// import java.io.IOException;
29+
// import java.util.Collections;
3030

31-
public class GroundingWithPrivateData {
32-
public static void main(String[] args) throws IOException {
33-
// TODO(developer): Replace these variables before running the sample.
34-
String projectId = "your-google-cloud-project-id";
35-
String location = "us-central1";
36-
String modelName = "gemini-2.0-flash-001";
37-
String datastore = String.format(
38-
"projects/%s/locations/global/collections/default_collection/dataStores/%s",
39-
projectId, "datastore_id");
31+
// public class GroundingWithPrivateData {
32+
// public static void main(String[] args) throws IOException {
33+
// // TODO(developer): Replace these variables before running the sample.
34+
// String projectId = "your-google-cloud-project-id";
35+
// String location = "us-central1";
36+
// String modelName = "gemini-2.0-flash-001";
37+
// String datastore = String.format(
38+
// "projects/%s/locations/global/collections/default_collection/dataStores/%s",
39+
// projectId, "datastore_id");
4040

41-
groundWithPrivateData(projectId, location, modelName, datastore);
42-
}
41+
// groundWithPrivateData(projectId, location, modelName, datastore);
42+
// }
4343

44-
// A request whose response will be "grounded"
45-
// with information found in Vertex AI Search datastores.
46-
public static String groundWithPrivateData(String projectId, String location, String modelName,
47-
String datastoreId)
48-
throws IOException {
49-
// Initialize client that will be used to send requests.
50-
// This client only needs to be created once, and can be reused for multiple requests.
51-
try (VertexAI vertexAI = new VertexAI(projectId, location)) {
52-
Tool datastoreTool = Tool.newBuilder()
53-
.setRetrieval(
54-
Retrieval.newBuilder()
55-
.setVertexAiSearch(VertexAISearch.newBuilder().setDatastore(datastoreId))
56-
.setDisableAttribution(false))
57-
.build();
44+
// // A request whose response will be "grounded"
45+
// // with information found in Vertex AI Search datastores.
46+
// public static String groundWithPrivateData(String projectId, String location, String modelName,
47+
// String datastoreId)
48+
// throws IOException {
49+
// // Initialize client that will be used to send requests.
50+
// // This client only needs to be created once, and can be reused for multiple requests.
51+
// try (VertexAI vertexAI = new VertexAI(projectId, location)) {
52+
// Tool datastoreTool = Tool.newBuilder()
53+
// .setRetrieval(
54+
// Retrieval.newBuilder()
55+
// .setVertexAiSearch(VertexAISearch.newBuilder().setDatastore(datastoreId))
56+
// .setDisableAttribution(false))
57+
// .build();
5858

59-
GenerativeModel model = new GenerativeModel(modelName, vertexAI).withTools(
60-
Collections.singletonList(datastoreTool)
61-
);
59+
// GenerativeModel model = new GenerativeModel(modelName, vertexAI).withTools(
60+
// Collections.singletonList(datastoreTool)
61+
// );
6262

63-
GenerateContentResponse response = model.generateContent(
64-
"How do I make an appointment to renew my driver's license?");
63+
// GenerateContentResponse response = model.generateContent(
64+
// "How do I make an appointment to renew my driver's license?");
6565

66-
GroundingMetadata groundingMetadata = response.getCandidates(0).getGroundingMetadata();
67-
String answer = ResponseHandler.getText(response);
66+
// GroundingMetadata groundingMetadata = response.getCandidates(0).getGroundingMetadata();
67+
// String answer = ResponseHandler.getText(response);
6868

69-
System.out.println("Answer: " + answer);
70-
System.out.println("Grounding metadata: " + groundingMetadata);
69+
// System.out.println("Answer: " + answer);
70+
// System.out.println("Grounding metadata: " + groundingMetadata);
7171

72-
return answer;
73-
}
74-
}
75-
}
76-
// [END generativeaionvertexai_grounding_private_data_basic]
72+
// return answer;
73+
// }
74+
// }
75+
// }
76+
// // [END generativeaionvertexai_grounding_private_data_basic]
Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
1-
/*
2-
* Copyright 2024 Google LLC
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
1+
// /*
2+
// * Copyright 2024 Google LLC
3+
// *
4+
// * Licensed under the Apache License, Version 2.0 (the "License");
5+
// * you may not use this file except in compliance with the License.
6+
// * You may obtain a copy of the License at
7+
// *
8+
// * http://www.apache.org/licenses/LICENSE-2.0
9+
// *
10+
// * Unless required by applicable law or agreed to in writing, software
11+
// * distributed under the License is distributed on an "AS IS" BASIS,
12+
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// * See the License for the specific language governing permissions and
14+
// * limitations under the License.
15+
// */
1616

17-
package vertexai.gemini;
17+
// package vertexai.gemini;
1818

19-
// [START generativeaionvertexai_grounding_public_data_basic]
20-
import com.google.cloud.vertexai.VertexAI;
21-
import com.google.cloud.vertexai.api.GenerateContentResponse;
22-
import com.google.cloud.vertexai.api.GoogleSearchRetrieval;
23-
import com.google.cloud.vertexai.api.GroundingMetadata;
24-
import com.google.cloud.vertexai.api.Tool;
25-
import com.google.cloud.vertexai.generativeai.GenerativeModel;
26-
import com.google.cloud.vertexai.generativeai.ResponseHandler;
27-
import java.io.IOException;
28-
import java.util.Collections;
19+
// // [START generativeaionvertexai_grounding_public_data_basic]
20+
// import com.google.cloud.vertexai.VertexAI;
21+
// import com.google.cloud.vertexai.api.GenerateContentResponse;
22+
// import com.google.cloud.vertexai.api.GoogleSearchRetrieval;
23+
// import com.google.cloud.vertexai.api.GroundingMetadata;
24+
// import com.google.cloud.vertexai.api.Tool;
25+
// import com.google.cloud.vertexai.generativeai.GenerativeModel;
26+
// import com.google.cloud.vertexai.generativeai.ResponseHandler;
27+
// import java.io.IOException;
28+
// import java.util.Collections;
2929

30-
public class GroundingWithPublicData {
31-
public static void main(String[] args) throws IOException {
32-
// TODO(developer): Replace these variables before running the sample.
33-
String projectId = "your-google-cloud-project-id";
34-
String location = "us-central1";
35-
String modelName = "gemini-2.0-flash-001";
30+
// public class GroundingWithPublicData {
31+
// public static void main(String[] args) throws IOException {
32+
// // TODO(developer): Replace these variables before running the sample.
33+
// String projectId = "your-google-cloud-project-id";
34+
// String location = "us-central1";
35+
// String modelName = "gemini-2.0-flash-001";
3636

37-
groundWithPublicData(projectId, location, modelName);
38-
}
37+
// groundWithPublicData(projectId, location, modelName);
38+
// }
3939

40-
// A request whose response will be "grounded" with information found in Google Search.
41-
public static String groundWithPublicData(String projectId, String location, String modelName)
42-
throws IOException {
43-
// Initialize client that will be used to send requests.
44-
// This client only needs to be created once, and can be reused for multiple requests.
45-
try (VertexAI vertexAI = new VertexAI(projectId, location)) {
46-
Tool googleSearchTool =
47-
Tool.newBuilder()
48-
.setGoogleSearchRetrieval(
49-
// Enable using the result from this tool in detecting grounding
50-
GoogleSearchRetrieval.newBuilder())
51-
.build();
40+
// // A request whose response will be "grounded" with information found in Google Search.
41+
// public static String groundWithPublicData(String projectId, String location, String modelName)
42+
// throws IOException {
43+
// // Initialize client that will be used to send requests.
44+
// // This client only needs to be created once, and can be reused for multiple requests.
45+
// try (VertexAI vertexAI = new VertexAI(projectId, location)) {
46+
// Tool googleSearchTool =
47+
// Tool.newBuilder()
48+
// .setGoogleSearchRetrieval(
49+
// // Enable using the result from this tool in detecting grounding
50+
// GoogleSearchRetrieval.newBuilder())
51+
// .build();
5252

53-
GenerativeModel model =
54-
new GenerativeModel(modelName, vertexAI)
55-
.withTools(Collections.singletonList(googleSearchTool));
53+
// GenerativeModel model =
54+
// new GenerativeModel(modelName, vertexAI)
55+
// .withTools(Collections.singletonList(googleSearchTool));
5656

57-
GenerateContentResponse response = model.generateContent("Why is the sky blue?");
57+
// GenerateContentResponse response = model.generateContent("Why is the sky blue?");
5858

59-
GroundingMetadata groundingMetadata = response.getCandidates(0).getGroundingMetadata();
60-
String answer = ResponseHandler.getText(response);
59+
// GroundingMetadata groundingMetadata = response.getCandidates(0).getGroundingMetadata();
60+
// String answer = ResponseHandler.getText(response);
6161

62-
System.out.println("Answer: " + answer);
63-
System.out.println("Grounding metadata: " + groundingMetadata);
62+
// System.out.println("Answer: " + answer);
63+
// System.out.println("Grounding metadata: " + groundingMetadata);
6464

65-
return answer;
66-
}
67-
}
68-
}
69-
// [END generativeaionvertexai_grounding_public_data_basic]
65+
// return answer;
66+
// }
67+
// }
68+
// }
69+
// // [END generativeaionvertexai_grounding_public_data_basic]

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -197,27 +197,27 @@ public void testVideoAudioInput() throws IOException {
197197
assertThat(output).ignoringCase().contains("Tokyo");
198198
}
199199

200-
@Test
201-
public void testGroundingWithPublicData() throws Exception {
202-
String output =
203-
GroundingWithPublicData.groundWithPublicData(PROJECT_ID, LOCATION, GEMINI_FLASH_1_5);
204-
205-
assertThat(output).ignoringCase().contains("Rayleigh");
206-
}
207-
208-
@Test
209-
public void testGroundingWithPrivateData() throws Exception {
210-
String output =
211-
GroundingWithPrivateData.groundWithPrivateData(
212-
PROJECT_ID,
213-
LOCATION,
214-
GEMINI_FLASH,
215-
String.format(
216-
"projects/%s/locations/global/collections/default_collection/dataStores/%s",
217-
PROJECT_ID, DATASTORE_ID));
218-
219-
assertThat(output).ignoringCase().contains("DMV");
220-
}
200+
// @Test
201+
// public void testGroundingWithPublicData() throws Exception {
202+
// String output =
203+
// GroundingWithPublicData.groundWithPublicData(PROJECT_ID, LOCATION, GEMINI_FLASH_1_5);
204+
205+
// assertThat(output).ignoringCase().contains("Rayleigh");
206+
// }
207+
208+
// @Test
209+
// public void testGroundingWithPrivateData() throws Exception {
210+
// String output =
211+
// GroundingWithPrivateData.groundWithPrivateData(
212+
// PROJECT_ID,
213+
// LOCATION,
214+
// GEMINI_FLASH,
215+
// String.format(
216+
// "projects/%s/locations/global/collections/default_collection/dataStores/%s",
217+
// PROJECT_ID, DATASTORE_ID));
218+
219+
// assertThat(output).ignoringCase().contains("DMV");
220+
// }
221221

222222
@Test
223223
public void testMultimodalStreaming() throws Exception {

0 commit comments

Comments
 (0)