ToolResult Object in SuiteScript 2.1 for LLM Integration

The ToolResult object in SuiteScript 2.1 allows integration with LLM tools, enabling real-time data retrieval and execution of business logic.

·2 min read·View Oracle Docs

The ToolResult object is a fundamental component in SuiteScript 2.1, facilitating interactions with large language models (LLM). This object encapsulates the results of tool calls, enhancing the integration between LLMs and SuiteScript, which is critical for dynamic business processes.

What is the ToolResult Object?

The ToolResult object serves to hold the output from executing a tool specified in an LLM interaction. It comprises key properties that can be accessed within server scripts to manage data flows between LLM requests and SuiteScript logic.

Key Properties of ToolResult

A ToolResult object includes the following properties:

Property NameReturn TypeSupported Script TypesDescription
ToolResult.callllm.ToolCallServer scriptsContains the originating tool call request from the LLM.
ToolResult.outputsObject[]Server scriptsRepresents the outputs derived from the related tool call.

Detailed Description of Properties

  • ToolResult.call: This property holds the original request sent from the LLM, enabling context-aware interactions. The llm.ToolCall object provides the specifics needed for executing the defined tool.
  • ToolResult.outputs: This property is an array of objects that includes results obtained from executing the tool defined in the LLM call, thus providing the necessary outputs for further processing or response generation.

How to Use ToolResult in Scripts

To effectively use the ToolResult property in server scripts, it is important to follow specific syntax. The following example illustrates how a ToolResult object is created and its properties accessed:

suitescript
1// Example of creating a ToolResult object
2const toolResult = llm.createToolResult({
3 // Originating tool call request
4 call: toolCall,
5 // Outputs from running the specified tool
6 outputs: [{ result: handlerResult }]
7});
8
9const toolResultCall = toolResult.call;

This syntax is not functional in isolation but serves to demonstrate how the ToolResult object can be utilized in real-world scenarios, such as LLM interactions that require defined tools to produce meaningful outputs.

Error Handling

When working with ToolResult, it is essential to note the error code READ_ONLY, which is thrown if an attempt is made to set the property after its creation. Proper handling of such errors can ensure robust script behavior.

Conclusion

In summary, the ToolResult object is a pivotal element for developers looking to implement sophisticated integrations with LLMs in SuiteScript 2.1. It provides critical encapsulation of tool calls and outputs, allowing for efficient data-driven interactions within the NetSuite platform.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

What role does the ToolResult object play in SuiteScript 2.1?
The ToolResult object is crucial for integrating with large language models (LLM) in SuiteScript 2.1, as it encapsulates the results of tool calls, enabling dynamic interactions within server scripts.
Can the properties of a ToolResult object be modified after its creation?
No, attempting to set properties of a ToolResult object after its creation will result in a 'READ_ONLY' error code, indicating that these properties are immutable.
What are the key properties of the ToolResult object?
The key properties of the ToolResult object include 'ToolResult.call', which is a `llm.ToolCall` containing the original tool call request, and 'ToolResult.outputs', an array of objects representing outputs from the tool calls.
How are error codes handled when working with the ToolResult object?
The 'READ_ONLY' error code is notable when working with ToolResult, as it occurs if there's an attempt to modify its properties post-creation. Proper error handling is necessary to maintain robust script functionality.
Source: ToolResult Object Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Integration

View all Integration articles →