llm.evaluatePrompt(options)

Note:

The content in this help topic pertains to SuiteScript 2.1.

Method Description

Takes the ID of an existing prompt and values for variables used in the prompt and returns the response from the LLM.

You can use this method to evaluate a prompt that is available in Prompt Studio by providing values for any variables that the prompt uses. The resulting prompt is sent to the LLM, and this method returns the LLM response, similar to the llm.generateText(options) method. For more information about Prompt Studio, see Prompt Studio.

When unlimited usage mode is used, this method accepts the OCI configuration parameters. You can also specify OCI configuration parameters on the SuiteScript tab of the AI Preferences page. For more information, see Using Your Own OCI Configuration for SuiteScript Generative AI APIs.

Returns

llm.Response

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

100

Module

N/llm Module

Since

2025.1

Parameters

Parameter

Type

Required / Optional

Description

Since

options.id

string | number

required

ID of the prompt to evaluate.

2025.1

options.ociConfig

Object

optional

Configuration needed for unlimited usage through OCI Generative AI Service. Required only when accessing the LLM through an Oracle Cloud Account and the OCI Generative AI Service. SuiteApps installed to target accounts are prevented from using the free usage pool for N/llm and must use the OCI configuration.

Instead of specifying OCI configuration details using this parameter, you can specify them on the SuiteScript tab of the AI Preferences page. When you do so, those OCI configuration details are used for all scripts in your account that use N/llm module methods, and unlimited usage mode is enabled for those scripts. If you specify OCI configuration details in both places (using this parameter and using the SuiteScript tab of the AI Preferences page), the details provided in this parameter override those that are specified on the SuiteScript tab. For more information, see Using Your Own OCI Configuration for SuiteScript Generative AI APIs.

2025.1

options.ociConfig.compartmentId

string

optional

Compartment OCID. For more information, refer to Managing Compartments in the Oracle Cloud Infrastructure Documentation.

2025.1

options.ociConfig.endpointId

string

optional

Endpoint ID. This value is needed only when a custom OCI DAC (dedicated AI cluster) is to be used. For more information, refer to Managing an Endpoint in Generative AI in the Oracle Cloud Infrastructure Documentation.

2025.1

options.ociConfig.fingerprint

string

optional

Fingerprint of the public key (only a NetSuite secret is accepted—see Creating Secrets ). For more information, refer to Required Keys and OCIDs in the Oracle Cloud Infrastructure Documentation.

2025.1

options.ociConfig.privateKey

string

optional

Private key of the OCI user (only a NetSuite secret is accepted—see Creating Secrets ). For more information, refer to Required Keys and OCIDs in the Oracle Cloud Infrastructure Documentation.

2025.1

options.ociConfig.tenancyId

string

optional

Tenancy OCID. For more information, refer to Managing the Tenancy in the Oracle Cloud Infrastructure Documentation.

2025.1

options.ociConfig.userId

string

optional

User OCID. For more information, refer to Managing Users in the Oracle Cloud Infrastructure Documentation.

2025.1

options.timeout

number

optional

Timeout in milliseconds, defaults to 30,000.

2025.1

options.variables

Object

optional

Values for the variables that are used in the prompt. Provide these values as an object with key-value pairs. For an example, see the Syntax section.

You can use Prompt Studio to generate a SuiteScript example that uses this method and includes the variables for a prompt in the correct format. When viewing a prompt in Prompt Studio, click Show SuiteScript Example to generate SuiteScript code with all of the variables that prompt uses. You can then use this code in your scripts and provide a value for each variable.

2025.1

Errors

Error Code

Thrown If

SSS_MISSING_REQD_ARGUMENT

The options.id parameter is missing.

INVALID_ID_PREFIX

The prefix of the options.id parameter is not custprompt.

UNRECOGNIZED_OCI_CONFIG_PARAMETERS

One or more unrecognized parameters for OCI configuration have been used.

ONLY_API_SECRET_IS_ACCEPTED

The options.ociConfig. privateKey or options.ociConfig.fingerprint parameters are not NetSuite API secrets.

MAXIMUM_PARALLEL_REQUESTS_LIMIT_EXCEEDED

The number of parallel requests to the LLM is greater than 5.

TEMPLATE_PROCESSING_EXCEPTION

The template for the specified prompt contains errors and cannot be processed. For example, this error is thrown in the following cases:

  • The prompt template uses required variables that are not specified in the options.variables parameter.

  • The prompt template contains syntax errors, such as an opening if statement without a corresponding closing one.

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/llm Module Script Samples.

            // Add additional code
...

const response = llm.evaluatePrompt({
    id: -1,
    variables: {
        "form": {
            "itemid": "My Item",
            "stockdescription": "This is a custom item for my business.",
            "vendorname": "Item Supplier Inc.",
            "isdropshipitem": "false",
            "isspecialorderitem": "true",
            "displayname": "My Awesome Item"
        },
        "text": "This item increases productivity."
    },
    ociConfig: {
        // Replace ociConfig values with your Oracle Cloud Account values
        userId: 'ocid1.user.oc1..aaaaaaaanld….exampleuserid',
        tenancyId: 'ocid1.tenancy.oc1..aaaaaaaabt….exampletenancyid',
        compartmentId: 'ocid1.compartment.oc1..aaaaaaaaph….examplecompartmentid',
        // Replace fingerprint and privateKey with your NetSuite API secret ID values
        fingerprint: 'custsecret_oci_fingerprint',
        privateKey: 'custsecret_oci_private_key'
   }
});

...
// Add additional code 

          

Related Topics

General Notices