From the course: Developing a Full-Stack App with the Gemini API

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Creating the function calling method

Creating the function calling method

In this video, we'll be creating the function that our model will use to retrieve the weather information. This function will be used in what is called a function call by the model to present weather information for a selected destination. Let's get started. Just above the root endpoint, let's define a new function with the name getWeather. Our function definition takes in a location argument which represents the geographical name of our destination. It also takes in a unit argument that defines the unit we want to get the temperature measurement in. That can be Celsius or Fahrenheit. Now let's add a doc string to describe what our function does. It returns the weather information for a given destination. It is important to add a detailed docstring to your function calling methods. This helps the model to appropriately recommend them to be called and also extract the right arguments. Now, in a real-world scenario, we'll be using a live weather API like the Open Weather API to retrieve…

Contents