From 18736cfca98d30ad5503b7b641124f9f57bbe634 Mon Sep 17 00:00:00 2001 From: "pattishin@google.com" Date: Wed, 13 Dec 2023 09:47:59 -0800 Subject: [PATCH 1/2] fix: resolve small bug (repeated image), and moving region tag --- .../snippets/sendMultiModalPromptWithImage.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/generative-ai/snippets/sendMultiModalPromptWithImage.js b/generative-ai/snippets/sendMultiModalPromptWithImage.js index 8b2392e9ed..33edbde3a1 100644 --- a/generative-ai/snippets/sendMultiModalPromptWithImage.js +++ b/generative-ai/snippets/sendMultiModalPromptWithImage.js @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// [START aiplatform_gemini_single_turn_multi_image] const {VertexAI} = require('@google-cloud/vertexai'); const axios = require('axios'); @@ -20,28 +21,23 @@ async function getBase64(url) { return Buffer.from(image.data).toString('base64'); } +/** + * TODO(developer): Update these variables before running the sample. + */ async function sendMultiModalPromptWithImage( projectId = 'PROJECT_ID', location = 'LOCATION_ID', model = 'MODEL' ) { - // [START aiplatform_gemini_single_turn_multi_image] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - // const projectId = 'your-project-id'; - // const location = 'us-central1'; - // const model = 'chosen-genai-model'; - // For images, the SDK supports base64 strings const landmarkImage1 = await getBase64( 'https://storage.googleapis.com/cloud-samples-data/vertex-ai/llm/prompts/landmark1.png' ); const landmarkImage2 = await getBase64( - 'https://storage.googleapis.com/cloud-samples-data/vertex-ai/llm/prompts/landmark1.png' + 'https://storage.googleapis.com/cloud-samples-data/vertex-ai/llm/prompts/landmark2.png' ); const landmarkImage3 = await getBase64( - 'https://storage.googleapis.com/cloud-samples-data/vertex-ai/llm/prompts/landmark1.png' + 'https://storage.googleapis.com/cloud-samples-data/vertex-ai/llm/prompts/landmark3.png' ); // Initialize Vertex with your Cloud project and location @@ -96,9 +92,8 @@ async function sendMultiModalPromptWithImage( aggregatedResponse.candidates[0].content.parts[0].text; console.log(fullTextResponse); - - // [END aiplatform_gemini_single_turn_multi_image] } +// [END aiplatform_gemini_single_turn_multi_image] sendMultiModalPromptWithImage(...process.argv.slice(2)).catch(err => { console.error(err.message); From 0c83ca47d2e31b7562b0cde3f04d80f1f023b850 Mon Sep 17 00:00:00 2001 From: "pattishin@google.com" Date: Wed, 13 Dec 2023 21:39:57 -0800 Subject: [PATCH 2/2] fix: resolve typo --- generative-ai/snippets/nonStreamingMultipartContent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generative-ai/snippets/nonStreamingMultipartContent.js b/generative-ai/snippets/nonStreamingMultipartContent.js index 086c4586d1..1ab9929112 100644 --- a/generative-ai/snippets/nonStreamingMultipartContent.js +++ b/generative-ai/snippets/nonStreamingMultipartContent.js @@ -41,7 +41,7 @@ async function createNonStreamingMultipartContent( // For images, the SDK supports both Google Cloud Storage URI and base64 strings const filePart = { - fileSata: { + fileData: { fileUri: image, mimeType: mimeType, },