diff --git a/packages/docs/docs/node-reference/abort-graph.mdx b/packages/docs/docs/node-reference/abort-graph.mdx index e8d7ce8f6..f8a629672 100644 --- a/packages/docs/docs/node-reference/abort-graph.mdx +++ b/packages/docs/docs/node-reference/abort-graph.mdx @@ -1,5 +1,94 @@ --- -title: 'Abort Graph' +id: abort-graph +title: Abort Graph Node +sidebar_label: Abort Graph --- -# Abort Graph Node +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +## Overview + +The Abort Graph Node is used to stop the execution of the entire graph immediately. It can either "successfully" abort the graph (early-exit), or "error" abort the graph. This can be useful for stopping the graph under certain conditions, or for handling errors. + +![Abort Graph Node Screenshot](./assets/abort-graph-node.png) + + + + + +## Inputs + +| Title | Data Type | Description | Default Value | Notes | +| ------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | +| Data or Error | `any` | The data or error message to be used when aborting the graph. If it's a string, it will be used as the error message for error aborting. | N/A | None | +| Successfully | `boolean` | Determines whether the graph should be aborted successfully or with an error. | true | Only available if the "Successfully Abort" setting is toggled on in the node's settings. Otherwise, the node's setting value will be used. | + + + + + +## Outputs + +This node does not have any outputs. + + + + + +## Editor Settings + +| Setting | Description | Default Value | Use Input Toggle | +| ------------------ | --------------------------------------------------------------------------------------------------------------------- | ------------- | ---------------- | +| Successfully Abort | Determines whether the graph should be aborted successfully or with an error. | true | Yes | +| Error Message | The error message to be used when aborting the graph with an error. Only used if "Successfully Abort" is not checked. | (Empty) | No | + + + + + +### Example 1: Successfully aborting a graph + +1. Add an Abort Graph node to your graph. +2. Make sure the "Successfully Abort" setting is checked. +3. Connect any node to the `Data or Error` input of the Abort Graph node. This could be a condition, a value, or anything else. +4. Run your graph. The graph will abort immediately after the Abort Graph node is processed, and no subsequent nodes will be executed. + +### Example 2: Aborting a graph with an error + +1. Add an Abort Graph node to your graph. +2. Uncheck the "Successfully Abort" setting. +3. Optionally, enter an error message in the "Error Message" setting. This message will be used as the error message when the graph is aborted. +4. Connect any node to the `Data or Error` input of the Abort Graph node. If this node outputs a string, it will be used as the error message when the graph is aborted. +5. Run your graph. The graph will abort immediately after the Abort Graph node is processed, and no subsequent nodes will be executed. An error message will be displayed, either the one from the `Data or Error` input or the one from the "Error Message" setting. + +## Error Handling + +The Abort Graph Node does not produce any errors itself. However, it causes the entire graph to stop executing when it is processed, either successfully or with an error. + +## FAQ + +**Q: What happens if I connect a non-string node to the `Data or Error` input?** + +A: If the node outputs a string, it will be used as the error message when the graph is aborted. If it does not output a string, it will be coerced into a string. + +**Q: What happens if I connect a node to the `Successfully` input but the "Successfully Abort" setting is not checked?** + +A: The `Successfully` input will be ignored, and the graph will be aborted with an error. + +**Q: What happens if I don't connect anything to the `Data or Error` input or leave the "Error Message" setting empty?** + +A: The graph will be aborted with a default error message of "Graph aborted with error". + +## See Also + +- [If Node](./if.mdx) +- [If/Else Node](./if-else.mdx) +- [Race Inputs Node](./race-inputs.mdx) diff --git a/packages/docs/docs/node-reference/append-to-dataset.mdx b/packages/docs/docs/node-reference/append-to-dataset.mdx index d3ede598c..61184deca 100644 --- a/packages/docs/docs/node-reference/append-to-dataset.mdx +++ b/packages/docs/docs/node-reference/append-to-dataset.mdx @@ -1,5 +1,101 @@ --- -title: 'Append to Dataset' +id: append-to-dataset +title: Append to Dataset Node +sidebar_label: Append to Dataset --- -# Append to Dataset Node +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +![Append to Dataset Node Screenshot](./assets/append-to-dataset-node.png) + +## Overview + +The Append to Dataset Node is used to append a row of data to a specified dataset. This node is particularly useful when you want to add new data to an existing dataset for further processing or analysis. + +The node requires a dataset provider to be available in the context when the graph is being run. The dataset provider is responsible for managing the storage and retrieval of datasets. In the Rivet application, the dataset provider is handled for you automatically. + +For more information on datasets, see the [Data Studio](../user-guide/features/data-studio.md) section of the user guide. + + + + + +## Inputs + +| Title | Data Type | Description | Default Value | Notes | +| ---------- | ---------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- | -------------------------------------------------------------------------- | +| Data | `string[]` | The data to be appended to the dataset. | (required) | The input will be coerced into a string array if it is not a string array. | +| ID | `string` | The ID for the new row of data. If not provided, a new ID will be generated. | (Automatically generated) | The input will be coerced into a string if it is not a string. | +| Embedding | `vector` | An optional vector that can be associated with the new row of data. | (empty) | The input will be coerced into a vector if it is not a vector. | +| Dataset ID | `string` | The ID of the dataset to append to. This input is only available if `Use Dataset ID Input` is enabled. | (required if if the input toggle for Dataset ID is enabled) | The input will be coerced into a string if it is not a string. | + + + + + +## Outputs + +| Title | Data Type | Description | Notes | +| ------- | --------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------ | +| Dataset | `object` | The new row of data that was appended to the dataset. | The output will be an object containing the ID, data, and embedding of the new row. | +| ID | `string` | The ID of the dataset that the data was appended to. | The output will be the same as the Dataset ID input or the Dataset ID specified in the settings. | + + + + + +## Editor Settings + +| Setting | Description | Default Value | Use Input Toggle | Input Data Type | +| -------------------- | ------------------------------------------------------------------------- | ------------- | ---------------- | --------------- | +| Dataset | The ID of the dataset to append to. | (required) | Yes | `string` | +| Use Dataset ID Input | If enabled, the Dataset ID can be provided via the Dataset ID input port. | False | No | N/A | + + + + + +## Example 1: Append data to a dataset + +1. Create an [Array Node](./array.mdx) and set the values to `["John Doe", "30", "Engineer"]`. +2. In the [Data Studio](../user-guide/features/data-studio.md), create a new dataset with the ID `employees`. +3. Create an Append to Dataset Node and set the Dataset ID to `employees`. +4. Connect the Array Node to the `Data` input of the Append to Dataset Node. +5. Run the graph. The `Dataset` output of the Append to Dataset Node should contain the new row of data that was appended to the `employees` dataset. + +![Append to Dataset Node Example 1.1](./assets/append-to-dataset-node-example-01.png) +![Append to Dataset Node Example 1.2](./assets/append-to-dataset-node-example-01-2.png) + +## Error Handling + +The Append to Dataset Node will error if the dataset provider is not available in the context when the graph is being run. It will also error if the `Data` input is not provided. + +## FAQ + +**Q: What is a dataset provider?** + +A: A dataset provider is an object that is responsible for managing the storage and retrieval of datasets. It is passed to the context when the graph is being run. The dataset provider must implement the `DatasetProvider` interface, which includes methods for getting, putting, and deleting datasets. See the [API Reference](../api-reference.md) for more information. + +**Q: Can I append data to multiple datasets at once?** + +A: No, the Append to Dataset Node can only append data to one dataset at a time. If you want to append data to multiple datasets, you can use multiple Append to Dataset Nodes. + +**Q: What happens if the dataset does not exist?** + +A: If the dataset does not exist, the Append to Dataset Node will error. + +## See Also + +- [Load Dataset Node](./load-dataset.mdx) +- [Create Dataset Node](./create-dataset.mdx) +- [Get All Datasets Node](./get-all-datasets.mdx) +- [KNN Dataset Node](./knn-dataset.mdx) +- [Get Dataset Row Node](./get-dataset-row.mdx) diff --git a/packages/docs/docs/node-reference/array.mdx b/packages/docs/docs/node-reference/array.mdx index 001572b4b..cd3a4aa1d 100644 --- a/packages/docs/docs/node-reference/array.mdx +++ b/packages/docs/docs/node-reference/array.mdx @@ -130,3 +130,9 @@ A: Yes, you can connect an Array Node to another Array Node. If the `Flatten` se A: If an input is missing or null, the Array Node will simply ignore it during the array creation process. This can be useful when dealing with optional inputs that may not always be present. ## See Also + +- [Code Node](./code.mdx) +- [Text Node](./text.mdx) +- [Number Node](./number.mdx) +- [Extract Object Path Node](./extract-object-path.mdx) +- [Pop Node](./pop.mdx) diff --git a/packages/docs/docs/node-reference/assets/abort-graph-node.png b/packages/docs/docs/node-reference/assets/abort-graph-node.png new file mode 100644 index 000000000..8c96b9c3f Binary files /dev/null and b/packages/docs/docs/node-reference/assets/abort-graph-node.png differ diff --git a/packages/docs/docs/node-reference/assets/append-to-dataset-node-example-01-2.png b/packages/docs/docs/node-reference/assets/append-to-dataset-node-example-01-2.png new file mode 100644 index 000000000..88c5f53bc Binary files /dev/null and b/packages/docs/docs/node-reference/assets/append-to-dataset-node-example-01-2.png differ diff --git a/packages/docs/docs/node-reference/assets/append-to-dataset-node-example-01.png b/packages/docs/docs/node-reference/assets/append-to-dataset-node-example-01.png new file mode 100644 index 000000000..557e3d2da Binary files /dev/null and b/packages/docs/docs/node-reference/assets/append-to-dataset-node-example-01.png differ diff --git a/packages/docs/docs/node-reference/assets/append-to-dataset-node.png b/packages/docs/docs/node-reference/assets/append-to-dataset-node.png new file mode 100644 index 000000000..c482b40fd Binary files /dev/null and b/packages/docs/docs/node-reference/assets/append-to-dataset-node.png differ diff --git a/packages/docs/docs/node-reference/assets/audio-node.png b/packages/docs/docs/node-reference/assets/audio-node.png new file mode 100644 index 000000000..c0b349f1c Binary files /dev/null and b/packages/docs/docs/node-reference/assets/audio-node.png differ diff --git a/packages/docs/docs/node-reference/assets/bool-node.png b/packages/docs/docs/node-reference/assets/bool-node.png new file mode 100644 index 000000000..54a74e0e8 Binary files /dev/null and b/packages/docs/docs/node-reference/assets/bool-node.png differ diff --git a/packages/docs/docs/node-reference/assets/comment-node.png b/packages/docs/docs/node-reference/assets/comment-node.png new file mode 100644 index 000000000..7292972e5 Binary files /dev/null and b/packages/docs/docs/node-reference/assets/comment-node.png differ diff --git a/packages/docs/docs/node-reference/assets/compare-node-example-01.png b/packages/docs/docs/node-reference/assets/compare-node-example-01.png new file mode 100644 index 000000000..513e2634f Binary files /dev/null and b/packages/docs/docs/node-reference/assets/compare-node-example-01.png differ diff --git a/packages/docs/docs/node-reference/assets/compare-node.png b/packages/docs/docs/node-reference/assets/compare-node.png new file mode 100644 index 000000000..a296a5000 Binary files /dev/null and b/packages/docs/docs/node-reference/assets/compare-node.png differ diff --git a/packages/docs/docs/node-reference/assets/create-dataset-node-example-01.png b/packages/docs/docs/node-reference/assets/create-dataset-node-example-01.png new file mode 100644 index 000000000..d28d8ccab Binary files /dev/null and b/packages/docs/docs/node-reference/assets/create-dataset-node-example-01.png differ diff --git a/packages/docs/docs/node-reference/assets/create-dataset-node.png b/packages/docs/docs/node-reference/assets/create-dataset-node.png new file mode 100644 index 000000000..b409a36e5 Binary files /dev/null and b/packages/docs/docs/node-reference/assets/create-dataset-node.png differ diff --git a/packages/docs/docs/node-reference/assets/delay-node-example-01.png b/packages/docs/docs/node-reference/assets/delay-node-example-01.png new file mode 100644 index 000000000..59f9d5948 Binary files /dev/null and b/packages/docs/docs/node-reference/assets/delay-node-example-01.png differ diff --git a/packages/docs/docs/node-reference/assets/delay-node.png b/packages/docs/docs/node-reference/assets/delay-node.png new file mode 100644 index 000000000..7f966fd7d Binary files /dev/null and b/packages/docs/docs/node-reference/assets/delay-node.png differ diff --git a/packages/docs/docs/node-reference/assets/evaluate-node-example-01.png b/packages/docs/docs/node-reference/assets/evaluate-node-example-01.png new file mode 100644 index 000000000..6cd2f5fba Binary files /dev/null and b/packages/docs/docs/node-reference/assets/evaluate-node-example-01.png differ diff --git a/packages/docs/docs/node-reference/assets/evaluate-node.png b/packages/docs/docs/node-reference/assets/evaluate-node.png new file mode 100644 index 000000000..39d83c7ff Binary files /dev/null and b/packages/docs/docs/node-reference/assets/evaluate-node.png differ diff --git a/packages/docs/docs/node-reference/audio.mdx b/packages/docs/docs/node-reference/audio.mdx new file mode 100644 index 000000000..906076f9d --- /dev/null +++ b/packages/docs/docs/node-reference/audio.mdx @@ -0,0 +1,90 @@ +--- +id: audio +title: Audio Node +sidebar_label: Audio +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +![Audio Node Screenshot](./assets/audio-node.png) + +## Overview + +The Audio Node is used to define an audio sample for use with other nodes. It can also convert a binary type into an audio type. + +The Audio Node can either take an input that represents the audio data or use an audio file specified in the node's settings. The audio data should be in a format that can be converted to a Uint8Array. + + + + + +## Inputs + +| Title | Data Type | Description | Default Value | Notes | +| ----- | --------- | --------------------------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------- | +| Data | `string` | The string representing the audio data. | N/A | This input is only available if the "Use Data Input" setting is enabled. The input will be coerced into a string. | + + + + + +## Outputs + +| Title | Data Type | Description | Notes | +| ---------- | --------- | ------------------------------------------------------------------------------------------------------- | ----- | +| Audio Data | `audio` | The audio data converted into a format that can be used by other nodes that accept audio data as input. | | + + + + + +## Editor Settings + +| Setting | Description | Default Value | Use Input Toggle | Input Data Type | +| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ---------------- | --------------- | +| Audio File | The audio file to be used as the audio data. This file should be in a format that can be converted to a Uint8Array. | N/A | Yes | `file` | +| Use Data Input | If enabled, the node will use the data from the "Data" input port as the audio data. If disabled, the node will use the data from the audio file specified in the "Audio File" setting. | False | No | N/A | + + + + + +## Example 1: Using an Audio Node with a File + +1. Add an Audio Node to your graph. +2. In the node's settings, click "Pick File" and select an audio file from your local file system. +3. Play the audio back using the player on the Audio node. You may also connect the Audio node to other nodes that accept Audio data, such as the [AssemblyAI Plugin](../user-guide/plugins/built-in/assemblyai.md) + +## Error Handling + +The Audio Node will throw an error if: + +- The "Use Data Input" setting is enabled but no data is provided to the "Data" input port. +- The "Use Data Input" setting is disabled but no audio file is specified in the "Audio File" setting. +- The provided audio data (either from the "Data" input or the specified audio file) cannot be converted to a Uint8Array. + +## FAQ + +**Q: What audio file formats are supported by the Audio Node?** + +A: The Audio Node does not process the audio data itself, so it does not have any specific audio file format requirements. However, the audio data should be in a format that can be converted to a Uint8Array. The specific audio file formats that can be used will depend on what other nodes you are connecting the Audio Node to. + +**Q: Can I use the Audio Node to play audio?** + +A: The Audio Node shows a playback bar on the Rivet UI, but otherwise, it cannot be used to play back audio during the graph's execution. + +## See Also + +- [Image Node](./image.mdx) +- [Text Node](./text.mdx) +- [Number Node](./number.mdx) +- [Boolean Node](./boolean.mdx) +- [External Call Node](./external-call.mdx) diff --git a/packages/docs/docs/node-reference/bool.mdx b/packages/docs/docs/node-reference/bool.mdx new file mode 100644 index 000000000..46c1a7036 --- /dev/null +++ b/packages/docs/docs/node-reference/bool.mdx @@ -0,0 +1,118 @@ +--- +id: bool +title: Bool Node +sidebar_label: Bool +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +![Bool Node Screenshot](./assets/bool-node.png) + +## Overview + +The Bool Node is used to output a boolean constant or convert an input value into a boolean. This node can be useful when you need to create a boolean value for use in other nodes, such as the [If Node](./if.mdx) or [If/Else Node](./if-else.mdx). + +The Bool Node can either output a constant boolean value that you set in the node's settings, or it can take an input and convert it into a boolean. The conversion follows JavaScript's rules for truthy and falsy values, with two exception: + +- Empty arrays are considered falsey +- The string "false" is considered falsey. + +If you need to treat empty arrays as truthy, or the string "false" as truthy, you can use the [Code Node](./code.mdx) + + + + + +## Inputs + +| Title | Data Type | Description | Default Value | Notes | +| ----- | --------- | ----------------------------------------------------------------------------------------------- | ------------- | ----- | +| Input | `any` | The value to be converted to a boolean. This input is only available if `Use Input` is enabled. | N/A | | + + + + + +## Outputs + +| Title | Data Type | Description | Notes | +| ----- | --------- | -------------------------------------------------------------------------------------------------- | ----- | +| Value | `boolean` | The boolean value. If `Use Input` is enabled, this will be the input value converted to a boolean. | | + + + + + +## Editor Settings + +| Setting | Description | Default Value | Use Input Toggle | Input Data Type | +| --------- | -------------------------------------------------------------------------------------------------------------------------- | ------------- | ---------------- | --------------- | +| Value | The constant boolean value to output. This setting is only available if `Use Input` is disabled. | `false` | Yes | `boolean` | +| Use Input | If enabled, the node will convert an input value to a boolean. If disabled, the node will output a constant boolean value. | `false` | No | N/A | + + + + + +## Example 1: Using a Constant Boolean Value + +1. Add a Bool Node to your graph. +2. Set the `Value` setting to `true`. +3. Run the graph. The `Value` output of the Bool Node will be `true`. + +## Example 2: Converting an Input to a Boolean + +1. Add a Bool Node to your graph. +2. Enable the `Use Input` setting. +3. Add a [Text Node](./text.mdx) to your graph and set the text to `"Hello"`. +4. Connect the output of the Text Node to the `Input` of the Bool Node. +5. Run the graph. The `Value` output of the Bool Node will be `true`, because the string `"Hello"` is a truthy value in JavaScript. + +## Error Handling + +The Bool Node cannot error under normal circumstances. If the `Use Input` setting is enabled and no input is connected, the node will output `false`. + +## FAQ + +**Q: What values are considered truthy and falsy in JavaScript?** + +A: The following values are considered falsy: + +- `false` +- `0` +- `''` (empty string) +- `null` +- `undefined` +- `NaN` +- **In Rivet, empty arrays are also considered falsy.** +- **In Rivet, the string "false" is also considered falsy.** + +All other values are considered truthy. + +**Q: Can I use the Bool Node to check if an array is empty?** + +A: Yes, if you connect an array to the `Input` of a Bool Node, the `Value` output will be `false` if the array is empty. If the array is not empty, the `Value` output will be `true`. + +**Q: Can I use the Bool Node to check if a string is empty?** + +A: Yes, you can connect a [Text Node](./text.mdx) to the `Input` of a Bool Node. If the string is empty, the `Value` output of the Bool Node will be `false`. If the string is not empty, the `Value` output will be `true`. + +**Q: Can I use the Bool Node to check if a number is zero?** + +A: Yes, you can connect a [Number Node](./number.mdx) to the `Input` of a Bool Node. If the number is zero, the `Value` output of the Bool Node will be `false`. If the number is not zero, the `Value` output will be `true`. + +## See Also + +- [If Node](./if.mdx) +- [Match Node](./match.mdx) +- [Text Node](./text.mdx) +- [Array Node](./array.mdx) +- [Number Node](./number.mdx) diff --git a/packages/docs/docs/node-reference/comment.mdx b/packages/docs/docs/node-reference/comment.mdx index a87149d80..1d0f47965 100644 --- a/packages/docs/docs/node-reference/comment.mdx +++ b/packages/docs/docs/node-reference/comment.mdx @@ -1,5 +1,65 @@ --- -title: 'Comment' +id: comment +title: Comment Node +sidebar_label: Comment --- -# Comment Node +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +![Comment Node Screenshot](./assets/comment-node.png) + +## Overview + +The Comment Node is a special type of node that doesn't perform any operations but serves as a way to add notes or comments to a graph. It can be used to provide additional context or explanation for a group of nodes, making the graph easier to understand. The Comment Node is always rendered behind other nodes and has a distinct appearance with customizable colors. + +A comment node is always rendered behind all other nodes in the graph. + + + + + +## Inputs + +The Comment Node does not have any inputs. + + + + + +## Outputs + +The Comment Node does not produce any outputs. + + + + + +## Editor Settings + +| Setting | Description | Default Value | +| ---------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------- | +| Color | The color of the text in the comment node. | `rgba(255,255,255,1)` | +| Background Color | The background color of the comment node. | `rgba(0,0,0,0.05)` | +| Text | The text content of the comment node. Supports Markdown syntax, allowing for rich text formatting including headings, lists, etc. | (Empty) | + + + + + +## Example Usage + +The Comment Node can be used to add notes or comments to a graph. For example, if you have a group of nodes performing a specific operation, you can add a Comment Node behind them to provide a brief explanation of what they do. + +Additionally, you can use different colors for the text and background of different Comment Nodes to visually distinguish between different sections of your graph. + +## See Also + +- [Markdown Guide](https://www.markdownguide.org/) diff --git a/packages/docs/docs/node-reference/compare.mdx b/packages/docs/docs/node-reference/compare.mdx index a35a4b75c..35be677a9 100644 --- a/packages/docs/docs/node-reference/compare.mdx +++ b/packages/docs/docs/node-reference/compare.mdx @@ -1,5 +1,86 @@ --- -title: 'Compare' +id: compare +title: Compare Node +sidebar_label: Compare --- -# Compare Node +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +## Overview + +The Compare Node allows you to perform a comparison operation between two input values. The node supports a variety of comparison functions including equality, inequality, less than, greater than, and logical operations such as AND, OR, XOR, NAND, NOR, and XNOR. + +![Compare Node Screenshot](./assets/compare-node.png) + + + + + +## Inputs + +| Title | Data Type | Description | Default Value | Notes | +| ----- | --------- | -------------------------------- | ------------- | ----- | +| A | `any` | The first value for comparison. | (Required) | None | +| B | `any` | The second value for comparison. | (Required) | None | + + + + + +## Outputs + +| Title | Data Type | Description | Notes | +| ------ | --------- | --------------------------------------- | ----- | +| Output | `boolean` | The result of the comparison operation. | | + + + + + +## Editor Settings + +| Setting | Description | Default Value | Use Input Toggle | Input Data Type | +| ------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------- | ---------------- | --------------- | +| Comparison Function | The comparison function to be used for the operation. Available options are '==', '<', '>', '<=', '>=', '!=', 'and', 'or', 'xor'. | '==' | Yes | `string` | + + + + + +## Example 1: Compare two numbers + +1. Create a Compare Node and set the `Comparison Function` to `>`. +2. Create two [Number Nodes](./number.mdx), one with the value `5` and the other with the value `3`. +3. Connect the Number Nodes to the `A` and `B` inputs of the Compare Node respectively. +4. Run the graph. Note that the output of the Compare Node is `true`, because 5 is greater than 3. + +![Compare Node Example 1](./assets/compare-node-example-01.png) + +## Error Handling + +The Compare Node does not have any specific error handling. If the inputs are not of the same type, the node will attempt to coerce the second input (`B`) to the type of the first input (`A`). + +## FAQ + +**Q: What happens if the inputs are not of the same type?** + +A: If the inputs are not of the same type, the node will attempt to coerce the second input (`B`) to the type of the first input (`A`). If the coercion is not possible, the comparison will be performed with the original values. + +**Q: Can I use the Compare Node to compare arrays or objects?** + +A: Yes, you can use the Compare Node to compare arrays or objects. However, the comparison will be performed using JavaScript's strict equality (`===`), which may not give the expected results for arrays or objects. For a deep comparison of arrays or objects, consider using a [Code Node](./code.mdx). + +## See Also + +- [If Node](./if.mdx) +- [Switch Node](./switch.mdx) +- [Match Node](./match.mdx) +- [Code Node](./code.mdx) diff --git a/packages/docs/docs/node-reference/create-dataset.mdx b/packages/docs/docs/node-reference/create-dataset.mdx index e3fd02c93..f1fc23eb8 100644 --- a/packages/docs/docs/node-reference/create-dataset.mdx +++ b/packages/docs/docs/node-reference/create-dataset.mdx @@ -1,5 +1,97 @@ --- -title: 'Create Dataset' +id: create-dataset +title: Create Dataset Node +sidebar_label: Create Dataset --- -# Create Dataset Node +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +![Create Dataset Node Screenshot](./assets/create-dataset-node.png) + +## Overview + +The Create Dataset Node is used to create a new dataset with a specified ID and name. If a dataset with the specified ID already exists, the node does nothing. This node is particularly useful when you want to create a new dataset for storing or processing data. + +Multiple datasets can have the same name, but IDs are unique across all datasets. The ID is used to identify the dataset when loading, appending, or deleting data. If the `Dataset ID` input is not provided, the node will automatically generate an ID for the dataset. + +If the `Dataset Name` input is not provided, the node will use the `Dataset ID` as the name. + +The node requires a dataset provider to be available in the context when the graph is being run. The dataset provider is responsible for managing the storage and retrieval of datasets. In the Rivet application, the dataset provider is handled for you automatically. + +For more information on datasets, see the [Data Studio](../user-guide/features/data-studio.md) section of the user guide. + + + + + +## Inputs + +| Title | Data Type | Description | Default Value | Notes | +| ------------ | --------- | ------------------------------------------------------------------------------------------------ | ------------------------- | -------------------------------------------------------------- | +| Dataset ID | `string` | The ID of the dataset to be created. | (automatically generated) | The input will be coerced into a string if it is not a string. | +| Dataset Name | `string` | The name of the dataset to be created. If not provided, the Dataset ID will be used as the name. | (dataset ID) | The input will be coerced into a string if it is not a string. | + + + + + +## Outputs + +| Title | Data Type | Description | Notes | +| ---------- | --------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | +| Dataset ID | `string` | The ID of the dataset that was created. | The output will be the same as the Dataset ID input, or the automatically-generated ID if the input was not connected. | + + + + + +## Editor Settings + +This node has no configurable editor settings. + + + + + +## Example 1: Create a new dataset + +1. Create a [Text Node](./text.mdx) and set the text to `employees`. +2. Create another Text Node and set the text to `Employees`. +3. Create a Create Dataset Node and connect the first Text Node to the `Dataset ID` input, and the second Text Node to the `Dataset Name` input. +4. Run the graph. The `Dataset ID` output of the Create Dataset Node should contain the ID of the new dataset that was created. + +![Create Dataset Node Example 1](./assets/create-dataset-node-example-01.png) + +## Error Handling + +The Create Dataset Node will error if the dataset provider is not available in the context when the graph is being run. It will also error if the `Dataset ID` input is not provided. + +## FAQ + +**Q: What is a dataset provider?** + +A: A dataset provider is an object that is responsible for managing the storage and retrieval of datasets. It is passed to the context when the graph is being run. The dataset provider must implement the `DatasetProvider` interface, which includes methods for getting, putting, and deleting datasets. See the [API Reference](../api-reference.md) for more information. + +**Q: Can I create multiple datasets at once?** + +A: No, the Create Dataset Node can only create one dataset at a time. If you want to create multiple datasets, you can use multiple Create Dataset Nodes. + +**Q: What happens if the dataset already exists?** + +A: If the dataset already exists, the Create Dataset Node will do nothing and the graph will continue to run. The dataset's ID will be outputted from the node. This is useful for ensuring that a dataset exists before loading or appending data to it. + +## See Also + +- [Append to Dataset Node](./append-to-dataset.mdx) +- [Load Dataset Node](./load-dataset.mdx) +- [Get All Datasets Node](./get-all-datasets.mdx) +- [KNN Dataset Node](./knn-dataset.mdx) +- [Get Dataset Row Node](./get-dataset-row.mdx) diff --git a/packages/docs/docs/node-reference/delay.mdx b/packages/docs/docs/node-reference/delay.mdx index 9125001fd..5e8d6b4c5 100644 --- a/packages/docs/docs/node-reference/delay.mdx +++ b/packages/docs/docs/node-reference/delay.mdx @@ -1,5 +1,85 @@ --- -title: 'Delay' +id: delay +title: Delay Node +sidebar_label: Delay --- -# Delay Node +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +![Delay Node Screenshot](./assets/delay-node.png) + +## Overview + +The Delay Node is used to introduce a delay in the execution of the graph. It takes any number of inputs and after a specified delay, passes the input values to the outputs without any modifications. This node is useful when you need to control the timing of your graph's execution. + + + + + +## Inputs + +| Title | Data Type | Description | Default Value | Notes | +| --------- | --------- | -------------------------------------------- | ------------- | ------------------------------------------------------------------------- | +| Delay | `number` | The delay time in milliseconds. | 0 | This input is only available if the "Use Delay Input" setting is enabled. | +| Input [i] | `any` | The ith input that will be passed to output. | N/A | Dynamic number of inputs based on how many connections there are. | + + + + + +## Outputs + +| Title | Data Type | Description | Notes | +| --------- | --------- | ---------------------------------------------------- | --------------------------------------------------------------------------------- | +| Output[i] | `any` | The ith output from the execution of the delay node. | The output will be the same as the corresponding input after the specified delay. | + + + + + +## Editor Settings + +| Setting | Description | Default Value | Use Input Toggle | Input Data Type | +| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- | ---------------- | --------------- | +| Function Name | The delay time in milliseconds. If the "Use Delay Input" setting is not enabled, this value will be used as the delay. | 0 | Yes | `number` | +| Use Error Output | If enabled, then the Delay node will use the "Delay" input as the delay time in milliseconds. If disabled, the delay time specified in the "Delay" setting will be used. | False | No | N/A | + + + + + +## Example 1: Delaying a Message + +1. Create a Text node and set its value to "Hello, World!". +2. Create a Delay node and set its "Delay" setting to 5000 (5 seconds). +3. Connect the output of the Text node to the first input of the Delay node. +4. Run the graph. Note that the output of the Delay node is not displayed until after 5 seconds. + +![Delay Node Example 1](./assets/delay-node-example-01.png) + +## Error Handling + +The Delay node cannot error under normal circumstances. If the delay time is negative, it will be treated as zero. + +## FAQ + +**Q: What happens if I set the delay time to zero?** + +A: The Delay node will pass the input to the output immediately, effectively acting as a pass-through node. + +**Q: Can I use the Delay node to throttle API calls?** + +A: Yes, you can use the Delay node to throttle API calls. For example, if you have a graph that makes an API call every time it is run, you can use the Delay node to ensure that the API call is not made more than once every 5 seconds. + +## See Also + +- [Passthrough Node](./passthrough.mdx) +- [Race Inputs Node](./race-inputs.mdx) diff --git a/packages/docs/docs/node-reference/evaluate.mdx b/packages/docs/docs/node-reference/evaluate.mdx index af3831a77..05a06a69f 100644 --- a/packages/docs/docs/node-reference/evaluate.mdx +++ b/packages/docs/docs/node-reference/evaluate.mdx @@ -1,5 +1,81 @@ --- -title: 'Evaluate' +id: evaluate +title: Evaluate Node +sidebar_label: Evaluate --- -# Evaluate Node +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +![Evaluate Node Screenshot](./assets/evaluate-node.png) + +## Overview + +The Evaluate Node performs a mathematical operation on the input values and outputs the result. It supports a variety of operations including addition, subtraction, multiplication, division, exponentiation, modulus, absolute value, and negation. + + + + + +## Inputs + +| Title | Data Type | Description | Default Value | Notes | +| ----- | --------- | ------------------------------------- | ------------------------------- | -------------------------------------------------------------- | +| A | `number` | The first operand for the operation. | (Required) | The input will be coerced into a number if it is not a number. | +| B | `number` | The second operand for the operation. | (Required for binary operators) | The input will be coerced into a number if it is not a number. | + + + + + +## Outputs + +| Title | Data Type | Description | Notes | +| ------ | --------- | ---------------------------- | ----- | +| Output | `number` | The result of the operation. | | + + + + + +## Editor Settings + +| Setting | Description | Default Value | Use Input Toggle | Input Data Type | +| --------- | ---------------------------------------------------------------------------------------------------------------- | ------------- | ---------------- | --------------- | +| Operation | The operation to perform on the input values. Options include `+`, `-`, `*`, `/`, `^`, `%`, `abs`, and `negate`. | `+` | Yes | `string` | + + + + + +## Example 1: Performing a simple addition + +1. Create an Evaluate Node and set the `Operation` to `+`. +2. Create two Number nodes, set their values to `2` and `3` respectively. +3. Connect the Number nodes to the `A` and `B` inputs of the Evaluate Node. +4. Run the graph. The output of the Evaluate Node should be `5`. + +![Evaluate Node Example 1](./assets/evaluate-node-example-01.png) + +## Error Handling + +If the operation fails (for example, if you try to divide by zero), the Evaluate node will error. + +## FAQ + +**Q: What if I want to perform a different operation based on the input?** + +A: You can use the `Operation` input port to dynamically change the operation based on the input. The input will be coerced into a string and must match one of the supported operations. + +## See Also + +- [Number Node](./number.mdx) +- [Code Node](./code.mdx) +- [Compare Node](./compare.mdx) diff --git a/packages/docs/docs/node-reference/image.mdx b/packages/docs/docs/node-reference/image.mdx new file mode 100644 index 000000000..89a20ccc1 --- /dev/null +++ b/packages/docs/docs/node-reference/image.mdx @@ -0,0 +1,5 @@ +--- +title: 'Image' +--- + +# Image Node diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js index 2ace237e2..16a588bab 100644 --- a/packages/docs/sidebars.js +++ b/packages/docs/sidebars.js @@ -221,6 +221,13 @@ const sidebars = { 'node-reference/object', ], }, + { + type: 'category', + label: 'Data', + collapsible: true, + collapsed: false, + items: ['node-reference/audio', 'node-reference/bool', 'node-reference/hash', 'node-reference/image'], + }, { type: 'category', label: 'Logic',