|
| 1 | +// Copyright 2025 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 | +'use strict'; |
| 16 | + |
| 17 | +// [START googlegenaisdk_tools_google_search_and_urlcontext_with_txt] |
| 18 | +const {GoogleGenAI} = require('@google/genai'); |
| 19 | + |
| 20 | +const GOOGLE_CLOUD_PROJECT = process.env.GOOGLE_CLOUD_PROJECT; |
| 21 | +const GOOGLE_CLOUD_LOCATION = process.env.GOOGLE_CLOUD_LOCATION || 'global'; |
| 22 | + |
| 23 | +async function generateContent( |
| 24 | + projectId = GOOGLE_CLOUD_PROJECT, |
| 25 | + location = GOOGLE_CLOUD_LOCATION |
| 26 | +) { |
| 27 | + const client = new GoogleGenAI({ |
| 28 | + vertexai: true, |
| 29 | + project: projectId, |
| 30 | + location: location, |
| 31 | + httpOptions: {apiVersion: 'v1beta1'}, |
| 32 | + }); |
| 33 | + |
| 34 | + // TODO(developer): Here put your URLs! |
| 35 | + const url = 'https://www.google.com/search?q=events+in+New+York'; |
| 36 | + |
| 37 | + const response = await client.models.generateContent({ |
| 38 | + model: 'gemini-2.5-flash', |
| 39 | + contents: `Give me a three-day events schedule based on ${url}. Also let me know what to take care of considering weather and commute.`, |
| 40 | + config: { |
| 41 | + tools: [{urlContext: {}}, {googleSearch: {}}], |
| 42 | + responseModalities: ['TEXT'], |
| 43 | + }, |
| 44 | + }); |
| 45 | + |
| 46 | + const output = []; |
| 47 | + |
| 48 | + { |
| 49 | + for (const part of response.candidates[0].content.parts) { |
| 50 | + console.log(part.text); |
| 51 | + output.push(part.text); |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + // 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. |
| 56 | + // |
| 57 | + // ### Three-Day Event Schedule: New York City (October 7-9, 2025) |
| 58 | + // |
| 59 | + // **Day 1: Tuesday, October 7, 2025 - Art and Culture** |
| 60 | + // |
| 61 | + // * **Morning (10:00 AM - 1:00 PM):** Visit "Phillips Visual Language: The Art of Irving Penn" at 432 Park Avenue. This exhibition is scheduled to end on this day, offering a last chance to see it. |
| 62 | + // * **Lunch (1:00 PM - 2:00 PM):** Grab a quick lunch near Park Avenue. |
| 63 | + // * **Afternoon (2:30 PM - 5:30 PM):** Explore the "Lincoln Center Festival of Firsts" at Lincoln Center. This festival runs until October 23rd, offering various performances or exhibits. Check their specific schedule for the day. |
| 64 | + // * **Evening (7:00 PM onwards):** Experience a classic Broadway show. Popular options mentioned for October 2025 include "Six The Musical," "Wicked," "Hadestown," or "MJ - The Musical." |
| 65 | + // |
| 66 | + // **Day 2: Wednesday, October 8, 2025 - Unique Experiences and SoHo Vibes** |
| 67 | + // |
| 68 | + // * **Morning (11:00 AM - 1:00 PM):** Head to Brooklyn for the "Secret Room at IKEA Brooklyn" at 1 Beard Street. This unique event is scheduled to end on October 9th. |
| 69 | + // * **Lunch (1:00 PM - 2:00 PM):** Enjoy lunch in Brooklyn, perhaps exploring local eateries in the area. |
| 70 | + // * **Afternoon (2:30 PM - 5:30 PM):** Immerse yourself in the "The Weeknd & Nespresso Samra Origins Vinyl Cafe" at 579 Broadway in SoHo. This pop-up, curated by The Weeknd, combines coffee and music and runs until October 14th. |
| 71 | + // * **Evening (6:00 PM onwards):** Explore the vibrant SoHo neighborhood, known for its shopping and dining. You could also consider a dinner cruise to see the illuminated Manhattan skyline and the Statue of Liberty. |
| 72 | + // |
| 73 | + // **Day 3: Thursday, October 9, 2025 - Film and Scenic Views** |
| 74 | + // |
| 75 | + // * **Morning (10:00 AM - 1:00 PM):** Attend a screening at the New York Greek Film Expo, which runs until October 12th in New York City. |
| 76 | + // * **Lunch (1:00 PM - 2:00 PM):** Have lunch near the film expo's location. |
| 77 | + // * **Afternoon (2:30 PM - 5:30 PM):** Take advantage of the pleasant October weather and enjoy outdoor activities. Consider biking along the rivers or through Central Park to admire the early autumn foliage. |
| 78 | + // * **Evening (6:00 PM onwards):** Visit an observation deck like the Empire State Building or Top of the Rock for panoramic city views. Afterwards, enjoy dinner in a neighborhood of your choice. |
| 79 | + // |
| 80 | + // ### Weather and Commute Considerations: |
| 81 | + // |
| 82 | + // **Weather in Early October:** |
| 83 | + // |
| 84 | + // * **Temperatures:** Expect mild to cool temperatures. Average daily temperatures in early October range from 10°C (50°F) to 18°C (64°F), with occasional warmer days reaching the mid-20s°C (mid-70s°F). Evenings can be quite chilly. |
| 85 | + // * **Rainfall:** October has a higher chance of rainfall compared to other months, with an average of 33mm and a 32% chance of rain on any given day. |
| 86 | + // * **Sunshine:** You can generally expect about 7 hours of sunshine per day. |
| 87 | + // * **What to Pack:** Pack layers! Bring a light jacket or sweater for the daytime, and a warmer coat for the evenings. An umbrella or a light raincoat is highly recommended due to the chance of showers. Comfortable walking shoes are a must for exploring the city. |
| 88 | + // |
| 89 | + // **Commute in New York City:** |
| 90 | + // |
| 91 | + // * **Public Transportation is Key:** The subway is generally the fastest and most efficient way to get around New York City, especially during the day. Buses are good for East-West travel, but can be slower due to traffic. |
| 92 | + // * **Using Apps:** Utilize Google Maps or official MTA apps to plan your routes and check for real-time service updates. The subway runs 24/7, but expect potential delays or changes to routes during nights and weekends due to maintenance. |
| 93 | + // * **Rush Hour:** Avoid subway and commuter train travel during peak rush hours (8 AM - 10 AM and 5 PM - 7 PM) if possible, as trains can be extremely crowded. |
| 94 | + // * **Subway Etiquette:** When on the subway, stand to the side of the doors to let people exit before boarding, and move to the center of the car to make space. Hold onto a pole or seat, and remove your backpack to free up space. |
| 95 | + // * **Transfers:** Subway fare is $2.90 per ride, and you get one free transfer between the subway and bus within a two-hour window. |
| 96 | + // * **Walking:** New York City is very walkable. If the weather is pleasant, walking between nearby attractions is an excellent way to see the city. |
| 97 | + // * **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. |
| 98 | + // * **Allow Extra Time:** Always factor in an additional 20-30 minutes for travel time, as delays can occur. |
| 99 | + |
| 100 | + return output; |
| 101 | +} |
| 102 | +// [END googlegenaisdk_tools_google_search_and_urlcontext_with_txt] |
| 103 | + |
| 104 | +module.exports = { |
| 105 | + generateContent, |
| 106 | +}; |
0 commit comments