Functions

This is how a function looks like.

It has 4 things you need to setup.

  1. A descriptive function name
  2. A parameters object in the given format.
  3. A description explaining what this function does.
  4. Function handler – The code that needs to run when this function gets called.

For example:

I have created an example function in the above screenshot for getting current weather.

  1. I put the name of the function as get_current_weather
  2. To get the current weather, I need to know the location and also the unit in which I need to tell the temperature in. So I added them as parameters.
  3. Then I wrote a description saying that this function gets current weather of a given location.
  4. Finally, I wrote the actual code to get the weather. This code gets the request as the argument, and it needs to return a response. See the screenshot to understand what I am talking about.

So, now when the user asks What is the current weather in Paris, SiteGPT will call the function get_current_weather using Paris as the location.