Skip to main content

execute

The execute method prioritizes filling in the variables in the "Prompt", then forwards it to the large AI model for processing.

async execute(
input: Record<string, string>,
parameters?: {
temperature?: number;
topP?: number;
stop?:
| []
| [string]
| [string, string]
| [string, string, string]
| [string, string, string, string];
maxTokens?: number;
presencePenalty?: number;
frequencyPenalty?: number;
}
): Promise<string>;

Reference​

Overview​

Assume your LLMExecutor is configured as shown in the following diagram.

images of LLMExecutor Prompt

You can utilize it in the following manner.

import { myLLMExecutor } from "#elements";

...

const input = {
"item_path": "the_value_of_your_actual_variable",
"selected_element": "the_value_of_your_actual_variable",
"babel_to_be_completed": "the_value_of_your_actual_variable",
"user_input": "the_value_of_your_actual_variable",
};
const result: string = await myLLMExecutor.execute(input);
console.log(result);

...

Parameters​

  • input: Key-value mapping of "Params".
  • parameters: Optional parameters, containing the following fields:
    • temperature: (optional) What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
    • topP: (optional) An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
    • stop: (optional) Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
    • maxTokens: (optional) The maximum number of tokens to generate in the completion. The token count of your prompt plus max tokens cannot exceed the model's context length.
    • presencePenalty: (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
    • frequencyPenalty: (optional) Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

Returns​

The execute method return a string value