I took a detour and decided to build a GPT referenced in OpenAI’s keynote from last week. I wanted to create one that had at least some information attached to the retrieval features and could call an API via a custom action.
Weather bots are fairly straightforward and there’s a ton of historic information available to upload without much cause for copyright concern. I ended up using the RapidAPI WeatherAPI.com endpoint. I asked ChatGPT to read the API from WeatherAPI and compare it to the example query provided in the GPT builder from OpenAI. It helped define a schema that would query the weather from WeatherAPI to build the forecast.
For fun, I wanted to compare how today’s weather data could do with an additional data source such as a large historical record or some sort of explainer text. I found a book on Project Gutenberg titled Meteorology by J.G. M’Phearson that seemed a literary explanation of the weather.
Unfortunately I couldn’t get the GPT to wait for the response from the WeatherAPI to write its summary, but for a low/no-code editor it’s pretty neat and I can see the power in it.
Query for Action
{
"openapi": "3.1.0",
"info": {
"title": "Get Current Weather Data",
"description": "Retrieves current weather data for a specified location.",
"version": "v1.0.0"
},
"servers": [
{
"url": "http://api.openweathermap.org/data/2.5"
}
],
"paths": {
"/weather": {
"get": {
"operationId": "GetCurrentWeatherByCoordinates",
"summary": "Get current weather data",
"description": "Fetches current weather data for a location based on latitude and longitude.",
"parameters": [
{
"name": "lat",
"in": "query",
"description": "Latitude of the location",
"required": true,
"schema": {
"type": "number",
"format": "float"
}
},
{
"name": "lon",
"in": "query",
"description": "Longitude of the location",
"required": true,
"schema": {
"type": "number",
"format": "float"
}
},
{
"name": "appid",
"in": "query",
"description": "Your unique API key for OpenWeatherMap",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful response with weather data",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"weather": {
"type": "array",
"items": {
"type": "object",
"description": "Weather condition",
"properties": {
"id": {
"type": "integer",
"description": "Weather condition id"
},
"main": {
"type": "string",
"description": "Group of weather parameters (Rain, Snow, Extreme etc.)"
},
"description": {
"type": "string",
"description": "Weather condition within the group"
},
"icon": {
"type": "string",
"description": "Weather icon id"
}
}
}
},
"main": {
"type": "object",
"description": "Main weather data",
"properties": {
"temp": {
"type": "number",
"description": "Temperature"
},
// Additional properties like pressure, humidity can be added here
}
}
// Additional data like wind, clouds can be added here
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {}
}
}
There might be some other ways to expand this, but as of now we’re only limited to one domain in the actions feature. I thought we could aggregate APIs from Microsoft Azure into a single API service so I could query for both the temperature and a historical fact that relates to it, but I haven’t been able to find the time to explore this yet.