The weather example Action in creating a GPT is confusing me and probably because I do not know enough about OpenAPI. Here is the documentation API that does not require.a credit card or authentication:
In your case, this path needs to exist: https://api.weather.gov/points?latitude=<string>&longitude=<string>
Have you checked if it’s not actually like this: https://api.weather.gov/points{latitude}/{longitude}
Here a description for each field:
{
"openapi": "3.1.0",
"info": {
"title": <Title for the server>,
"description": <Description of the server>,
"version": "v1.0.0"
},
"servers": [
{
"url": "<server domain>"
}
],
"paths": {
"/<the path for the api in the server>": {
"get": {
"description": "<the description of the api>",
"operationId": "<the name to reference to the AI>",
"parameters": [
{
"name": "<parameter>",
"in": <"query" or "path">,
"description": "<description of the parameter>",
"required": <true or false>,
"schema": {
"type": <"string", "int" or "float">
}
}
],
"deprecated": false
}
},
"/<another path>": {
...
}
}
},
"components": {
"schemas": {}
}
}
What you specify as a function tool to the API is actually provided (after being rewritten to a different form) directly to the AI model.
It is the AI that must understand your function, and the AI must have the cognitive abilities to construct the response parameters you want to take and then employ in your backend code for communicating with the various APIs you need to fulfill the request with a return value.
Easy for the AI to write:
tools.functions.weather_forecast(“city”: “Los Angeles, CA”)
Hard for the AI to write:
tools.functions.weather_noaa_gridpoint(“field_office”: “PQR”, “forecast_grid”: “134,110”)
@paul.fishwick I was actually doing the same thing and found the weather.gov api to be a bit challenging for the reasons @_j pointed out (primary making two calls).
I found another free (for non-commercial use) service called Open-Meteo on Vand. Here’s both the OpenAPI and a function spec you can use with OpenAI models. (Open-Meteo Weather API - Vand.io).
Note that it still uses lat long as an input but I’ve found GPT 3.5 is able to do this reliably, at least for the major cities I’ve tried it with. Might be less accurate for small towns.
Thanks. Good point. In some ways, I find it easier to use the library methods/functions in an Assistant as contrasted with the Action schema. More control.
That is great. I’ll try now. On these schemas, while I completely understand how to formulate a REST API via curl or web browser, the challenge for me is getting from understanding the REST API to translating this into a JSON schema. In some conversations online, they use ChatGPT to generate the schema. I tried this but got OpenAI parser errors.
I would suggest to avoid the use of latitude and longitude unless you have no other choice.
I would like to suggest this site weatherapi, their free tier is sufficient for us to test things out.
Query parameter based on which data is sent back. It could be following:
* Latitude and Longitude (Decimal degree) e.g: q=48.8567,2.3508
* city name e.g.: q=Paris
* US zip e.g.: q=10001
* UK postcode e.g: q=SW1
* Canada postal code e.g: q=G2J
* metar:<metar code> e.g: q=metar:EGLL
* iata:<3 digit airport code> e.g: q=iata:DXB
* auto:ip IP lookup e.g: q=auto:ip
* IP address (IPv4 and IPv6 supported) e.g: q=100.0.0.1
* By ID returned from Search API. e.g: q=id:2801268
* bulk New