assistance-engine/docs/developer.avapframework.com/appendices_24.md

1.8 KiB

functionAI()

The functionAI() command uses an artificial intelligence model to convert a natural language description of a function or process into a code implementation, which is then executed and returns the result. This command converts a description provided in prompt into a function that operates on the data of the table specified in source , and stores the result in a target variable.

Parameters

  • prompt Type: variable Description: A string in natural language that describes the process or function to be executed. For example, "calculate the average of the salary column".
  • source Type: variable Description: The name of the table on which the generated function should be executed. It must be a variable containing the name of the table in the database.
  • TargetVariable Type: variable Description: The variable in which the result of the executed function or process will be stored. It must be a variable that will receive the result of the generated and executed code.

Command Flow

Example Usage

Suppose you want to calculate the average of the salary column in a table called employees .

// Define variables
prompt = "calculate the average of the salary column"
source = "employees"
averageSalary = ''

// Call the command to process the function
functionAI(prompt, source, averageSalary)

// Return the result of the function via addResult
addResult(averageSalary)

In this example, the functionAI() command will convert the prompt into a code implementation to calculate the average of the salary column in the employees table. The result of the calculation will be stored in the averageSalary variable, and this variable will be returned via addResult(averageSalary) . The output will be the calculated average of the salary column.