Skip to content

Commit 087a61d

Browse files
authored
Revert "refactor(genai): migrate region tags from generative-ai to genai fold…" (#4337)
This reverts commit 7517761.
1 parent 7517761 commit 087a61d

24 files changed

Lines changed: 835 additions & 24 deletions

genai/safety/safety-with-txt.js

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

1515
'use strict';
1616

17-
// [START generativeaionvertexai_gemini_safety_settings]
1817
// [START googlegenaisdk_safety_with_txt]
1918
const {GoogleGenAI} = require('@google/genai');
2019

@@ -110,7 +109,6 @@ async function generateWithSafetySettings(
110109
}
111110

112111
// [END googlegenaisdk_safety_with_txt]
113-
// [END generativeaionvertexai_gemini_safety_settings]
114112

115113
module.exports = {
116114
generateWithSafetySettings,

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

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

1515
'use strict';
1616

17-
// [START generativeaionvertexai_gemini_multiturn_chat_stream]
1817
// [START googlegenaisdk_textgen_chat_stream_with_txt]
1918
const {GoogleGenAI} = require('@google/genai');
2019

@@ -49,7 +48,6 @@ async function generateText(
4948
}
5049

5150
// [END googlegenaisdk_textgen_chat_stream_with_txt]
52-
// [END generativeaionvertexai_gemini_multiturn_chat_stream]
5351

5452
module.exports = {
5553
generateText,

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

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

1515
'use strict';
1616

17-
// [START generativeaionvertexai_gemini_multiturn_chat_nonstreaming]
18-
// [START aiplatform_gemini_multiturn_chat_nonstreaming]
1917
// [START googlegenaisdk_textgen_chat_with_txt]
2018
const {GoogleGenAI} = require('@google/genai');
2119

@@ -57,8 +55,7 @@ async function generateText(
5755
}
5856

5957
// [END googlegenaisdk_textgen_chat_with_txt]
60-
// [END aiplatform_gemini_multiturn_chat_nonstreaming]
61-
// [END generativeaionvertexai_gemini_multiturn_chat_nonstreaming]
58+
6259
module.exports = {
6360
generateText,
6461
};

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

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

1515
'use strict';
1616

17-
// [START generativeaionvertexai_gemini_single_turn_video]
1817
// [START googlegenaisdk_textgen_with_mute_video]
1918
const {GoogleGenAI} = require('@google/genai');
2019

@@ -63,7 +62,6 @@ async function generateText(
6362
return response.text;
6463
}
6564
// [END googlegenaisdk_textgen_with_mute_video]
66-
// [END generativeaionvertexai_gemini_single_turn_video]
6765

6866
module.exports = {
6967
generateText,

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

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

1515
'use strict';
1616

17-
// [START generativeaionvertexai_gemini_get_started]
1817
// [START googlegenaisdk_textgen_with_txt_img]
1918
const {GoogleGenAI} = require('@google/genai');
2019

@@ -48,7 +47,6 @@ async function generateContent(
4847
return response.text;
4948
}
5049
// [END googlegenaisdk_textgen_with_txt_img]
51-
// [END generativeaionvertexai_gemini_get_started]
5250

5351
module.exports = {
5452
generateContent,

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
// limitations under the License.
1414

1515
'use strict';
16-
17-
// [START generativeaionvertexai_gemini_content]
18-
// [START aiplatform_gemini_content]
1916
// [START generativeaionvertexai_stream_text_basic]
2017
// [START googlegenaisdk_textgen_with_txt_stream]
2118
const {GoogleGenAI} = require('@google/genai');
@@ -47,8 +44,6 @@ async function generateContent(
4744
}
4845
// [END googlegenaisdk_textgen_with_txt_stream]
4946
// [END generativeaionvertexai_stream_text_basic]
50-
// [END aiplatform_gemini_content]
51-
// [END generativeaionvertexai_gemini_content]
5247

5348
module.exports = {
5449
generateContent,

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
// limitations under the License.
1414

1515
'use strict';
16-
17-
// [START generativeaionvertexai_gemini_content_nonstreaming]
18-
// [START aiplatform_gemini_content_nonstreaming]
1916
// [START generativeaionvertexai_gemini_generate_from_text_input]
2017
// [START googlegenaisdk_textgen_with_txt]
2118
const {GoogleGenAI} = require('@google/genai');
@@ -44,8 +41,6 @@ async function generateContent(
4441
}
4542
// [END googlegenaisdk_textgen_with_txt]
4643
// [END generativeaionvertexai_gemini_generate_from_text_input]
47-
// [END aiplatform_gemini_content_nonstreaming]
48-
// [END generativeaionvertexai_gemini_content_nonstreaming]
4944

5045
module.exports = {
5146
generateContent,

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

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

1515
'use strict';
1616

17-
// [START generativeaionvertexai_gemini_video_with_audio]
1817
// [START googlegenaisdk_textgen_with_video]
1918
const {GoogleGenAI} = require('@google/genai');
2019

@@ -57,7 +56,6 @@ async function generateContent(
5756
return response.text;
5857
}
5958
// [END googlegenaisdk_textgen_with_video]
60-
// [END generativeaionvertexai_gemini_video_with_audio]
6159

6260
module.exports = {
6361
generateContent,
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// [START generativeaionvertexai_gemini_video_with_audio]
16+
const {GoogleGenAI} = require('@google/genai');
17+
/**
18+
* TODO(developer): Update these variables before running the sample.
19+
*/
20+
async function analyze_video_with_audio(
21+
projectId = 'PROJECT_ID',
22+
model = 'gemini-2.5-flash'
23+
) {
24+
const client = new GoogleGenAI({
25+
vertexai: true,
26+
project: projectId,
27+
location: 'us-central1',
28+
});
29+
30+
const filePart = {
31+
fileData: {
32+
fileUri: 'gs://cloud-samples-data/generative-ai/video/pixel8.mp4',
33+
mimeType: 'video/mp4',
34+
},
35+
};
36+
37+
const textPart = {
38+
text: `
39+
Provide a description of the video.
40+
The description should also contain anything important which people say in the video.`,
41+
};
42+
43+
const response = await client.models.generateContent({
44+
model: model,
45+
contents: [filePart, textPart],
46+
});
47+
48+
console.log(response.text);
49+
}
50+
// [END generativeaionvertexai_gemini_video_with_audio]
51+
52+
analyze_video_with_audio(...process.argv.slice(2)).catch(err => {
53+
console.error(err.message);
54+
process.exitCode = 1;
55+
});
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// [START generativeaionvertexai_gemini_multiturn_chat_nonstreaming]
16+
// [START aiplatform_gemini_multiturn_chat_nonstreaming]
17+
const {GoogleGenAI} = require('@google/genai');
18+
/**
19+
* TODO(developer): Update these variables before running the sample.
20+
*/
21+
async function createNonStreamingChat(
22+
projectId = 'PROJECT_ID',
23+
location = 'us-central1',
24+
model = 'gemini-2.5-flash'
25+
) {
26+
// Initialize client with your Cloud project and location
27+
const client = new GoogleGenAI({
28+
vertexai: true,
29+
project: projectId,
30+
location: location,
31+
});
32+
33+
const chat = client.chats.create({
34+
model: model,
35+
});
36+
37+
const response1 = await chat.sendMessage({message: 'Hello'});
38+
console.log('Chat response 1: ', response1.text);
39+
40+
const response2 = await chat.sendMessage({
41+
message: 'Can you tell me a scientific fun fact?',
42+
});
43+
console.log('Chat response 2: ', response2.text);
44+
45+
const response3 = await chat.sendMessage({
46+
message: 'How can I learn more about that?',
47+
});
48+
console.log('Chat response 3: ', response3.text);
49+
}
50+
// [END aiplatform_gemini_multiturn_chat_nonstreaming]
51+
// [END generativeaionvertexai_gemini_multiturn_chat_nonstreaming]
52+
53+
createNonStreamingChat(...process.argv.slice(2)).catch(err => {
54+
console.error(err.message);
55+
process.exitCode = 1;
56+
});

0 commit comments

Comments
 (0)