Function Call

Execute functions to help your AI generate dynamic answers.

AIs were previously restricted to answering questions using your static knowledge base.

With function calling, your AI can now execute JavaScript functions that invoke third-party APIs to provide dynamic answers.

Creating a function

First, we create a function from the AI Studio -> Function Call screen.

Each function is made up of 3 things:

Prompt

A brief description that helps the AI understand what this function does.

Parameters

The list of parameters that are required for this function to be executed. The parameters need to be provided in the form of a JSON array.

Function handler

This is the Java script code executed to generate the response to the question asked.

This function would generally consist of

  • API endpoint that is to be invoked.

  • Conditions and logic to ask follow-up questions if parameters are missing

Testing the function

On the function, click on 'Save & Run function' to open the test window.

You can customize the LLM model used and see the response generated by it.

Additionally, to see the precise execution of the function, you can click 'Show log' to view the entire log.

Here, you can view the arguments detected by the function and the output it generated.

Last updated