The last lessons have invoked local functions, but there is a worldwide web of services that you may want to use. This lesson will describe how you can use them. All right. Let's use the web. Many RESTful services are available online. Their interfaces often described using API standards such as the open API specification. It's very helpful to be able to integrate our function calling LLMs with such services. So let's take a look at how you can use them. In this simple example, what you've done is you've written Python code to interface with the joke API using RESTful methods. You would simply submit a Get request to the endpoint of the joke API, and you'll get back a response json that contains many keys, but the most relevant keys are the setup and the delivery of the joke. Let's run this to see. Okay, great. You're able to interface with this external resource using simple Python. However, it is not possible to call this directly within an LLM. Instead, what you need to do, is to write a tool to wrap around this endpoint. Let's give it a try. You simply write a Python function with a single argument for the category. You'll provide a dot string, and the main thing is you'll make the URL more dynamic, whereas the category that you'll pass to in the URL will be the argument in your Python tool. And then after that, you'll write code to submit a get request to your dynamic URL, and then you'll print out the setup and delivery of the response json. At this point, you're ready to try it with your LLM. Here's a user query and here's the Raven prompt. You will provide the function definition and the user query from earlier. Now let's call the LLM. Great! "What says oh oh oh? That's Santa's working backwards." Awesome. We got a joke that's in theme for December. Try running it again yourself. We have not been able to use Raven to generate the joke using the jokes API. The core idea, however, is that you're adding an adapter around your external APIs that converts the Python arguments that you generate using the LLM into the external API argument format. A lot of external assets use different kinds of API specifications. Open API being one of them. Writing tools allows you to unify them together. So just a practice, let's write a tool that uses the open API API specification. For this example, you'll be using the open meteo weather API. You will first download the open API specification in a Yaml format. Let's take a look at what you just downloaded. What you downloaded was a Yaml file that describes the Open meteo APIs. It provides you a list of descriptions of how the API will behave, including high level descriptions of the API itself. Most importantly, it provides a list of paths that you can send requests to, to get different kinds of responses. For example, sending a get request to this URL with the /v1/forecast path will provide you the seven day weather forecasts for certain coordinates. There are also parameters that you can add to your Get request that you send to this path. These parameters are described here and have certain types, such as arrays and the elements within the arrays, having to type strings with different enumerations allowed. This allows you to change the way the API will provide your responses for the seven-day forecast, by changing the parameter that you specify in the Get request you send to the endpoint. Since this is a Yaml format, you will need to convert the Yaml into a json to use our tool. You will first load the Yaml. You then need to convert by hand some of the data types, such as integers and floats, and then you will save the content back into a json. You can then use the open API Python generator utility to convert the json that you just saved out to disk into Python code that's capable of querying the endpoint. From here, you'll import the Python code that you just wrote out in the previous step. You can then provide a user query that depends on the API, such as asking for the current weather and the wind speed in New York. Then you can use the inspect approach that we discussed in the previous lesson, to construct the Raven prompt. Notice that in the prompt we have the function definition, which was automatically constructed from the output of the generator step and the dot string, which you wrote in the previous cell, as well as the user query which you provided in the cell before that. You can now send this to Raven. You can now run this call. Running the call will give you the output json from the API that will provide you the temperature in New York, which currently is 13.1°C, and New York has a wind speed of 23.7km/h. Try it yourself. Try the city you're in currently. In the next lesson, you'll be using Raven to do structured extraction, such as extracting insights as well as detailed structured data from unstructured texts. See you there.