StreamedResponse Object Members
Explore the StreamedResponse object members in SuiteScript 2.1 for detailed LLM response management.
The StreamedResponse object in SuiteScript 2.1 provides essential members for managing responses from a Large Language Model (LLM). This object allows developers to access various attributes such as chat history and citations, enabling dynamic interactions with AI-generated content.
What Are the Members of the StreamedResponse Object?
The StreamedResponse object includes several properties, each serving a unique purpose:
| Member Name | Return Type | Supported Script Types | Description |
|---|---|---|---|
StreamedResponse.chatHistory | llm.ChatMessage[] | Server scripts | This is a list of chat messages. |
StreamedResponse.citations | llm.Citation[] | Server scripts | This contains a list of citations used in the response. |
StreamedResponse.documents | llm.Document[] | Server scripts | This property holds a list of documents relevant to the response. |
StreamedResponse.model | string | Server scripts | Indicates the model used to generate the response. |
StreamedResponse.text | string | Server scripts | The actual text generated by the LLM. |
StreamedResponse.toolCalls | llm.ToolCall[] | Server scripts | Lists tool calls requested by the LLM. |
Understanding Each Member
- chatHistory: This property provides insights into the ongoing conversation. However, it's important to note that its value isn't accessible until the entire response from the LLM has been generated.
- citations and documents: Both properties are useful for tracking the sources of information that were leveraged to produce the output, enhancing transparency and credibility.
- model: Knowing which model generated the response can help evaluate the response's context and accuracy.
- text: This is the output content provided by the LLM, which developers will typically utilize within their applications.
Handling Errors in StreamedResponse
A common error associated with the StreamedResponse is READ_ONLY, which occurs if there attempt to set any of its properties.
Practical Example
The following code snippet demonstrates how to use the StreamedResponse object in a SuiteScript 2.1 server script:
1const response = llm.generateTextStreamed({2 prompt: 'Hello World'3});4 5var iter = response.iterator();6iters.each(function(token) {7 log.debug('token.value: ' + token.value);8 log.debug('response.text: ' + response.text);9 return true;10});11 12const responseChatHistory = response.chatHistory;This example shows how to generate a streamed response and iterate through tokens while logging valuable information, including the final text produced by the LLM.
Key Considerations
When working with the StreamedResponse object:
- Ensure that you are familiar with the overall structure and capabilities of the
llmmodule in SuiteScript 2.1. - Understand the timing of when properties like
chatHistoryandtextbecome available.
Key Takeaways
- The
StreamedResponseobject comprises several valuable members for handling AI outputs. - Understanding the individual properties aids in effective LLM response management.
- Careful handling of error conditions can help maintain optimal performance while interacting with the LLM.
Frequently Asked Questions (4)
What types of scripts support the StreamedResponse object in SuiteScript 2.1?
Are there any error conditions to be aware of when using the StreamedResponse object?
When does the chatHistory property of the StreamedResponse object become available?
How do the citations and documents properties of the StreamedResponse object benefit users?
Was this article helpful?
More in AI
- Natural Language Queries in NetSuite AI
Updated for NetSuite 2026.1, featuring enhancements in natural language queries. The MCP Standard Tools SuiteApp offers enhanced AI-driven interaction with
- Support for Consolidated Reports and SuiteQL Tool
Updated to reflect the latest features added in NetSuite 2026.1. Starting with the latest updates in NetSuite 2026.1, NetSuite enhances reporting capabilities
- Intelligent Close Manager Portlet in NetSuite
The Intelligent Close Manager portlet offers a centralized view for managing tasks and exceptions in NetSuite, enhancing close processes.
- New SuiteCloud Agent Skills for NetSuite 2026.1
NetSuite 2026.1 introduces new SuiteCloud Agent Skills, enhancing security and development workflows.
Advertising
Reach AI Professionals
Put your product in front of NetSuite experts who work with AI every day.
Sponsor This Category