Function calling to connect with your APIs

This is a new way to more reliably connect GPT's capabilities with external tools and APIs. Read OpenAI blog and documentation for more technical details.

Function calling is a programming concept that involves invoking a specific function within a program to perform a predefined task or operation. In OpenAI models, it involves calling a set of predefined functions allowing users to interact with external systems or APIs through the model’s responses. It enables more dynamic and interactive responses.

What can you do with it?

It's like having Gali chatbots interacting with your own backend, via your APIs.

Function calling allows you to more reliably get structured data back from the model, connecting the chatbot with your external tools and APIs. This means that you can leverage it for a huge number of different use cases and can customize it for your own needs.

While it's a relatively new feature and there's a lot to explore in terms of usage, we already see our customers supercharging their chatbots with function calling.

Some use cases include:
- Retrieving from your database a list of products/services that you want to offer to a user based on their preferences.
- Providing real-time info that is updated in your backend.
- Updating your DB with info extracted from the chats and coming directly from the conversations between users and chatbots.
- Retrieving the products still available with price and amount form a database.
- Check the availability of a service/product in real time.

...and much more!

How to set it up

Open 'Functions ' and add a function

Go to the 'Functions' tab. Please note that due to the large number of tokens used by this feature, function calling utilizes credits corresponding to two user messages – i.e., if a function is called by the model, it will consume extra credits for the additional request.

Each function is unique and contains its parameters. Since the model will choose whether to call a function or not, it's fundamental to describe the functions and their parameters properly and to conduct some tests before publishing them.

Function

Function Name: Add a name, it must be unique and without spaces.

Function Description: Describe the purpose and operation of the function to enable the model to accurately determine if and how to activate it. E.g. 'Retrieve the current weather conditions for a specified location.'

Backend Method: Add the HTTP method of your endpoint.

Backend URL: Add the endpoint URL (example: https://example.com/apis/products).

Parameters

Property Name: Add a name, it must be unique and without spaces. [REQUIRED]

Property Type: You can chose based on your needs between object, string, array, boolean, number. [REQUIRED]

Property Descriptions: Describe the propriety to let the model understand better this parameter. [Optional]

Property Enum Values: List of all potential values assignable to this property. [Optional]

Test it

Go to the 'Try it out' tab to test if everything works as expected.

Some tips:

1) Compare different GPT engines, 3.5 vs 4. While GPT-3.5 is faster, we see that GPT-4 provides a much higher quality output and follows the prompt and function descriptions much better. Moreover, we suggest to use the 'extended' version of engine models (unique on Gali!) that can contain a much larger set of sources.

2) Review the prompt and function description to make sure they don't overlap and are aligned. If a function is particularly complex or requires some parameters that are not working as you expect from the 'function description', you can even try to reinforce the need for the function in the prompt as well – this is not recommended, but in specific cases, it has worked better.

3) Make sure your APIs are set correctly and double-check the results on your end, especially if you use the functions to update fields.

4) In case of issues, please double check the parameters that the chatbot passes to your endpoint.