Skip to content

Commit 74763b8

Browse files
Merge pull request #1 from GoogleCloudPlatform/main
JDS
2 parents 414e26b + 69cd787 commit 74763b8

Some content is hidden

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

47 files changed

+2759
-292
lines changed

.github/blunderbuss.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
assign_issues:
16-
- GoogleCloudPlatform/java-samples-reviewers
17-
1815
assign_issues_by:
1916
- labels:
2017
- "api: routeoptimization"
@@ -100,9 +97,6 @@ assign_issues_by:
10097
to:
10198
- GoogleCloudPlatform/cloud-modelarmor-team
10299

103-
assign_prs:
104-
- GoogleCloudPlatform/java-samples-reviewers
105-
106100
assign_prs_by:
107101
- labels:
108102
- "api: cloudasset"

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

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ 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-005";
44+
String model = "gemini-embedding-001";
4545
predictTextEmbeddings(
4646
endpoint,
4747
project,
4848
model,
4949
List.of("banana bread?", "banana muffins?"),
5050
"QUESTION_ANSWERING",
51-
OptionalInt.of(256));
51+
OptionalInt.of(3072));
5252
}
5353

5454
// Gets text embeddings from a pretrained, foundational model.
@@ -67,37 +67,40 @@ public static List<List<Float>> predictTextEmbeddings(
6767
EndpointName endpointName =
6868
EndpointName.ofProjectLocationPublisherModelName(project, location, "google", model);
6969

70+
List<List<Float>> floats = new ArrayList<>();
7071
// You can use this prediction service client for multiple requests.
7172
try (PredictionServiceClient client = PredictionServiceClient.create(settings)) {
72-
PredictRequest.Builder request =
73-
PredictRequest.newBuilder().setEndpoint(endpointName.toString());
74-
if (outputDimensionality.isPresent()) {
75-
request.setParameters(
76-
Value.newBuilder()
77-
.setStructValue(
78-
Struct.newBuilder()
79-
.putFields("outputDimensionality", valueOf(outputDimensionality.getAsInt()))
80-
.build()));
81-
}
73+
// gemini-embedding-001 takes one input at a time.
8274
for (int i = 0; i < texts.size(); i++) {
75+
PredictRequest.Builder request =
76+
PredictRequest.newBuilder().setEndpoint(endpointName.toString());
77+
if (outputDimensionality.isPresent()) {
78+
request.setParameters(
79+
Value.newBuilder()
80+
.setStructValue(
81+
Struct.newBuilder()
82+
.putFields(
83+
"outputDimensionality", valueOf(outputDimensionality.getAsInt()))
84+
.build()));
85+
}
8386
request.addInstances(
8487
Value.newBuilder()
8588
.setStructValue(
8689
Struct.newBuilder()
8790
.putFields("content", valueOf(texts.get(i)))
8891
.putFields("task_type", valueOf(task))
8992
.build()));
90-
}
91-
PredictResponse response = client.predict(request.build());
92-
List<List<Float>> floats = new ArrayList<>();
93-
for (Value prediction : response.getPredictionsList()) {
94-
Value embeddings = prediction.getStructValue().getFieldsOrThrow("embeddings");
95-
Value values = embeddings.getStructValue().getFieldsOrThrow("values");
96-
floats.add(
97-
values.getListValue().getValuesList().stream()
98-
.map(Value::getNumberValue)
99-
.map(Double::floatValue)
100-
.collect(toList()));
93+
PredictResponse response = client.predict(request.build());
94+
95+
for (Value prediction : response.getPredictionsList()) {
96+
Value embeddings = prediction.getStructValue().getFieldsOrThrow("embeddings");
97+
Value values = embeddings.getStructValue().getFieldsOrThrow("values");
98+
floats.add(
99+
values.getListValue().getValuesList().stream()
100+
.map(Value::getNumberValue)
101+
.map(Double::floatValue)
102+
.collect(toList()));
103+
}
101104
}
102105
return floats;
103106
}

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

Lines changed: 1 addition & 1 deletion
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-005",
55+
"gemini-embedding-001",
5656
texts,
5757
"QUESTION_ANSWERING",
5858
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.56.v20240826</jetty.version>
24+
<jetty.version>9.4.57.v20241219</jetty.version>
2525
</properties>
2626

2727
<!-- [START gae_java11_server_dependencies] -->

endpoints/multiple-versions/container-engine.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ spec:
3838
app: esp-echo
3939
spec:
4040
containers:
41-
# [START esp]
4241
- name: esp
4342
image: gcr.io/endpoints-release/endpoints-runtime:1
4443
args: [
@@ -47,7 +46,6 @@ spec:
4746
"--service=SERVICE_NAME",
4847
"--version=SERVICE_CONFIG_ID",
4948
]
50-
# [END esp]
5149
ports:
5250
- containerPort: 8081
5351
- name: echo

eventarc/audit-storage/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN mvn package -DskipTests
2828

2929
# Use Eclipse Temurin for base image.
3030
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
31-
FROM eclipse-temurin:17.0.14_7-jre-alpine
31+
FROM eclipse-temurin:17.0.15_6-jre-alpine
3232

3333
# Copy the jar to the production image from the builder stage.
3434
COPY --from=builder /app/target/audit-storage-*.jar /audit-storage.jar

eventarc/pubsub/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RUN mvn package -DskipTests
2626

2727
# Use Eclipse Temurin for base image.
2828
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
29-
FROM eclipse-temurin:17.0.14_7-jre-alpine
29+
FROM eclipse-temurin:17.0.15_6-jre-alpine
3030

3131
# Copy the jar to the production image from the builder stage.
3232
COPY --from=builder /app/target/events-pubsub-*.jar /events-pubsub.jar

flexible/java-11/websocket-jetty/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<maven.compiler.target>11</maven.compiler.target>
3838
<maven.compiler.source>11</maven.compiler.source>
3939
<failOnMissingWebXml>false</failOnMissingWebXml> <!-- REQUIRED -->
40-
<jetty.version>9.4.54.v20240208</jetty.version>
40+
<jetty.version>9.4.57.v20241219</jetty.version>
4141
<spring.boot.version>2.7.18</spring.boot.version>
4242
</properties>
4343

flexible/java-17/websocket-jetty/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<maven.compiler.target>17</maven.compiler.target>
3838
<maven.compiler.source>17</maven.compiler.source>
3939
<failOnMissingWebXml>false</failOnMissingWebXml> <!-- REQUIRED -->
40-
<jetty.version>9.4.54.v20240208</jetty.version>
40+
<jetty.version>9.4.57.v20241219</jetty.version>
4141
<spring.boot.version>2.7.18</spring.boot.version>
4242
</properties>
4343

flexible/repacking-legacy-applications/appengine-simple-jetty-main/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3939
<maven.compiler.source>21</maven.compiler.source>
4040
<maven.compiler.target>21</maven.compiler.target>
41-
<jetty.version>9.4.56.v20240826</jetty.version>
41+
<jetty.version>9.4.57.v20241219</jetty.version>
4242
</properties>
4343
<!-- [END gae_java21_properties] -->
4444

0 commit comments

Comments
 (0)