Skip to content

Commit

Permalink
docs(generativeai): add region tags for code samples (#3756)
Browse files Browse the repository at this point in the history
Adding `generativeaionvertexai_` region tags to replace old `aiplatform_`

In near future GenAI code samples, will only use `generativeaionvertexai_` region tag prefix.
  • Loading branch information
msampathkumar authored Jul 24, 2024
1 parent 997bf90 commit 24829aa
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ai-platform/snippets/embedding-model-tuning.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'use strict';

// [START aiplatform_genai_code_model_tuning]
// [START generativeaionvertexai_genai_code_model_tuning]
async function main(
apiEndpoint,
project,
Expand Down Expand Up @@ -74,6 +75,7 @@ async function main(
await createTuneJob();
}
// [END aiplatform_genai_code_model_tuning]
// [END generativeaionvertexai_genai_code_model_tuning]

process.on('unhandledRejection', err => {
console.error(err.message);
Expand Down
2 changes: 2 additions & 0 deletions ai-platform/snippets/predict-chat-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

async function main(project, location = 'us-central1') {
// [START aiplatform_sdk_chat]
// [START generativeaionvertexai_sdk_chat]
/**
* TODO(developer): Uncomment these variables before running the sample.\
* (Not necessary if passing values as arguments)
Expand Down Expand Up @@ -93,6 +94,7 @@ async function main(project, location = 'us-central1') {

callPredict();
// [END aiplatform_sdk_chat]
// [END generativeaionvertexai_sdk_chat]
}

process.on('unhandledRejection', err => {
Expand Down
2 changes: 2 additions & 0 deletions ai-platform/snippets/predict-code-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

async function main(project, location = 'us-central1') {
// [START aiplatform_sdk_code_chat]
// [START generativeaionvertexai_sdk_code_chat]
/**
* TODO(developer): Uncomment these variables before running the sample.\
* (Not necessary if passing values as arguments)
Expand Down Expand Up @@ -92,6 +93,7 @@ async function main(project, location = 'us-central1') {

callPredict();
// [END aiplatform_sdk_code_chat]
// [END generativeaionvertexai_sdk_code_chat]
}

process.on('unhandledRejection', err => {
Expand Down
2 changes: 2 additions & 0 deletions ai-platform/snippets/predict-code-completion-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

async function main(project, location = 'us-central1') {
// [START aiplatform_sdk_code_completion_comment]
// [START generativeaionvertexai_sdk_code_completion_comment]
/**
* TODO(developer): Uncomment these variables before running the sample.\
* (Not necessary if passing values as arguments)
Expand Down Expand Up @@ -79,6 +80,7 @@ async function main(project, location = 'us-central1') {

callPredict();
// [END aiplatform_sdk_code_completion_comment]
// [END generativeaionvertexai_sdk_code_completion_comment]
}

process.on('unhandledRejection', err => {
Expand Down
2 changes: 2 additions & 0 deletions ai-platform/snippets/predict-code-generation-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

async function main(project, location = 'us-central1') {
// [START aiplatform_sdk_code_generation_function]
// [START generativeaionvertexai_sdk_code_generation_function]
/**
* TODO(developer): Uncomment these variables before running the sample.\
* (Not necessary if passing values as arguments)
Expand Down Expand Up @@ -76,6 +77,7 @@ async function main(project, location = 'us-central1') {

callPredict();
// [END aiplatform_sdk_code_generation_function]
// [END generativeaionvertexai_sdk_code_generation_function]
}

process.on('unhandledRejection', err => {
Expand Down
2 changes: 2 additions & 0 deletions ai-platform/snippets/predict-image-from-image-and-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async function main(
textPrompt
) {
// [START aiplatform_sdk_text_image_embedding]
// [START generativeaionvertexai_sdk_text_image_embedding]
/**
* TODO(developer): Uncomment these variables before running the sample.\
* (Not necessary if passing values as arguments)
Expand Down Expand Up @@ -91,6 +92,7 @@ async function main(

await predictImageFromImageAndText();
// [END aiplatform_sdk_text_image_embedding]
// [END generativeaionvertexai_sdk_text_image_embedding]
}

exports.predictImageFromImageAndText = main;
2 changes: 2 additions & 0 deletions ai-platform/snippets/predict-text-embeddings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'use strict';

// [START aiplatform_sdk_embedding]
// [START generativeaionvertexai_sdk_embedding]
async function main(
project,
model = 'text-embedding-004',
Expand Down Expand Up @@ -54,6 +55,7 @@ async function main(
callPredict();
}
// [END aiplatform_sdk_embedding]
// [END generativeaionvertexai_sdk_embedding]

process.on('unhandledRejection', err => {
console.error(err.message);
Expand Down
2 changes: 2 additions & 0 deletions ai-platform/snippets/predict-text-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

async function main(project, location = 'us-central1') {
// [START aiplatform_sdk_ideation]
// [START generativeaionvertexai_sdk_ideation]
/**
* TODO(developer): Uncomment these variables before running the sample.\
* (Not necessary if passing values as arguments)
Expand Down Expand Up @@ -76,6 +77,7 @@ async function main(project, location = 'us-central1') {

callPredict();
// [END aiplatform_sdk_ideation]
// [END generativeaionvertexai_sdk_ideation]
}

process.on('unhandledRejection', err => {
Expand Down
2 changes: 2 additions & 0 deletions ai-platform/snippets/tuning.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ async function main(
trainSteps = 300
) {
// [START aiplatform_model_tuning]
// [START generativeaionvertexai_model_tuning]
/**
* TODO(developer): Uncomment these variables before running the sample.\
* (Not necessary if passing values as arguments)
Expand Down Expand Up @@ -97,6 +98,7 @@ async function main(

await tuneLLM();
// [END aiplatform_model_tuning]
// [END generativeaionvertexai_model_tuning]
}

exports.tuneModel = main;
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

// [START aiplatform_gemini_function_calling_content]
// [START generativeaionvertexai_gemini_function_calling_content]
const {
VertexAI,
FunctionDeclarationSchemaType,
Expand Down Expand Up @@ -89,6 +90,7 @@ async function functionCallingStreamContent(
}
}
// [END aiplatform_gemini_function_calling_content]
// [END generativeaionvertexai_gemini_function_calling_content]

functionCallingStreamContent(...process.argv.slice(2)).catch(err => {
console.error(err.message);
Expand Down
2 changes: 2 additions & 0 deletions generative-ai/snippets/streamChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// [START generativeaionvertexai_gemini_multiturn_chat_stream]
// [START aiplatform_gemini_multiturn_chat]
// [START generativeaionvertexai_gemini_multiturn_chat]
const {VertexAI} = require('@google-cloud/vertexai');

/**
Expand Down Expand Up @@ -43,6 +44,7 @@ async function createStreamChat(
}
}
// [END aiplatform_gemini_multiturn_chat]
// [END generativeaionvertexai_gemini_multiturn_chat]
// [END generativeaionvertexai_gemini_multiturn_chat_stream]

createStreamChat(...process.argv.slice(2)).catch(err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ describe('Google search grounding', async () => {
const output = execSync(
`node ./grounding/groundingPublicDataBasic.js ${projectId} ${location} ${model}`
);
assert(output.match(/webSearchQueries.*Why is the sky blue?/));
assert(output.match(/GroundingMetadata.*Why is the sky blue?/));
});
});

0 comments on commit 24829aa

Please sign in to comment.