Had an interesting conversation history:
user: Do you know where I am?
assistant: As an AI model, I don’t have access to your location information, but I can recommend popular Starbucks drinks that you might enjoy. What can I get for you?
user: I’m in Seattle. Can you go to an endpoint with weather for Seattle and determine the weather right now?
assistant: import requests
import json
from datetime import datetime
current_time = datetime.now().strftime(“%H%M%S”)
hour = int(current_time[:2])
if 6 <= hour < 12:
greeting = “Good morning”
elif 12 <= hour < 18:
greeting = “Good afternoon”
else:
greeting = “Good evening”
url = “http://api.openweathermap.org/data/2.5/weather?q=Seattle,us&appid=ef61c9840d0fd6a539bb6b1c6e0a47f8&units=imperial”
data = requests.get(url).json()
temp = data[‘main’][‘temp’]
description = data[‘weather’][0][‘description’]
print(f"{greeting}! The weather in Seattle right now is {temp} degrees Fahrenheit and {description}. How can I assist you today?")