Skip to content

Commit e4a0d21

Browse files
author
Guiners
committed
changed way of printing data
1 parent 35f7d89 commit e4a0d21

File tree

3 files changed

+12
-37
lines changed

3 files changed

+12
-37
lines changed

genai/tools/tools-google-maps-coordinates-with-txt.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,13 @@ async function generateContent(
5151
},
5252
});
5353

54-
const output = [];
55-
56-
console.log('\n--- Model Output ---');
57-
for (const candidate of response.candidates || []) {
58-
for (const part of candidate.content.parts || []) {
59-
if (part.text) {
60-
console.log(part.text);
61-
output.push(part.text);
62-
}
63-
}
64-
}
54+
console.log(response.text);
6555
// Example response:
6656
// 'Here are some of the top-rated places to get espresso near you: ...'
6757

68-
return output;
58+
console.log(response.candidates[0].urlContextMetadata);
59+
60+
return response.text;
6961
}
7062
// [END googlegenaisdk_tools_google_maps_coordinates_with_txt]
7163

genai/tools/tools-google-search-and-urlcontext-with-txt.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,7 @@ async function generateContent(
4343
},
4444
});
4545

46-
const output = [];
47-
48-
console.log('\n--- Model Output ---');
49-
for (const candidate of response.candidates || []) {
50-
for (const part of candidate.content.parts || []) {
51-
if (part.text) {
52-
console.log(part.text);
53-
output.push(part.text);
54-
}
55-
}
56-
}
57-
46+
console.log(response.text);
5847
// Here is a possible three-day event schedule for New York City, focusing on the dates around October 7-9, 2025, along with weather and commute considerations.
5948
//
6049
// ### Three-Day Event Schedule: New York City (October 7-9, 2025)
@@ -100,7 +89,9 @@ async function generateContent(
10089
// * **Taxis/Ride-sharing:** Uber, Lyft, and Curb (for NYC taxis) are available, but driving in the city is generally discouraged due to traffic and parking difficulties.
10190
// * **Allow Extra Time:** Always factor in an additional 20-30 minutes for travel time, as delays can occur.
10291

103-
return output;
92+
console.log(response.candidates[0].urlContextMetadata);
93+
94+
return response.text;
10495
}
10596
// [END googlegenaisdk_tools_google_search_and_urlcontext_with_txt]
10697

genai/tools/tools-urlcontext-with-txt.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,7 @@ async function generateContent(
4444
},
4545
});
4646

47-
const output = [];
48-
49-
console.log('\n--- Model Output ---');
50-
for (const candidate of response.candidates || []) {
51-
for (const part of candidate.content.parts || []) {
52-
if (part.text) {
53-
console.log(part.text);
54-
output.push(part.text);
55-
}
56-
}
57-
}
47+
console.log(response.text);
5848

5949
// Gemini 2.5 Pro and Gemini 2.5 Flash are both advanced models offered by Google AI, but they are optimized for different use cases.
6050
//
@@ -84,7 +74,9 @@ async function generateContent(
8474
// In essence, while both models are powerful and capable, Gemini 2.5 Pro is designed for maximum performance in complex reasoning tasks, whereas Gemini 2.5 Flash prioritizes cost-effectiveness and speed for broader, high-throughput applications.
8575
// get URLs retrieved for context
8676

87-
return output;
77+
console.log(response.candidates[0].urlContextMetadata);
78+
79+
return response.text;
8880
}
8981
// [END googlegenaisdk_tools_urlcontext_with_txt]
9082

0 commit comments

Comments
 (0)