Skip to content

Commit e77736c

Browse files
authored
Merge branch 'main' into paradalicea/fix/functions/sample-billing-stop/b-403855924
2 parents a4712e5 + 3cd9396 commit e77736c

106 files changed

Lines changed: 6888 additions & 91 deletions

File tree

Some content is hidden

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

.github/workflows/custard-ci-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Create `bin` directory for cloud-samples-tools binaries
4646
run: mkdir bin
4747
working-directory: cloud-samples-tools
48-
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
48+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
4949
with:
5050
go-version: ${{ env.GO_VERSION }}
5151
- name: Build Custard (from cloud-samples-tools)

.github/workflows/custard-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- name: Create `bin` directory for cloud-samples-tools binaries
5050
run: mkdir bin
5151
working-directory: cloud-samples-tools
52-
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
52+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
5353
with:
5454
go-version: ${{ env.GO_VERSION }}
5555
- name: Build Custard (from cloud-samples-tools)

ai-platform/snippets/predict-image-from-image-and-text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function main(
3030
*/
3131
// const project = 'YOUR_PROJECT_ID';
3232
// const location = 'YOUR_PROJECT_LOCATION';
33-
// const bastImagePath = "YOUR_BASED_IMAGE_PATH"
33+
// const baseImagePath = 'YOUR_BASE_IMAGE_PATH';
3434
// const textPrompt = 'YOUR_TEXT_PROMPT';
3535
const aiplatform = require('@google-cloud/aiplatform');
3636

ai-platform/snippets/predict-text-embeddings.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// [START generativeaionvertexai_sdk_embedding]
2121
async function main(
2222
project,
23-
model = 'text-embedding-005',
23+
model = 'gemini-embedding-001',
2424
texts = 'banana bread?;banana muffins?',
2525
task = 'QUESTION_ANSWERING',
2626
dimensionality = 0,
@@ -37,19 +37,29 @@ async function main(
3737
const instances = texts
3838
.split(';')
3939
.map(e => helpers.toValue({content: e, task_type: task}));
40+
41+
const client = new PredictionServiceClient(clientOptions);
4042
const parameters = helpers.toValue(
4143
dimensionality > 0 ? {outputDimensionality: parseInt(dimensionality)} : {}
4244
);
43-
const request = {endpoint, instances, parameters};
44-
const client = new PredictionServiceClient(clientOptions);
45-
const [response] = await client.predict(request);
46-
const predictions = response.predictions;
47-
const embeddings = predictions.map(p => {
48-
const embeddingsProto = p.structValue.fields.embeddings;
49-
const valuesProto = embeddingsProto.structValue.fields.values;
50-
return valuesProto.listValue.values.map(v => v.numberValue);
51-
});
52-
console.log('Got embeddings: \n' + JSON.stringify(embeddings));
45+
const allEmbeddings = []
46+
// gemini-embedding-001 takes one input at a time.
47+
for (const instance of instances) {
48+
const request = {endpoint, instances: [instance], parameters};
49+
const [response] = await client.predict(request);
50+
const predictions = response.predictions;
51+
52+
const embeddings = predictions.map(p => {
53+
const embeddingsProto = p.structValue.fields.embeddings;
54+
const valuesProto = embeddingsProto.structValue.fields.values;
55+
return valuesProto.listValue.values.map(v => v.numberValue);
56+
});
57+
58+
allEmbeddings.push(embeddings[0])
59+
}
60+
61+
62+
console.log('Got embeddings: \n' + JSON.stringify(allEmbeddings));
5363
}
5464

5565
callPredict();

ai-platform/snippets/test/predict-text-embeddings.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const texts = [
3737
describe('predict text embeddings', () => {
3838
it('should get text embeddings using the latest model', async () => {
3939
const stdout = execSync(
40-
`node ./predict-text-embeddings.js ${project} text-embedding-004 '${texts.join(';')}' QUESTION_ANSWERING ${dimensionality}`,
40+
`node ./predict-text-embeddings.js ${project} gemini-embedding-001 '${texts.join(';')}' QUESTION_ANSWERING ${dimensionality}`,
4141
{cwd}
4242
);
4343
const embeddings = JSON.parse(stdout.trimEnd().split('\n').at(-1));

functions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ There are two versions of Cloud Run functions:
1313

1414
1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
1515

16-
[prereq]: ../README.md#prerequisities
16+
[prereq]: ../README.md#setup
1717
[run]: ../README.md#how-to-run-a-sample
1818

1919
## Samples

functions/env_vars/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ See the [Cloud Functions Using Environment Variables tutorial][tutorial].
1616

1717
## Run the tests
1818

19-
1. Read and follow the [prerequisites](../../#how-to-run-the-tests).
19+
1. Read and follow the [prerequisites](../../#setup).
2020

2121
2. Install dependencies:
2222

functions/helloworld/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ complete list, see the [gcloud reference](https://cloud.google.com/sdk/gcloud/re
2727

2828
## Run the tests
2929

30-
1. Read and follow the [prerequisites](../../../README.md#prerequisites).
30+
1. Read and follow the [prerequisites](../../../README.md#setup).
3131

3232

3333
1. Install dependencies:

functions/helloworld/helloGCS/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ complete list, see the [gcloud reference](https://cloud.google.com/sdk/gcloud/re
2525

2626
## Run the tests
2727

28-
1. Read and follow the [prerequisites](../../../README.md#prerequisites).
28+
1. Read and follow the [prerequisites](../../../README.md#setup).
2929

3030

3131
1. Install dependencies:

functions/helloworld/helloPubSub/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ complete list, see the [gcloud reference](https://cloud.google.com/sdk/gcloud/re
2525

2626
## Run the tests
2727

28-
1. Read and follow the [prerequisites](../../../README.md#prerequisites).
28+
1. Read and follow the [prerequisites](../../../README.md#setup).
2929

3030

3131
1. Install dependencies:

0 commit comments

Comments
 (0)