12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ // [START aiplatform_gemini_single_turn_multi_image]
15
16
const { VertexAI} = require ( '@google-cloud/vertexai' ) ;
16
17
const axios = require ( 'axios' ) ;
17
18
@@ -20,28 +21,23 @@ async function getBase64(url) {
20
21
return Buffer . from ( image . data ) . toString ( 'base64' ) ;
21
22
}
22
23
24
+ /**
25
+ * TODO(developer): Update these variables before running the sample.
26
+ */
23
27
async function sendMultiModalPromptWithImage (
24
28
projectId = 'PROJECT_ID' ,
25
29
location = 'LOCATION_ID' ,
26
30
model = 'MODEL'
27
31
) {
28
- // [START aiplatform_gemini_single_turn_multi_image]
29
- /**
30
- * TODO(developer): Uncomment these variables before running the sample.
31
- */
32
- // const projectId = 'your-project-id';
33
- // const location = 'us-central1';
34
- // const model = 'chosen-genai-model';
35
-
36
32
// For images, the SDK supports base64 strings
37
33
const landmarkImage1 = await getBase64 (
38
34
'https://storage.googleapis.com/cloud-samples-data/vertex-ai/llm/prompts/landmark1.png'
39
35
) ;
40
36
const landmarkImage2 = await getBase64 (
41
- 'https://storage.googleapis.com/cloud-samples-data/vertex-ai/llm/prompts/landmark1 .png'
37
+ 'https://storage.googleapis.com/cloud-samples-data/vertex-ai/llm/prompts/landmark2 .png'
42
38
) ;
43
39
const landmarkImage3 = await getBase64 (
44
- 'https://storage.googleapis.com/cloud-samples-data/vertex-ai/llm/prompts/landmark1 .png'
40
+ 'https://storage.googleapis.com/cloud-samples-data/vertex-ai/llm/prompts/landmark3 .png'
45
41
) ;
46
42
47
43
// Initialize Vertex with your Cloud project and location
@@ -96,9 +92,8 @@ async function sendMultiModalPromptWithImage(
96
92
aggregatedResponse . candidates [ 0 ] . content . parts [ 0 ] . text ;
97
93
98
94
console . log ( fullTextResponse ) ;
99
-
100
- // [END aiplatform_gemini_single_turn_multi_image]
101
95
}
96
+ // [END aiplatform_gemini_single_turn_multi_image]
102
97
103
98
sendMultiModalPromptWithImage ( ...process . argv . slice ( 2 ) ) . catch ( err => {
104
99
console . error ( err . message ) ;
0 commit comments