Getting coordinates for a location when using external API tool

In section 4 (interfacing with external tools) there is an example of using the OpenAPI of open-metro.com to get the current weather of a location. In the example, the question is about New York, but the query_raven() function converts the location to its coordinates when calling the API.
How does it know the coordinates of the city? Does it call another function to get the coordinates? I’ve tried another location (Valencia, in Spain) and the functions gets the correct coordinates of the city.

The LLM must have been trained on data that likely includes the lat/lng coordinates of major cities. If you drop into ChatGPT and ask ‘What are the lat lng coordinates of NYC?’ you will see you get an answer without it searching or using any other tool.

If the LLM didn’t have this knowledge, or if you didn’t trust it not to hallucinate, we could have wired up another tool such as a geocoding API but that wasn’t necessary in this case.

Thanks for your answer Brenthan,
you are right. I’ve proved the Raven LLM on my computer asking for the coordinates of Valencia and the model “knows” the correct answer. I assume that this is valid for demonstration purposes as the example on the course, bur for a more robust application it seems convenient to use a nested function calling to retrieve the coordinates from a Geo API and then call the open-meteo API.

1 Like