llm.StreamedResponse

Note:

The content in this help topic pertains to SuiteScript 2.1.

Object Description

The streamed response returned from the LLM.

Use the following methods to retrieve a streamed response from the LLM:

When calling these methods, 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 access the value of the StreamedResponse.model property in this way. Other properties (such as StreamedResponse.documents and StreamedResponse.citations) are accessible only after the entire response has been generated.

You can use an iterator to examine each token returned by the LLM. For an example, see llm.generateTextStreamed(options).

Supported Script Types

Server scripts

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

Module

N/llm Module

Methods and Properties

StreamedResponse Object Members

Since

2025.1

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.generateTextStreamed({
    prompt: 'Hello World'
});

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 

          

Related Topics

General Notices