Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update _id from /create #46

Merged
merged 21 commits into from
Jan 5, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
weather tool
  • Loading branch information
genekogan committed Jan 5, 2025
commit 3b5eb15acb5df648bd057779d3dd4e12dca96322
17 changes: 17 additions & 0 deletions eve/tools/weather/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Weather
description: Get the weather for a given location
cost_estimate: 1
output_type: string
status: prod
visible: true
parameters:
lat:
type: float
label: Latitude
description: The latitude of the location to get the weather for
required: true
lon:
type: float
label: Longitude
description: The longitude of the location to get the weather for
required: true
26 changes: 26 additions & 0 deletions eve/tools/weather/handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import json
import requests

async def handler(args: dict):
lat = args["lat"]
lon = args["lon"]

points_url = f"https://api.weather.gov/points/{lat},{lon}"
# Provide a descriptive User-Agent per NOAA policy
headers = {'User-Agent': 'MyForecastApp (contact@example.com)'}

# Step 1: Get the forecast endpoint
points_resp = requests.get(points_url, headers=headers)
points_data = points_resp.json()

# Step 2: Use the "forecast" or "forecastHourly" property to get actual data
forecast_url = points_data["properties"]["forecast"]
forecast_resp = requests.get(forecast_url, headers=headers)
forecast_data = forecast_resp.json()

output = forecast_data["properties"]

return {
"output": json.dumps(output)
}

4 changes: 4 additions & 0 deletions eve/tools/weather/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"lat": 33.355415,
"lon": -115.723984
}