Skip to content

Commit 9aaca6e

Browse files
authored
fix: Update non-streaming example (#3737)
* fix: Update non-streaming example Also remove diuplicate region tag to disambiguate correct sample * fix: Lint error
1 parent 4046b51 commit 9aaca6e

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

generative-ai/snippets/nonStreamingMultipartContent.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,13 @@ async function createNonStreamingMultipartContent(
5454
console.log(request.contents[0].parts[1].text);
5555

5656
console.log('Non-Streaming Response Text:');
57-
// Create the response stream
58-
const responseStream =
59-
await generativeVisionModel.generateContentStream(request);
6057

61-
// Wait for the response stream to complete
62-
const aggregatedResponse = await responseStream.response;
58+
// Generate a response
59+
const response = await generativeVisionModel.generateContent(request);
6360

6461
// Select the text from the response
6562
const fullTextResponse =
66-
aggregatedResponse.candidates[0].content.parts[0].text;
63+
response.response.candidates[0].content.parts[0].text;
6764

6865
console.log(fullTextResponse);
6966
}

generative-ai/snippets/streamMultipartContent.js

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// [START generativeaionvertexai_gemini_get_started]
1615
// [START aiplatform_gemini_get_started]
1716
const {VertexAI} = require('@google-cloud/vertexai');
1817

@@ -64,7 +63,6 @@ async function createStreamMultipartContent(
6463
}
6564
}
6665
// [END aiplatform_gemini_get_started]
67-
// [END generativeaionvertexai_gemini_get_started]
6866

6967
createStreamMultipartContent(...process.argv.slice(2)).catch(err => {
7068
console.error(err.message);

0 commit comments

Comments
 (0)