from google.genai import types from google.genai import Client from dotenv import load_dotenv from toon_format import encode, decode load_dotenv() client = Client() def get_current_weather(location: str) -> str: """Returns the current weather and 15-day forecast. Args: location: The city and state, e.g. San Francisco, CA """ forecast = [] for i in range(16): # 0 for today, 1-15 for next 15 days day_data = { "date": f"2025-12-{21 + i:02d}", # Starting from Dec 21, 2025 "temperature": f"{70 + (i % 10)} F", # Varying temperatures "condition": ["sunny", "cloudy", "rainy", "partly cloudy"][i % 4], } forecast.append(day_data) data = { "location": location, "current": { "temperature": "72 F", "condition": "sunny", }, "forecast": forecast, } return encode(data) response = client.models.generate_content( model="gemini-2.5-flash", contents="What is the weather like in New York? Share Next 15 days forecast as well.", config=types.GenerateContentConfig( tools=[get_current_weather], thinking_config=types.ThinkingConfig( include_thoughts=False, thinking_budget=0, ), ), ) print(response.text) print(response.usage_metadata)