Skip to content

Commit 0414996

Browse files
committed
Restore generative-ai sample code
1 parent 3bb2fcd commit 0414996

51 files changed

Lines changed: 42 additions & 1829 deletions

Some content is hidden

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

genai/count-tokens/counttoken-resp-with-txt.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
'use strict';
16-
16+
// [START generativeaionvertexai_gemini_token_count]
1717
// [START googlegenaisdk_counttoken_resp_with_txt]
1818
const {GoogleGenAI} = require('@google/genai');
1919

@@ -41,6 +41,7 @@ async function countTokens(
4141
return response.usageMetadata;
4242
}
4343
// [END googlegenaisdk_counttoken_resp_with_txt]
44+
// [END generativeaionvertexai_gemini_token_count]
4445

4546
module.exports = {
4647
countTokens,

genai/count-tokens/counttoken-with-txt-vid.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
'use strict';
1616

17+
// [START generativeaionvertexai_gemini_token_count_advanced]
1718
// [START googlegenaisdk_counttoken_with_txt_vid]
1819
const {GoogleGenAI} = require('@google/genai');
1920

@@ -47,6 +48,7 @@ async function countTokens(
4748
return response.totalTokens;
4849
}
4950
// [END googlegenaisdk_counttoken_with_txt_vid]
51+
// [END generativeaionvertexai_gemini_token_count_advanced]
5052

5153
module.exports = {
5254
countTokens,

genai/safety/safety-with-txt.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
'use strict';
1616

17+
// [START generativeaionvertexai_gemini_safety_settings]
1718
// [START googlegenaisdk_safety_with_txt]
1819
const {GoogleGenAI} = require('@google/genai');
1920

@@ -109,6 +110,7 @@ async function generateWithSafetySettings(
109110
}
110111

111112
// [END googlegenaisdk_safety_with_txt]
113+
// [END generativeaionvertexai_gemini_safety_settings]
112114

113115
module.exports = {
114116
generateWithSafetySettings,

genai/text-generation/textgen-chat-stream-with-txt.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
'use strict';
1616

17+
// [START generativeaionvertexai_gemini_multiturn_chat_stream]
1718
// [START googlegenaisdk_textgen_chat_stream_with_txt]
1819
const {GoogleGenAI} = require('@google/genai');
1920

@@ -48,6 +49,7 @@ async function generateText(
4849
}
4950

5051
// [END googlegenaisdk_textgen_chat_stream_with_txt]
52+
// [END generativeaionvertexai_gemini_multiturn_chat_stream]
5153

5254
module.exports = {
5355
generateText,

genai/text-generation/textgen-chat-with-txt.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
'use strict';
1616

17+
// [START generativeaionvertexai_gemini_multiturn_chat_nonstreaming]
18+
// [START aiplatform_gemini_multiturn_chat_nonstreaming]
1719
// [START googlegenaisdk_textgen_chat_with_txt]
1820
const {GoogleGenAI} = require('@google/genai');
1921

@@ -55,7 +57,8 @@ async function generateText(
5557
}
5658

5759
// [END googlegenaisdk_textgen_chat_with_txt]
58-
60+
// [END aiplatform_gemini_multiturn_chat_nonstreaming]
61+
// [END generativeaionvertexai_gemini_multiturn_chat_nonstreaming]
5962
module.exports = {
6063
generateText,
6164
};

genai/text-generation/textgen-sys-instr-with-txt.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
'use strict';
1616

17+
// [START generativeaionvertexai_gemini_translate]
18+
// [START generativeaionvertexai_gemini_system_instruction]
1719
// [START googlegenaisdk_textgen_sys_instr_with_txt]
1820
const {GoogleGenAI} = require('@google/genai');
1921

@@ -51,6 +53,8 @@ async function generateContent(
5153
return response.text;
5254
}
5355
// [END googlegenaisdk_textgen_sys_instr_with_txt]
56+
// [END generativeaionvertexai_gemini_system_instruction]
57+
// [END generativeaionvertexai_gemini_translate]
5458

5559
module.exports = {
5660
generateContent,

genai/text-generation/textgen-transcript-with-gcs-audio.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
'use strict';
16-
16+
// [START generativeaionvertexai_gemini_audio_transcription]
1717
// [START googlegenaisdk_textgen_transcript_with_gcs_audio]
1818
const {GoogleGenAI} = require('@google/genai');
1919

@@ -63,6 +63,7 @@ async function generateText(
6363
}
6464

6565
// [END googlegenaisdk_textgen_transcript_with_gcs_audio]
66+
// [END generativeaionvertexai_gemini_audio_transcription]
6667

6768
module.exports = {
6869
generateText,

genai/text-generation/textgen-with-gcs-audio.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
'use strict';
16-
16+
// [START generativeaionvertexai_gemini_audio_summarization]
1717
// [START googlegenaisdk_textgen_with_gcs_audio]
1818
const {GoogleGenAI} = require('@google/genai');
1919

@@ -55,6 +55,7 @@ async function generateText(
5555
return response.text;
5656
}
5757
// [END googlegenaisdk_textgen_with_gcs_audio]
58+
// [END generativeaionvertexai_gemini_audio_summarization]
5859

5960
module.exports = {
6061
generateText,

genai/text-generation/textgen-with-mute-video.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
'use strict';
1616

17+
// [START generativeaionvertexai_gemini_single_turn_video]
1718
// [START googlegenaisdk_textgen_with_mute_video]
1819
const {GoogleGenAI} = require('@google/genai');
1920

@@ -62,6 +63,7 @@ async function generateText(
6263
return response.text;
6364
}
6465
// [END googlegenaisdk_textgen_with_mute_video]
66+
// [END generativeaionvertexai_gemini_single_turn_video]
6567

6668
module.exports = {
6769
generateText,

genai/text-generation/textgen-with-pdf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
'use strict';
16-
16+
// [START generativeaionvertexai_gemini_pdf]
1717
// [START googlegenaisdk_textgen_with_pdf]
1818
const {GoogleGenAI} = require('@google/genai');
1919

@@ -59,6 +59,7 @@ async function generateText(
5959
}
6060

6161
// [END googlegenaisdk_textgen_with_pdf]
62+
// [END generativeaionvertexai_gemini_pdf]
6263

6364
module.exports = {
6465
generateText,

0 commit comments

Comments
 (0)