llm.evaluatePromptStreamed(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 streamed response from the LLM. You can use this method to evaluate a prompt that's 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. This method is similar to llm.evaluatePrompt(options) but returns the LLM response as a stream. After calling this method, you can access the partial response (using the StreamedResponse.text property of the returned llm.StreamedResponse object) before the entire response has been generated. You can also use an iterator to examine each token returned by the LLM, as the following example shows:
In this example, This method consumes AI Units. For more information, see NetSuite AI Units and NetSuite Features and AI Units FAQ. |
|
Returns |
|
|
Aliases |
Note:
These aliases use the same parameters and can throw the same errors as the llm.evaluatePromptStreamed(options) method. |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.1 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 |
Important:
This object is no longer supported. Any values specified in this object are ignored. |
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 |
|
|
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 isn't a functional example. For a complete script example, see N/llm Module Script Samples.
// Add additional code
...
const response = llm.evaluatePromptStreamed({
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."
}
});
var iter = response.iterator();
iter.each(function(token){
log.debug("token.value: " + token.value);
log.debug("response.text: " + response.text);
return true;
})
...
// Add additional code