llm.evaluatePrompt(options)
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 |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
100 |
Module |
|
Since |
2025.1 |
Parameters
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
string | number |
required |
ID of the prompt to evaluate. |
2025.1 |
|
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 |
|
string |
optional |
Compartment OCID. For more information, refer to Managing Compartments in the Oracle Cloud Infrastructure Documentation. |
2025.1 |
|
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 |
|
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 |
|
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 |
|
string |
optional |
Tenancy OCID. For more information, refer to Managing the Tenancy in the Oracle Cloud Infrastructure Documentation. |
2025.1 |
|
string |
optional |
User OCID. For more information, refer to Managing Users in the Oracle Cloud Infrastructure Documentation. |
2025.1 |
|
number |
optional |
Timeout in milliseconds, defaults to 30,000. |
2025.1 |
|
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 |
---|---|
|
The |
|
The prefix of the |
|
One or more unrecognized parameters for OCI configuration have been used. |
|
The |
|
The number of parallel requests to the LLM is greater than 5. |
|
The template for the specified prompt contains errors and cannot be processed. For example, this error is thrown in the following cases:
|
Syntax
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