Skip to content

Commit

Permalink
chore: weather tool
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Price <[email protected]>
  • Loading branch information
drpebcak committed Mar 6, 2025
1 parent 5f42649 commit d1c9419
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
5 changes: 5 additions & 0 deletions weather/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/obot-platform/tools/weather

go 1.24.0

require github.com/icodealot/noaa v0.0.2
2 changes: 2 additions & 0 deletions weather/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/icodealot/noaa v0.0.2 h1:nL21mFSxJUBog7/0/vakIfA109T2A8/JpowzEzL9O+w=
github.com/icodealot/noaa v0.0.2/go.mod h1:vPMSrP4zBvlbWC34qtUR5w64dCp0xSRjkLy9/Ky81go=
46 changes: 46 additions & 0 deletions weather/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"fmt"
"github.com/icodealot/noaa"
"log"
"os"
)

func main() {
if len(os.Args) < 2 {
log.Fatal("usage: weather <command>")
}

command := os.Args[1]

latitude := os.Getenv("LATITUDE")
if latitude == "" {
log.Fatal("required latitude parameter not set")
}
longitude := os.Getenv("LONGITUDE")
if longitude == "" {
log.Fatal("required longitude parameter not set")
}

switch command {
case "getWeeklyForecast":
forecast, err := noaa.Forecast(latitude, longitude)
if err != nil {
log.Fatalf("error getting the forecast: %v", err)
return
}
for _, period := range forecast.Periods {
fmt.Printf("%-20s ---> %.0f%s\n", period.Name, period.Temperature, period.TemperatureUnit)
}
case "getHourlyForecast":
forecast, err := noaa.HourlyForecast(latitude, longitude)
if err != nil {
log.Fatalf("error getting the forecast: %v", err)
}
for _, period := range forecast.Periods {
fmt.Printf("%-20s ---> %.0f%s\n", period.StartTime, period.Temperature, period.TemperatureUnit)
}
}

}
21 changes: 21 additions & 0 deletions weather/tool.gpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
Name: Weather
Description: Tools for getting the weather forecast
Metadata: bundle: true
Share Tools: Get Weekly Forecast, Get Hourly Forecast

---
Name: Get Weekly Forecast
Description: Gets the weekly forecast for a given latitude and longitude
Param: latitude: The latitude to look up the forecast for
Param: longitude: The longitude to look up the forecast for

#!${GPTSCRIPT_TOOL_DIR}/bin/gptscript-go-tool getWeeklyForecast

---
Name: Get Hourly Forecast
Description: Gets the hourly forecast for a given latitude and longitude
Param: latitude: The latitude to look up the forecast for
Param: longitude: The longitude to look up the forecast for

#!${GPTSCRIPT_TOOL_DIR}/bin/gptscript-go-tool getHourlyForecast

0 comments on commit d1c9419

Please sign in to comment.