BRX NPM Package
Suggest Edits
brx-node
is the official interaction module for BRX.ai. It is used for interacting with BRX and includes functionalities such as sending requests and receiving responses.
We’re currently in BETA. Expect package changes and improvements in the future!
Install
Usage
Here is how you can interact with the BRX AI API using this module:
BRX Client Class
The BRX Client is used for fetching the BRK Object on runtime, and BRK Execution.
BRX.constructor(accessToken: string): BRX
Creates an instance of the BRX Client.
Parameters:
accessToken
(string
): The access token to interact with the BRX AI API.
Example:
BRX.get(BRK_ID: string)
Fetches a BRK schema and returns a promise for the response.
Note: this function only fetches the object needed for BRK constructor. You still have to initialize the BRK Class for execution.
Parameters:
- query: (
BRK
): The BRK
Example:
BRX.run(query: BRK)
Executes a BRK and returns a promise for the response.
Note: this function contains an optional callback function which fires events when a Dependency BRK is resolved. You can either await the full response, or optionally use callbacks.
Parameters:
- query: (
BRK
): The BRK
Example:
Example with callbacks:
BRK Class
A BRK is a prompt with an ability to include variables, and other BRKs as dependencies with recursion.
BRK.constructor(BRKSchema: GetSchemaObject): BRK
Creates an instance of the BRK.
Parameters:
BRKSchema
(GetSchemaObject
): The schema for the BRK. you can fetch this schema using BRX.get(’BRK-ID’)
Example:
Input Fields
A BRK may contain variable(s). These variables are surfaced from each BRK in the pipeline (BRK Dependencies).
Example:
Example with multiple variables