API Reference
Namespaces
Modules
Classes
Events
Global
Externals

Class: Executor

Executor (registry [, rpcClient])


new Executor(registry [, rpcClient])

Executor — a command interpreter for string input.

Parameters:
Name Type Argument Description
registry object | function

command registry; can be a function that overrides the default executor

rpcClient object <optional>

JSON-RPC client; optional. If not passed in the executor will not be able to execute RPC commands.

Since:
  • 9.6.0

Returns:

a function that interprets string input and executes commands

Type
function
Example
const executor = Executor(function (input) {
		// note: you must call this in an environment where `this.echo` is defined
		fetch("http://llm.example.com/v1/chat/completions", {
			method: "POST",
			headers: {
				"Content-Type": "application/json",
				Authorization: `Bearer ${apikey}`
			},
			body: JSON.stringify({
				model: "ng-3.5-turbo",
				messages: [{ role: "system", content: input }]
			})
		})
			.then((response) => response.json())
			.then(this.echo)
			.catch(this.echo);
	});