Free Republic
Browse · Search
General/Chat
Topics · Post Article

To: Lazamataz

Monty Python.


36 posted on 01/18/2026 3:30:26 AM PST by ifinnegan (Democrats kill babies and harvest their organs to sell)
[ Post Reply | Private Reply | To 34 | View Replies ]


To: ifinnegan
No, something more like this:
import os
from langchain_openai import ChatOpenAI
from langchain.agents import initialize_agent, Tool
from langchain.agents import AgentType
import requests

# Set your API keys
os.environ["OPENAI_API_KEY"] = "sk-proj-51Hbb"
WEATHER_API_KEY = "70af9bd14888db"

# Define the Weather Tool function
def get_weather(location: str):
    """Fetch weather data for a city name or zipcode."""
    # This URL handles both city names and zipcodes via OpenWeatherMap's search
    url = f"http://api.openweathermap.org/data/2.5/weather?q={location}&appid={WEATHER_API_KEY}&units=metric"
    response = requests.get(url)
    
    if response.status_code == 200:
        data = response.json()
        temp = data['main']['temp']
        desc = data['weather'][0]['description']
        return f"The current weather in {location} is {temp}°C with {desc}."
    else:
        return "Sorry, I couldn't find that location."

39 posted on 01/18/2026 3:32:58 AM PST by Lazamataz (The quickest and easiest way to untold riches is to be elected to national office.)
[ Post Reply | Private Reply | To 36 | View Replies ]

Free Republic
Browse · Search
General/Chat
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson