Skip to content

Commit cbead5d

Browse files
Merged changes from main
2 parents ea589d0 + f89f6fa commit cbead5d

File tree

73 files changed

+3106
-372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3106
-372
lines changed

aiplatform/src/main/java/aiplatform/EmbeddingBatchSample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static void main(String[] args) throws IOException, InterruptedException
4040
// Could be a BigQuery table or a Google Cloud Storage file.
4141
// E.g. "gs://[BUCKET]/[OUTPUT].jsonl" OR "bq://[PROJECT].[DATASET].[TABLE]"
4242
String outputUri = "gs://YOUR_BUCKET/embedding_batch_output";
43-
String textEmbeddingModel = "textembedding-gecko@003";
43+
String textEmbeddingModel = "text-embedding-005";
4444

4545
embeddingBatchSample(project, location, inputUri, outputUri, textEmbeddingModel);
4646
}

aiplatform/src/main/java/aiplatform/EmbeddingModelTuningSample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static PipelineJob createEmbeddingModelTuningPipelineJob(
8484
Matcher matcher = Pattern.compile("^(?<Location>\\w+-\\w+)").matcher(apiEndpoint);
8585
String location = matcher.matches() ? matcher.group("Location") : "us-central1";
8686
String templateUri =
87-
"https://us-kfp.pkg.dev/ml-pipeline/llm-text-embedding/tune-text-embedding-model/v1.1.3";
87+
"https://us-kfp.pkg.dev/ml-pipeline/llm-text-embedding/tune-text-embedding-model/v1.1.4";
8888
PipelineServiceSettings settings =
8989
PipelineServiceSettings.newBuilder().setEndpoint(apiEndpoint).build();
9090
try (PipelineServiceClient client = PipelineServiceClient.create(settings)) {

aiplatform/src/main/java/aiplatform/PredictTextEmbeddingsSample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static void main(String[] args) throws IOException {
4141
// https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings
4242
String endpoint = "us-central1-aiplatform.googleapis.com:443";
4343
String project = "YOUR_PROJECT_ID";
44-
String model = "text-embedding-004";
44+
String model = "text-embedding-005";
4545
predictTextEmbeddings(
4646
endpoint,
4747
project,

aiplatform/src/main/java/aiplatform/PredictTextEmbeddingsSamplePreview.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static void main(String[] args) throws IOException {
4141
// https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings
4242
String endpoint = "us-central1-aiplatform.googleapis.com";
4343
String project = "YOUR_PROJECT_ID";
44-
String model = "text-embedding-preview-0815";
44+
String model = "text-embedding-005";
4545
// Calculate the embedding for a code retrieval query. Using 'CODE_RETRIEVAL_QUERY' for query.
4646
predictTextEmbeddings(
4747
endpoint,

aiplatform/src/test/java/aiplatform/EmbeddingBatchSampleTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class EmbeddingBatchSampleTest extends TestCase {
4141
"gs://cloud-samples-data/generative-ai/embeddings/embeddings_input.jsonl";
4242
private static final String GCS_OUTPUT_URI =
4343
String.format("gs://%s/embedding_batch_output", BUCKET_NAME);
44-
private static final String MODEL_ID = "textembedding-gecko@003";
44+
private static final String MODEL_ID = "text-embedding-005";
4545
static Storage storage;
4646
static Bucket bucket;
4747

aiplatform/src/test/java/aiplatform/EmbeddingModelTuningSampleTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class EmbeddingModelTuningSampleTest {
5353

5454
private static final String API_ENDPOINT = "us-central1-aiplatform.googleapis.com:443";
5555
private static final String PROJECT = System.getenv("UCAIP_PROJECT_ID");
56-
private static final String BASE_MODEL_VERSION_ID = "text-embedding-004";
56+
private static final String BASE_MODEL_VERSION_ID = "text-embedding-005";
5757
private static final String TASK_TYPE = "DEFAULT";
5858
private static final String JOB_DISPLAY_NAME = "embedding-customization-pipeline-sample";
5959
private static final String CORPUS =

aiplatform/src/test/java/aiplatform/PredictTextEmbeddingsSampleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void testPredictTextEmbeddings() throws IOException {
5252
PredictTextEmbeddingsSample.predictTextEmbeddings(
5353
APIS_ENDPOINT,
5454
PROJECT,
55-
"text-embedding-004",
55+
"text-embedding-005",
5656
texts,
5757
"QUESTION_ANSWERING",
5858
OptionalInt.of(5));
@@ -70,7 +70,7 @@ public void testPredictTextEmbeddingsPreview() throws IOException {
7070
PredictTextEmbeddingsSamplePreview.predictTextEmbeddings(
7171
APIS_ENDPOINT,
7272
PROJECT,
73-
"text-embedding-preview-0815",
73+
"text-embedding-005",
7474
texts,
7575
"CODE_RETRIEVAL_QUERY",
7676
OptionalInt.of(5));

appengine-java11/appengine-simple-jetty-main/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2222
<maven.compiler.source>11</maven.compiler.source>
2323
<maven.compiler.target>11</maven.compiler.target>
24-
<jetty.version>9.4.54.v20240208</jetty.version>
24+
<jetty.version>9.4.56.v20240826</jetty.version>
2525
</properties>
2626

2727
<!-- [START gae_java11_server_dependencies] -->
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
*/
16+
17+
// [START apikeys_undelete_api_key]
18+
import com.google.api.apikeys.v2.ApiKeysClient;
19+
import com.google.api.apikeys.v2.Key;
20+
import com.google.api.apikeys.v2.UndeleteKeyRequest;
21+
import java.io.IOException;
22+
import java.util.concurrent.ExecutionException;
23+
import java.util.concurrent.TimeUnit;
24+
import java.util.concurrent.TimeoutException;
25+
26+
public class UndeleteApiKey {
27+
28+
public static void main(String[] args)
29+
throws IOException, ExecutionException, InterruptedException, TimeoutException {
30+
// TODO(developer): Replace these variables before running the sample.
31+
// Project ID or project number of the Google Cloud project.
32+
String projectId = "YOUR_PROJECT_ID";
33+
// The API key id to undelete.
34+
String keyId = "YOUR_KEY_ID";
35+
36+
undeleteApiKey(projectId, keyId);
37+
}
38+
39+
// Undeletes an API key.
40+
public static void undeleteApiKey(String projectId, String keyId)
41+
throws IOException, ExecutionException, InterruptedException, TimeoutException {
42+
// Initialize client that will be used to send requests. This client only needs to be created
43+
// once, and can be reused for multiple requests.
44+
try (ApiKeysClient apiKeysClient = ApiKeysClient.create()) {
45+
46+
// Initialize the undelete request and set the argument.
47+
UndeleteKeyRequest undeleteKeyRequest = UndeleteKeyRequest.newBuilder()
48+
.setName(String.format("projects/%s/locations/global/keys/%s", projectId, keyId))
49+
.build();
50+
51+
// Make the request and wait for the operation to complete.
52+
Key undeletedKey = apiKeysClient.undeleteKeyAsync(undeleteKeyRequest)
53+
.get(3, TimeUnit.MINUTES);
54+
55+
System.out.printf("Successfully undeleted the API key: %s", undeletedKey.getName());
56+
}
57+
}
58+
}
59+
// [END apikeys_undelete_api_key]

auth/src/test/java/ApiKeySnippetsIT.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
public class ApiKeySnippetsIT {
3737

3838
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
39-
private static final String CREDENTIALS = System.getenv("GOOGLE_APPLICATION_CREDENTIALS");
4039
private static Key API_KEY;
4140
private static String API_KEY_STRING;
4241
private ByteArrayOutputStream stdOut;
@@ -79,8 +78,15 @@ public static void cleanup()
7978

8079
String apiKeyId = getApiKeyId(API_KEY);
8180
DeleteApiKey.deleteApiKey(PROJECT_ID, apiKeyId);
82-
String goal = String.format("Successfully deleted the API key: %s", API_KEY.getName());
83-
assertThat(stdOut.toString()).contains(goal);
81+
82+
UndeleteApiKey.undeleteApiKey(PROJECT_ID, apiKeyId);
83+
String undeletedKey = String.format("Successfully undeleted the API key: %s",
84+
API_KEY.getName());
85+
assertThat(stdOut.toString()).contains(undeletedKey);
86+
87+
DeleteApiKey.deleteApiKey(PROJECT_ID, apiKeyId);
88+
String deletedKey = String.format("Successfully deleted the API key: %s", API_KEY.getName());
89+
assertThat(stdOut.toString()).contains(deletedKey);
8490

8591
stdOut.close();
8692
System.setOut(out);

0 commit comments

Comments
 (0)