@alpic80/rivet-core 1.19.1-aidon.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +176 -0
- package/dist/cjs/bundle.cjs +18915 -0
- package/dist/cjs/bundle.cjs.map +7 -0
- package/dist/esm/api/createProcessor.js +131 -0
- package/dist/esm/api/streaming.js +116 -0
- package/dist/esm/exports.js +32 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/integrations/AudioProvider.js +1 -0
- package/dist/esm/integrations/DatasetProvider.js +92 -0
- package/dist/esm/integrations/EmbeddingGenerator.js +1 -0
- package/dist/esm/integrations/GptTokenizerTokenizer.js +65 -0
- package/dist/esm/integrations/LLMProvider.js +1 -0
- package/dist/esm/integrations/Tokenizer.js +1 -0
- package/dist/esm/integrations/VectorDatabase.js +1 -0
- package/dist/esm/integrations/enableIntegrations.js +3 -0
- package/dist/esm/integrations/integrations.js +19 -0
- package/dist/esm/integrations/openai/OpenAIEmbeddingGenerator.js +23 -0
- package/dist/esm/model/DataValue.js +176 -0
- package/dist/esm/model/Dataset.js +1 -0
- package/dist/esm/model/EditorDefinition.js +1 -0
- package/dist/esm/model/GraphProcessor.js +1198 -0
- package/dist/esm/model/NodeBase.js +1 -0
- package/dist/esm/model/NodeBodySpec.js +1 -0
- package/dist/esm/model/NodeDefinition.js +12 -0
- package/dist/esm/model/NodeGraph.js +14 -0
- package/dist/esm/model/NodeImpl.js +49 -0
- package/dist/esm/model/NodeRegistration.js +144 -0
- package/dist/esm/model/Nodes.js +227 -0
- package/dist/esm/model/PluginLoadSpec.js +1 -0
- package/dist/esm/model/ProcessContext.js +1 -0
- package/dist/esm/model/Project.js +2 -0
- package/dist/esm/model/RivetPlugin.js +1 -0
- package/dist/esm/model/RivetUIContext.js +1 -0
- package/dist/esm/model/Settings.js +1 -0
- package/dist/esm/model/nodes/AbortGraphNode.js +100 -0
- package/dist/esm/model/nodes/AppendToDatasetNode.js +115 -0
- package/dist/esm/model/nodes/ArrayNode.js +144 -0
- package/dist/esm/model/nodes/AssembleMessageNode.js +199 -0
- package/dist/esm/model/nodes/AssemblePromptNode.js +129 -0
- package/dist/esm/model/nodes/AudioNode.js +101 -0
- package/dist/esm/model/nodes/BooleanNode.js +74 -0
- package/dist/esm/model/nodes/CallGraphNode.js +136 -0
- package/dist/esm/model/nodes/ChatNode.js +964 -0
- package/dist/esm/model/nodes/ChunkNode.js +166 -0
- package/dist/esm/model/nodes/CoalesceNode.js +104 -0
- package/dist/esm/model/nodes/CodeNode.js +136 -0
- package/dist/esm/model/nodes/CommentNode.js +69 -0
- package/dist/esm/model/nodes/CompareNode.js +138 -0
- package/dist/esm/model/nodes/ContextNode.js +99 -0
- package/dist/esm/model/nodes/CreateDatasetNode.js +71 -0
- package/dist/esm/model/nodes/DatasetNearestNeigborsNode.js +97 -0
- package/dist/esm/model/nodes/DelayNode.js +105 -0
- package/dist/esm/model/nodes/DelegateFunctionCallNode.js +136 -0
- package/dist/esm/model/nodes/DestructureNode.js +86 -0
- package/dist/esm/model/nodes/EvaluateNode.js +141 -0
- package/dist/esm/model/nodes/ExternalCallNode.js +162 -0
- package/dist/esm/model/nodes/ExtractJsonNode.js +122 -0
- package/dist/esm/model/nodes/ExtractMarkdownCodeBlocksNode.js +100 -0
- package/dist/esm/model/nodes/ExtractObjectPathNode.js +128 -0
- package/dist/esm/model/nodes/ExtractRegexNode.js +201 -0
- package/dist/esm/model/nodes/ExtractYamlNode.js +214 -0
- package/dist/esm/model/nodes/FilterNode.js +73 -0
- package/dist/esm/model/nodes/GetAllDatasetsNode.js +53 -0
- package/dist/esm/model/nodes/GetDatasetRowNode.js +99 -0
- package/dist/esm/model/nodes/GetEmbeddingNode.js +130 -0
- package/dist/esm/model/nodes/GetGlobalNode.js +139 -0
- package/dist/esm/model/nodes/GptFunctionNode.js +169 -0
- package/dist/esm/model/nodes/GraphInputNode.js +130 -0
- package/dist/esm/model/nodes/GraphOutputNode.js +104 -0
- package/dist/esm/model/nodes/GraphReferenceNode.js +128 -0
- package/dist/esm/model/nodes/HashNode.js +97 -0
- package/dist/esm/model/nodes/HttpCallNode.js +257 -0
- package/dist/esm/model/nodes/IfElseNode.js +138 -0
- package/dist/esm/model/nodes/IfNode.js +124 -0
- package/dist/esm/model/nodes/ImageNode.js +107 -0
- package/dist/esm/model/nodes/JoinNode.js +135 -0
- package/dist/esm/model/nodes/ListGraphsNode.js +61 -0
- package/dist/esm/model/nodes/LoadDatasetNode.js +83 -0
- package/dist/esm/model/nodes/LoopControllerNode.js +206 -0
- package/dist/esm/model/nodes/MatchNode.js +137 -0
- package/dist/esm/model/nodes/NumberNode.js +86 -0
- package/dist/esm/model/nodes/ObjectNode.js +121 -0
- package/dist/esm/model/nodes/PassthroughNode.js +78 -0
- package/dist/esm/model/nodes/PlayAudioNode.js +61 -0
- package/dist/esm/model/nodes/PopNode.js +89 -0
- package/dist/esm/model/nodes/PromptNode.js +227 -0
- package/dist/esm/model/nodes/RaceInputsNode.js +86 -0
- package/dist/esm/model/nodes/RaiseEventNode.js +84 -0
- package/dist/esm/model/nodes/RandomNumberNode.js +106 -0
- package/dist/esm/model/nodes/ReadDirectoryNode.js +165 -0
- package/dist/esm/model/nodes/ReadFileNode.js +114 -0
- package/dist/esm/model/nodes/ReplaceDatasetNode.js +118 -0
- package/dist/esm/model/nodes/SetGlobalNode.js +124 -0
- package/dist/esm/model/nodes/ShuffleNode.js +64 -0
- package/dist/esm/model/nodes/SliceNode.js +100 -0
- package/dist/esm/model/nodes/SplitNode.js +101 -0
- package/dist/esm/model/nodes/SubGraphNode.js +181 -0
- package/dist/esm/model/nodes/TextNode.js +97 -0
- package/dist/esm/model/nodes/ToJsonNode.js +78 -0
- package/dist/esm/model/nodes/ToYamlNode.js +68 -0
- package/dist/esm/model/nodes/TrimChatMessagesNode.js +120 -0
- package/dist/esm/model/nodes/URLReferenceNode.js +79 -0
- package/dist/esm/model/nodes/UserInputNode.js +111 -0
- package/dist/esm/model/nodes/VectorNearestNeighborsNode.js +127 -0
- package/dist/esm/model/nodes/VectorStoreNode.js +124 -0
- package/dist/esm/model/nodes/WaitForEventNode.js +88 -0
- package/dist/esm/native/BaseDir.js +32 -0
- package/dist/esm/native/BrowserNativeApi.js +19 -0
- package/dist/esm/native/NativeApi.js +1 -0
- package/dist/esm/plugins/aidon/index.js +2 -0
- package/dist/esm/plugins/aidon/nodes/ChatAidonNode.js +215 -0
- package/dist/esm/plugins/aidon/plugin.js +9 -0
- package/dist/esm/plugins/anthropic/anthropic.js +187 -0
- package/dist/esm/plugins/anthropic/fetchEventSource.js +106 -0
- package/dist/esm/plugins/anthropic/index.js +2 -0
- package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +652 -0
- package/dist/esm/plugins/anthropic/plugin.js +18 -0
- package/dist/esm/plugins/assemblyAi/LemurActionItemsNode.js +75 -0
- package/dist/esm/plugins/assemblyAi/LemurQaNode.js +155 -0
- package/dist/esm/plugins/assemblyAi/LemurSummaryNode.js +79 -0
- package/dist/esm/plugins/assemblyAi/LemurTaskNode.js +82 -0
- package/dist/esm/plugins/assemblyAi/TranscribeAudioNode.js +125 -0
- package/dist/esm/plugins/assemblyAi/index.js +2 -0
- package/dist/esm/plugins/assemblyAi/lemurHelpers.js +114 -0
- package/dist/esm/plugins/assemblyAi/plugin.js +32 -0
- package/dist/esm/plugins/autoevals/AutoEvalsNode.js +223 -0
- package/dist/esm/plugins/autoevals/index.js +2 -0
- package/dist/esm/plugins/autoevals/plugin.js +8 -0
- package/dist/esm/plugins/gentrace/index.js +2 -0
- package/dist/esm/plugins/gentrace/plugin.js +192 -0
- package/dist/esm/plugins/google/google.js +60 -0
- package/dist/esm/plugins/google/index.js +2 -0
- package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +364 -0
- package/dist/esm/plugins/google/plugin.js +32 -0
- package/dist/esm/plugins/huggingface/index.js +2 -0
- package/dist/esm/plugins/huggingface/nodes/ChatHuggingFace.js +243 -0
- package/dist/esm/plugins/huggingface/nodes/TextToImageHuggingFace.js +189 -0
- package/dist/esm/plugins/huggingface/plugin.js +26 -0
- package/dist/esm/plugins/openai/handleOpenaiError.js +17 -0
- package/dist/esm/plugins/openai/index.js +2 -0
- package/dist/esm/plugins/openai/nodes/AttachAssistantFileNode.js +123 -0
- package/dist/esm/plugins/openai/nodes/CreateAssistantNode.js +289 -0
- package/dist/esm/plugins/openai/nodes/CreateThreadMessageNode.js +176 -0
- package/dist/esm/plugins/openai/nodes/CreateThreadNode.js +157 -0
- package/dist/esm/plugins/openai/nodes/DeleteAssistantNode.js +104 -0
- package/dist/esm/plugins/openai/nodes/DeleteThreadNode.js +97 -0
- package/dist/esm/plugins/openai/nodes/GetAssistantNode.js +118 -0
- package/dist/esm/plugins/openai/nodes/GetOpenAIFileNode.js +100 -0
- package/dist/esm/plugins/openai/nodes/GetThreadNode.js +108 -0
- package/dist/esm/plugins/openai/nodes/ListAssistantsNode.js +202 -0
- package/dist/esm/plugins/openai/nodes/ListOpenAIFilesNode.js +94 -0
- package/dist/esm/plugins/openai/nodes/ListThreadMessagesNode.js +224 -0
- package/dist/esm/plugins/openai/nodes/RunThreadNode.js +630 -0
- package/dist/esm/plugins/openai/nodes/ThreadMessageNode.js +145 -0
- package/dist/esm/plugins/openai/nodes/UploadFileNode.js +121 -0
- package/dist/esm/plugins/openai/plugin.js +44 -0
- package/dist/esm/plugins/pinecone/PineconeVectorDatabase.js +88 -0
- package/dist/esm/plugins/pinecone/index.js +2 -0
- package/dist/esm/plugins/pinecone/plugin.js +19 -0
- package/dist/esm/plugins.js +21 -0
- package/dist/esm/recording/ExecutionRecorder.js +177 -0
- package/dist/esm/recording/RecordedEvents.js +1 -0
- package/dist/esm/utils/assertNever.js +3 -0
- package/dist/esm/utils/base64.js +25 -0
- package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +60 -0
- package/dist/esm/utils/coerceType.js +322 -0
- package/dist/esm/utils/compatibility.js +27 -0
- package/dist/esm/utils/copyToClipboard.js +10 -0
- package/dist/esm/utils/defaults.js +2 -0
- package/dist/esm/utils/errors.js +7 -0
- package/dist/esm/utils/expectType.js +34 -0
- package/dist/esm/utils/fetchEventSource.js +120 -0
- package/dist/esm/utils/genericUtilFunctions.js +25 -0
- package/dist/esm/utils/getPluginConfig.js +23 -0
- package/dist/esm/utils/handleEscapeCharacters.js +11 -0
- package/dist/esm/utils/index.js +14 -0
- package/dist/esm/utils/inputs.js +16 -0
- package/dist/esm/utils/interpolation.js +6 -0
- package/dist/esm/utils/misc.js +1 -0
- package/dist/esm/utils/newId.js +4 -0
- package/dist/esm/utils/openai.js +219 -0
- package/dist/esm/utils/outputs.js +14 -0
- package/dist/esm/utils/serialization/serialization.js +86 -0
- package/dist/esm/utils/serialization/serializationUtils.js +13 -0
- package/dist/esm/utils/serialization/serialization_v1.js +19 -0
- package/dist/esm/utils/serialization/serialization_v2.js +24 -0
- package/dist/esm/utils/serialization/serialization_v3.js +145 -0
- package/dist/esm/utils/serialization/serialization_v4.js +200 -0
- package/dist/esm/utils/symbols.js +2 -0
- package/dist/esm/utils/time.js +14 -0
- package/dist/esm/utils/typeSafety.js +42 -0
- package/dist/types/api/createProcessor.d.ts +37 -0
- package/dist/types/api/streaming.d.ts +56 -0
- package/dist/types/exports.d.ts +33 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/integrations/AudioProvider.d.ts +4 -0
- package/dist/types/integrations/DatasetProvider.d.ts +33 -0
- package/dist/types/integrations/EmbeddingGenerator.d.ts +3 -0
- package/dist/types/integrations/GptTokenizerTokenizer.d.ts +20 -0
- package/dist/types/integrations/LLMProvider.d.ts +7 -0
- package/dist/types/integrations/Tokenizer.d.ts +11 -0
- package/dist/types/integrations/VectorDatabase.d.ts +7 -0
- package/dist/types/integrations/enableIntegrations.d.ts +1 -0
- package/dist/types/integrations/integrations.d.ts +12 -0
- package/dist/types/integrations/openai/OpenAIEmbeddingGenerator.d.ts +10 -0
- package/dist/types/model/DataValue.d.ts +138 -0
- package/dist/types/model/Dataset.d.ts +19 -0
- package/dist/types/model/EditorDefinition.d.ts +142 -0
- package/dist/types/model/GraphProcessor.d.ts +192 -0
- package/dist/types/model/NodeBase.d.ts +110 -0
- package/dist/types/model/NodeBodySpec.d.ts +19 -0
- package/dist/types/model/NodeDefinition.d.ts +13 -0
- package/dist/types/model/NodeGraph.d.ts +15 -0
- package/dist/types/model/NodeImpl.d.ts +55 -0
- package/dist/types/model/NodeRegistration.d.ts +24 -0
- package/dist/types/model/Nodes.d.ts +84 -0
- package/dist/types/model/PluginLoadSpec.d.ts +17 -0
- package/dist/types/model/ProcessContext.d.ts +69 -0
- package/dist/types/model/Project.d.ts +17 -0
- package/dist/types/model/RivetPlugin.d.ts +45 -0
- package/dist/types/model/RivetUIContext.d.ts +18 -0
- package/dist/types/model/Settings.d.ts +15 -0
- package/dist/types/model/nodes/AbortGraphNode.d.ts +22 -0
- package/dist/types/model/nodes/AppendToDatasetNode.d.ts +21 -0
- package/dist/types/model/nodes/ArrayNode.d.ts +20 -0
- package/dist/types/model/nodes/AssembleMessageNode.d.ts +23 -0
- package/dist/types/model/nodes/AssemblePromptNode.d.ts +20 -0
- package/dist/types/model/nodes/AudioNode.d.ts +20 -0
- package/dist/types/model/nodes/BooleanNode.d.ts +19 -0
- package/dist/types/model/nodes/CallGraphNode.d.ts +16 -0
- package/dist/types/model/nodes/ChatNode.d.ts +77 -0
- package/dist/types/model/nodes/ChunkNode.d.ts +22 -0
- package/dist/types/model/nodes/CoalesceNode.d.ts +14 -0
- package/dist/types/model/nodes/CodeNode.d.ts +21 -0
- package/dist/types/model/nodes/CommentNode.d.ts +20 -0
- package/dist/types/model/nodes/CompareNode.d.ts +19 -0
- package/dist/types/model/nodes/ContextNode.d.ts +24 -0
- package/dist/types/model/nodes/CreateDatasetNode.d.ts +13 -0
- package/dist/types/model/nodes/DatasetNearestNeigborsNode.d.ts +19 -0
- package/dist/types/model/nodes/DelayNode.d.ts +20 -0
- package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +25 -0
- package/dist/types/model/nodes/DestructureNode.d.ts +18 -0
- package/dist/types/model/nodes/EvaluateNode.d.ts +19 -0
- package/dist/types/model/nodes/ExternalCallNode.d.ts +22 -0
- package/dist/types/model/nodes/ExtractJsonNode.d.ts +13 -0
- package/dist/types/model/nodes/ExtractMarkdownCodeBlocksNode.d.ts +12 -0
- package/dist/types/model/nodes/ExtractObjectPathNode.d.ts +19 -0
- package/dist/types/model/nodes/ExtractRegexNode.d.ts +22 -0
- package/dist/types/model/nodes/ExtractYamlNode.d.ts +21 -0
- package/dist/types/model/nodes/FilterNode.d.ts +13 -0
- package/dist/types/model/nodes/GetAllDatasetsNode.d.ts +14 -0
- package/dist/types/model/nodes/GetDatasetRowNode.d.ts +19 -0
- package/dist/types/model/nodes/GetEmbeddingNode.d.ts +24 -0
- package/dist/types/model/nodes/GetGlobalNode.d.ts +29 -0
- package/dist/types/model/nodes/GptFunctionNode.d.ts +25 -0
- package/dist/types/model/nodes/GraphInputNode.d.ts +24 -0
- package/dist/types/model/nodes/GraphOutputNode.d.ts +22 -0
- package/dist/types/model/nodes/GraphReferenceNode.d.ts +22 -0
- package/dist/types/model/nodes/HashNode.d.ts +17 -0
- package/dist/types/model/nodes/HttpCallNode.d.ts +27 -0
- package/dist/types/model/nodes/IfElseNode.d.ts +18 -0
- package/dist/types/model/nodes/IfNode.d.ts +17 -0
- package/dist/types/model/nodes/ImageNode.d.ts +20 -0
- package/dist/types/model/nodes/JoinNode.d.ts +21 -0
- package/dist/types/model/nodes/ListGraphsNode.d.ts +14 -0
- package/dist/types/model/nodes/LoadDatasetNode.d.ts +17 -0
- package/dist/types/model/nodes/LoopControllerNode.d.ts +20 -0
- package/dist/types/model/nodes/MatchNode.d.ts +19 -0
- package/dist/types/model/nodes/NumberNode.d.ts +21 -0
- package/dist/types/model/nodes/ObjectNode.d.ts +18 -0
- package/dist/types/model/nodes/PassthroughNode.d.ts +14 -0
- package/dist/types/model/nodes/PlayAudioNode.d.ts +15 -0
- package/dist/types/model/nodes/PopNode.d.ts +19 -0
- package/dist/types/model/nodes/PromptNode.d.ts +23 -0
- package/dist/types/model/nodes/RaceInputsNode.d.ts +17 -0
- package/dist/types/model/nodes/RaiseEventNode.d.ts +22 -0
- package/dist/types/model/nodes/RandomNumberNode.d.ts +23 -0
- package/dist/types/model/nodes/ReadDirectoryNode.d.ts +30 -0
- package/dist/types/model/nodes/ReadFileNode.d.ts +23 -0
- package/dist/types/model/nodes/ReplaceDatasetNode.d.ts +21 -0
- package/dist/types/model/nodes/SetGlobalNode.d.ts +23 -0
- package/dist/types/model/nodes/ShuffleNode.d.ts +12 -0
- package/dist/types/model/nodes/SliceNode.d.ts +22 -0
- package/dist/types/model/nodes/SplitNode.d.ts +19 -0
- package/dist/types/model/nodes/SubGraphNode.d.ts +29 -0
- package/dist/types/model/nodes/TextNode.d.ts +18 -0
- package/dist/types/model/nodes/ToJsonNode.d.ts +18 -0
- package/dist/types/model/nodes/ToYamlNode.d.ts +13 -0
- package/dist/types/model/nodes/TrimChatMessagesNode.d.ts +20 -0
- package/dist/types/model/nodes/URLReferenceNode.d.ts +19 -0
- package/dist/types/model/nodes/UserInputNode.d.ts +21 -0
- package/dist/types/model/nodes/VectorNearestNeighborsNode.d.ts +24 -0
- package/dist/types/model/nodes/VectorStoreNode.d.ts +22 -0
- package/dist/types/model/nodes/WaitForEventNode.d.ts +21 -0
- package/dist/types/native/BaseDir.d.ts +29 -0
- package/dist/types/native/BrowserNativeApi.d.ts +11 -0
- package/dist/types/native/NativeApi.d.ts +17 -0
- package/dist/types/plugins/aidon/index.d.ts +2 -0
- package/dist/types/plugins/aidon/nodes/ChatAidonNode.d.ts +3 -0
- package/dist/types/plugins/aidon/plugin.d.ts +2 -0
- package/dist/types/plugins/anthropic/anthropic.d.ts +216 -0
- package/dist/types/plugins/anthropic/fetchEventSource.d.ts +11 -0
- package/dist/types/plugins/anthropic/index.d.ts +2 -0
- package/dist/types/plugins/anthropic/nodes/ChatAnthropicNode.d.ts +30 -0
- package/dist/types/plugins/anthropic/plugin.d.ts +2 -0
- package/dist/types/plugins/assemblyAi/LemurActionItemsNode.d.ts +6 -0
- package/dist/types/plugins/assemblyAi/LemurQaNode.d.ts +22 -0
- package/dist/types/plugins/assemblyAi/LemurSummaryNode.d.ts +8 -0
- package/dist/types/plugins/assemblyAi/LemurTaskNode.d.ts +8 -0
- package/dist/types/plugins/assemblyAi/TranscribeAudioNode.d.ts +7 -0
- package/dist/types/plugins/assemblyAi/index.d.ts +2 -0
- package/dist/types/plugins/assemblyAi/lemurHelpers.d.ts +67 -0
- package/dist/types/plugins/assemblyAi/plugin.d.ts +2 -0
- package/dist/types/plugins/autoevals/AutoEvalsNode.d.ts +8 -0
- package/dist/types/plugins/autoevals/index.d.ts +2 -0
- package/dist/types/plugins/autoevals/plugin.d.ts +2 -0
- package/dist/types/plugins/gentrace/index.d.ts +2 -0
- package/dist/types/plugins/gentrace/plugin.d.ts +5 -0
- package/dist/types/plugins/google/google.d.ts +60 -0
- package/dist/types/plugins/google/index.d.ts +2 -0
- package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +27 -0
- package/dist/types/plugins/google/plugin.d.ts +2 -0
- package/dist/types/plugins/huggingface/index.d.ts +2 -0
- package/dist/types/plugins/huggingface/nodes/ChatHuggingFace.d.ts +24 -0
- package/dist/types/plugins/huggingface/nodes/TextToImageHuggingFace.d.ts +20 -0
- package/dist/types/plugins/huggingface/plugin.d.ts +2 -0
- package/dist/types/plugins/openai/handleOpenaiError.d.ts +1 -0
- package/dist/types/plugins/openai/index.d.ts +2 -0
- package/dist/types/plugins/openai/nodes/AttachAssistantFileNode.d.ts +10 -0
- package/dist/types/plugins/openai/nodes/CreateAssistantNode.d.ts +26 -0
- package/dist/types/plugins/openai/nodes/CreateThreadMessageNode.d.ts +15 -0
- package/dist/types/plugins/openai/nodes/CreateThreadNode.d.ts +13 -0
- package/dist/types/plugins/openai/nodes/DeleteAssistantNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/DeleteThreadNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/GetAssistantNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/GetOpenAIFileNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/GetThreadNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/ListAssistantsNode.d.ts +14 -0
- package/dist/types/plugins/openai/nodes/ListOpenAIFilesNode.d.ts +8 -0
- package/dist/types/plugins/openai/nodes/ListThreadMessagesNode.d.ts +16 -0
- package/dist/types/plugins/openai/nodes/RunThreadNode.d.ts +28 -0
- package/dist/types/plugins/openai/nodes/ThreadMessageNode.d.ts +14 -0
- package/dist/types/plugins/openai/nodes/UploadFileNode.d.ts +7 -0
- package/dist/types/plugins/openai/plugin.d.ts +2 -0
- package/dist/types/plugins/pinecone/PineconeVectorDatabase.d.ts +9 -0
- package/dist/types/plugins/pinecone/index.d.ts +2 -0
- package/dist/types/plugins/pinecone/plugin.d.ts +2 -0
- package/dist/types/plugins.d.ts +20 -0
- package/dist/types/recording/ExecutionRecorder.d.ts +25 -0
- package/dist/types/recording/RecordedEvents.d.ts +100 -0
- package/dist/types/utils/assertNever.d.ts +1 -0
- package/dist/types/utils/base64.d.ts +2 -0
- package/dist/types/utils/chatMessageToOpenAIChatCompletionMessage.d.ts +3 -0
- package/dist/types/utils/coerceType.d.ts +6 -0
- package/dist/types/utils/compatibility.d.ts +3 -0
- package/dist/types/utils/copyToClipboard.d.ts +1 -0
- package/dist/types/utils/defaults.d.ts +2 -0
- package/dist/types/utils/errors.d.ts +2 -0
- package/dist/types/utils/expectType.d.ts +3 -0
- package/dist/types/utils/fetchEventSource.d.ts +12 -0
- package/dist/types/utils/genericUtilFunctions.d.ts +21 -0
- package/dist/types/utils/getPluginConfig.d.ts +2 -0
- package/dist/types/utils/handleEscapeCharacters.d.ts +2 -0
- package/dist/types/utils/index.d.ts +14 -0
- package/dist/types/utils/inputs.d.ts +3 -0
- package/dist/types/utils/interpolation.d.ts +1 -0
- package/dist/types/utils/misc.d.ts +1 -0
- package/dist/types/utils/newId.d.ts +1 -0
- package/dist/types/utils/openai.d.ts +739 -0
- package/dist/types/utils/outputs.d.ts +3 -0
- package/dist/types/utils/serialization/serialization.d.ts +12 -0
- package/dist/types/utils/serialization/serializationUtils.d.ts +6 -0
- package/dist/types/utils/serialization/serialization_v1.d.ts +3 -0
- package/dist/types/utils/serialization/serialization_v2.d.ts +3 -0
- package/dist/types/utils/serialization/serialization_v3.d.ts +19 -0
- package/dist/types/utils/serialization/serialization_v4.d.ts +9 -0
- package/dist/types/utils/symbols.d.ts +3 -0
- package/dist/types/utils/time.d.ts +22 -0
- package/dist/types/utils/typeSafety.d.ts +37 -0
- package/package.json +97 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {} from '../../model/NodeBase.js';
|
|
2
|
+
import { NodeImpl } from '../../model/NodeImpl.js';
|
|
3
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
4
|
+
import { coerceType } from '../../utils/coerceType.js';
|
|
5
|
+
import { dedent } from 'ts-dedent';
|
|
6
|
+
import { openAiModelOptions, openaiModels } from '../../utils/openai.js';
|
|
7
|
+
import {} from '../../index.js';
|
|
8
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
9
|
+
export class ChunkNodeImpl extends NodeImpl {
|
|
10
|
+
static create() {
|
|
11
|
+
const chartNode = {
|
|
12
|
+
type: 'chunk',
|
|
13
|
+
title: 'Chunk',
|
|
14
|
+
id: nanoid(),
|
|
15
|
+
visualData: {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0,
|
|
18
|
+
width: 200,
|
|
19
|
+
},
|
|
20
|
+
data: {
|
|
21
|
+
model: 'gpt-3.5-turbo',
|
|
22
|
+
useModelInput: false,
|
|
23
|
+
numTokensPerChunk: 1024,
|
|
24
|
+
overlap: 0,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
return chartNode;
|
|
28
|
+
}
|
|
29
|
+
getInputDefinitions() {
|
|
30
|
+
const inputs = [
|
|
31
|
+
{
|
|
32
|
+
id: 'input',
|
|
33
|
+
title: 'Input',
|
|
34
|
+
dataType: 'string',
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
if (this.data.useModelInput) {
|
|
38
|
+
inputs.push({
|
|
39
|
+
id: 'model',
|
|
40
|
+
title: 'Model',
|
|
41
|
+
dataType: 'string',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return inputs;
|
|
45
|
+
}
|
|
46
|
+
getOutputDefinitions() {
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
id: 'chunks',
|
|
50
|
+
title: 'Chunks',
|
|
51
|
+
dataType: 'string[]',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 'first',
|
|
55
|
+
title: 'First',
|
|
56
|
+
dataType: 'string',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'last',
|
|
60
|
+
title: 'Last',
|
|
61
|
+
dataType: 'string',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'indexes',
|
|
65
|
+
title: 'Indexes',
|
|
66
|
+
dataType: 'number[]',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'count',
|
|
70
|
+
title: 'Count',
|
|
71
|
+
dataType: 'number',
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
getEditors() {
|
|
76
|
+
return [
|
|
77
|
+
{
|
|
78
|
+
type: 'dropdown',
|
|
79
|
+
label: 'Model',
|
|
80
|
+
dataKey: 'model',
|
|
81
|
+
options: openAiModelOptions,
|
|
82
|
+
useInputToggleDataKey: 'useModelInput',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: 'number',
|
|
86
|
+
label: 'Number of tokens per chunk',
|
|
87
|
+
dataKey: 'numTokensPerChunk',
|
|
88
|
+
min: 1,
|
|
89
|
+
max: 32768,
|
|
90
|
+
step: 1,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: 'number',
|
|
94
|
+
label: 'Overlap (in %)',
|
|
95
|
+
dataKey: 'overlap',
|
|
96
|
+
min: 0,
|
|
97
|
+
max: 100,
|
|
98
|
+
step: 1,
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
getBody() {
|
|
103
|
+
return dedent `
|
|
104
|
+
Model: ${this.data.model}
|
|
105
|
+
Token Count: ${this.data.numTokensPerChunk.toLocaleString()}
|
|
106
|
+
${this.data.overlap ? `Overlap: ${this.data.overlap}%` : ''}
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
static getUIData() {
|
|
110
|
+
return {
|
|
111
|
+
infoBoxBody: dedent `
|
|
112
|
+
Splits the input text into an array of chunks based on an approximate GPT token count per chunk.
|
|
113
|
+
|
|
114
|
+
The "overlap" setting allows you to partially overlap the chunks for redundancy.
|
|
115
|
+
|
|
116
|
+
Can also be used for string length truncation by only using the \`First\` or \`Last\` outputs of the node.
|
|
117
|
+
`,
|
|
118
|
+
infoBoxTitle: 'Chunk Node',
|
|
119
|
+
contextMenuTitle: 'Chunk',
|
|
120
|
+
group: ['Text'],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async process(inputs, context) {
|
|
124
|
+
const input = coerceType(inputs['input'], 'string');
|
|
125
|
+
const overlapPercent = this.chartNode.data.overlap / 100;
|
|
126
|
+
const chunked = await chunkStringByTokenCount(context.tokenizer, {
|
|
127
|
+
node: this.chartNode,
|
|
128
|
+
endpoint: undefined,
|
|
129
|
+
model: this.data.model,
|
|
130
|
+
}, input, this.chartNode.data.numTokensPerChunk, overlapPercent);
|
|
131
|
+
return {
|
|
132
|
+
['chunks']: {
|
|
133
|
+
type: 'string[]',
|
|
134
|
+
value: chunked,
|
|
135
|
+
},
|
|
136
|
+
['first']: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
value: chunked[0],
|
|
139
|
+
},
|
|
140
|
+
['last']: {
|
|
141
|
+
type: 'string',
|
|
142
|
+
value: chunked.at(-1),
|
|
143
|
+
},
|
|
144
|
+
['indexes']: {
|
|
145
|
+
type: 'number[]',
|
|
146
|
+
value: chunked.map((_, i) => i + 1),
|
|
147
|
+
},
|
|
148
|
+
['count']: {
|
|
149
|
+
type: 'number',
|
|
150
|
+
value: chunked.length,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export const chunkNode = nodeDefinition(ChunkNodeImpl, 'Chunk');
|
|
156
|
+
export async function chunkStringByTokenCount(tokenizer, tokenizerInfo, input, targetTokenCount, overlapPercent) {
|
|
157
|
+
overlapPercent = Number.isNaN(overlapPercent) ? 0 : Math.max(0, Math.min(1, overlapPercent));
|
|
158
|
+
const chunks = [];
|
|
159
|
+
const guess = Math.floor(targetTokenCount * (input.length / (await tokenizer.getTokenCountForString(input, tokenizerInfo))));
|
|
160
|
+
let remaining = input;
|
|
161
|
+
while (remaining.length > 0) {
|
|
162
|
+
chunks.push(remaining.slice(0, guess));
|
|
163
|
+
remaining = remaining.slice(guess - Math.floor(guess * overlapPercent));
|
|
164
|
+
}
|
|
165
|
+
return chunks;
|
|
166
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
2
|
+
import {} from '../NodeBase.js';
|
|
3
|
+
import { unwrapDataValue } from '../DataValue.js';
|
|
4
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
5
|
+
import {} from '../GraphProcessor.js';
|
|
6
|
+
import { dedent } from 'ts-dedent';
|
|
7
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
8
|
+
export class CoalesceNodeImpl extends NodeImpl {
|
|
9
|
+
static create = () => {
|
|
10
|
+
const chartNode = {
|
|
11
|
+
type: 'coalesce',
|
|
12
|
+
title: 'Coalesce',
|
|
13
|
+
id: nanoid(),
|
|
14
|
+
data: {},
|
|
15
|
+
visualData: {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0,
|
|
18
|
+
width: 150,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
return chartNode;
|
|
22
|
+
};
|
|
23
|
+
getInputDefinitions(connections) {
|
|
24
|
+
const inputs = [];
|
|
25
|
+
const inputCount = this.#getInputPortCount(connections);
|
|
26
|
+
inputs.push({
|
|
27
|
+
dataType: 'boolean',
|
|
28
|
+
id: 'conditional',
|
|
29
|
+
title: 'Conditional',
|
|
30
|
+
});
|
|
31
|
+
for (let i = 1; i <= inputCount; i++) {
|
|
32
|
+
inputs.push({
|
|
33
|
+
dataType: 'any',
|
|
34
|
+
id: `input${i}`,
|
|
35
|
+
title: `Input ${i}`,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return inputs;
|
|
39
|
+
}
|
|
40
|
+
getOutputDefinitions() {
|
|
41
|
+
return [
|
|
42
|
+
{
|
|
43
|
+
dataType: 'any',
|
|
44
|
+
id: 'output',
|
|
45
|
+
title: 'Output',
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
static getUIData() {
|
|
50
|
+
return {
|
|
51
|
+
infoBoxBody: dedent `
|
|
52
|
+
Takes in any number of inputs and outputs the first value that exists. Useful for consolidating branches after a Match node. This node can also "consume" the "Not Ran" value.
|
|
53
|
+
`,
|
|
54
|
+
infoBoxTitle: 'Coalesce Node',
|
|
55
|
+
contextMenuTitle: 'Coalesce',
|
|
56
|
+
group: ['Logic'],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
#getInputPortCount(connections) {
|
|
60
|
+
const inputNodeId = this.chartNode.id;
|
|
61
|
+
const inputConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('input'));
|
|
62
|
+
let maxInputNumber = 0;
|
|
63
|
+
for (const connection of inputConnections) {
|
|
64
|
+
const messageNumber = parseInt(connection.inputId.replace('input', ''), 10);
|
|
65
|
+
if (messageNumber > maxInputNumber) {
|
|
66
|
+
maxInputNumber = messageNumber;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return maxInputNumber + 1;
|
|
70
|
+
}
|
|
71
|
+
async process(inputData) {
|
|
72
|
+
const conditional = inputData['conditional'];
|
|
73
|
+
// This lets the coalesce actually be control-flow-excluded itself, because otherwise
|
|
74
|
+
// the input control-flow-excluded are consumed.
|
|
75
|
+
if (conditional?.type === 'control-flow-excluded') {
|
|
76
|
+
return {
|
|
77
|
+
['output']: {
|
|
78
|
+
type: 'control-flow-excluded',
|
|
79
|
+
value: undefined,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const inputCount = Object.keys(inputData).filter((key) => key.startsWith('input')).length;
|
|
84
|
+
const okInputValues = [];
|
|
85
|
+
for (let i = 1; i <= inputCount; i++) {
|
|
86
|
+
const inputValue = inputData[`input${i}`];
|
|
87
|
+
if (inputValue && inputValue.type !== 'control-flow-excluded' && unwrapDataValue(inputValue) != null) {
|
|
88
|
+
okInputValues.push(inputValue);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (okInputValues.length === 0) {
|
|
92
|
+
return {
|
|
93
|
+
['output']: {
|
|
94
|
+
type: 'control-flow-excluded',
|
|
95
|
+
value: undefined,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
['output']: okInputValues[0],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export const coalesceNode = nodeDefinition(CoalesceNodeImpl, 'Coalesce');
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import {} from '../DataValue.js';
|
|
5
|
+
import { dedent } from 'ts-dedent';
|
|
6
|
+
import {} from '../EditorDefinition.js';
|
|
7
|
+
import {} from '../NodeBodySpec.js';
|
|
8
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
9
|
+
const maskInput = (name) => name.trim().replace(/[^a-zA-Z0-9_]/g, '_');
|
|
10
|
+
const asValidNames = (names) => Array(...new Set(names.map(maskInput))).filter(Boolean);
|
|
11
|
+
export class CodeNodeImpl extends NodeImpl {
|
|
12
|
+
static create() {
|
|
13
|
+
const chartNode = {
|
|
14
|
+
type: 'code',
|
|
15
|
+
title: 'Code',
|
|
16
|
+
id: nanoid(),
|
|
17
|
+
visualData: {
|
|
18
|
+
x: 0,
|
|
19
|
+
y: 0,
|
|
20
|
+
},
|
|
21
|
+
data: {
|
|
22
|
+
code: dedent `
|
|
23
|
+
// This is a code node, you can write and JS in here and it will be executed.
|
|
24
|
+
// Inputs are accessible via an object \`inputs\` and data is typed (i.e. inputs.foo.type, inputs.foo.value)
|
|
25
|
+
// Return an object with named outputs that match the output names specified in the node's config.
|
|
26
|
+
// Output values must by typed as well (e.g. { bar: { type: 'string', value: 'bar' } }
|
|
27
|
+
return {
|
|
28
|
+
output1: {
|
|
29
|
+
type: inputs.input1.type,
|
|
30
|
+
value: inputs.input1.value
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
`,
|
|
34
|
+
inputNames: 'input1',
|
|
35
|
+
outputNames: 'output1',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
return chartNode;
|
|
39
|
+
}
|
|
40
|
+
getInputDefinitions() {
|
|
41
|
+
const inputNames = this.data.inputNames
|
|
42
|
+
? Array.isArray(this.data.inputNames)
|
|
43
|
+
? this.data.inputNames
|
|
44
|
+
: [this.data.inputNames]
|
|
45
|
+
: [];
|
|
46
|
+
return asValidNames(inputNames).map((inputName) => {
|
|
47
|
+
return {
|
|
48
|
+
type: 'any',
|
|
49
|
+
id: inputName.trim(),
|
|
50
|
+
title: inputName.trim(),
|
|
51
|
+
dataType: 'string',
|
|
52
|
+
required: false,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
getOutputDefinitions() {
|
|
57
|
+
const outputNames = this.data.outputNames
|
|
58
|
+
? Array.isArray(this.data.outputNames)
|
|
59
|
+
? this.data.outputNames
|
|
60
|
+
: [this.data.outputNames]
|
|
61
|
+
: [];
|
|
62
|
+
return asValidNames(outputNames).map((outputName) => {
|
|
63
|
+
return {
|
|
64
|
+
id: outputName.trim(),
|
|
65
|
+
title: outputName.trim(),
|
|
66
|
+
dataType: 'any',
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
getEditors() {
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
type: 'custom',
|
|
74
|
+
customEditorId: 'CodeNodeAIAssist',
|
|
75
|
+
label: 'AI Assist',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'code',
|
|
79
|
+
label: 'Code',
|
|
80
|
+
dataKey: 'code',
|
|
81
|
+
language: 'javascript',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: 'stringList',
|
|
85
|
+
label: 'Inputs',
|
|
86
|
+
dataKey: 'inputNames',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'stringList',
|
|
90
|
+
label: 'Outputs',
|
|
91
|
+
dataKey: 'outputNames',
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
getBody() {
|
|
96
|
+
const trimmed = this.data.code
|
|
97
|
+
.split('\n')
|
|
98
|
+
.slice(0, 15)
|
|
99
|
+
.map((line) => (line.length > 50 ? line.slice(0, 50) + '...' : line))
|
|
100
|
+
.join('\n')
|
|
101
|
+
.trim();
|
|
102
|
+
return {
|
|
103
|
+
type: 'colorized',
|
|
104
|
+
text: trimmed,
|
|
105
|
+
language: 'javascript',
|
|
106
|
+
fontSize: 12,
|
|
107
|
+
fontFamily: 'monospace',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
static getUIData() {
|
|
111
|
+
return {
|
|
112
|
+
infoBoxBody: dedent `
|
|
113
|
+
Executes a piece of JavaScript code. See the Rivet Documentation for more information on how to write code for the Code Node.
|
|
114
|
+
`,
|
|
115
|
+
infoBoxTitle: 'Code Node',
|
|
116
|
+
contextMenuTitle: 'Code',
|
|
117
|
+
group: ['Advanced'],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
async process(inputs) {
|
|
121
|
+
// eslint-disable-next-line no-new-func
|
|
122
|
+
const codeFunction = new Function('inputs', this.chartNode.data.code);
|
|
123
|
+
const outputs = codeFunction(inputs);
|
|
124
|
+
if (outputs == null || typeof outputs !== 'object' || ('then' in outputs && typeof outputs.then === 'function')) {
|
|
125
|
+
throw new Error('Code node must return an object with output values.');
|
|
126
|
+
}
|
|
127
|
+
const missingOutputs = this.getOutputDefinitions().filter((output) => !(output.id in outputs));
|
|
128
|
+
if (missingOutputs.length > 0) {
|
|
129
|
+
throw new Error(`Code node must return an object with output values for all outputs. To not run an output, return { "type": "control-flow-excluded", "value": undefiend }. To return undefined, return { "type": "any", "value": undefined }. Missing: ${missingOutputs
|
|
130
|
+
.map((output) => output.id)
|
|
131
|
+
.join(', ')}`);
|
|
132
|
+
}
|
|
133
|
+
return outputs;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export const codeNode = nodeDefinition(CodeNodeImpl, 'Code');
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import {} from '../DataValue.js';
|
|
5
|
+
import { dedent } from 'ts-dedent';
|
|
6
|
+
import {} from '../EditorDefinition.js';
|
|
7
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
8
|
+
export class CommentNodeImpl extends NodeImpl {
|
|
9
|
+
static create() {
|
|
10
|
+
const chartNode = {
|
|
11
|
+
type: 'comment',
|
|
12
|
+
title: 'Comment',
|
|
13
|
+
id: nanoid(),
|
|
14
|
+
visualData: {
|
|
15
|
+
x: 0,
|
|
16
|
+
y: 0,
|
|
17
|
+
width: 600,
|
|
18
|
+
},
|
|
19
|
+
data: {
|
|
20
|
+
text: '',
|
|
21
|
+
height: 600,
|
|
22
|
+
color: 'rgba(255,255,255,1)',
|
|
23
|
+
backgroundColor: 'rgba(0,0,0,0.05)',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
return chartNode;
|
|
27
|
+
}
|
|
28
|
+
getInputDefinitions() {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
getOutputDefinitions() {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
getEditors() {
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
type: 'color',
|
|
38
|
+
label: 'Color',
|
|
39
|
+
dataKey: 'color',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'color',
|
|
43
|
+
label: 'Background Color',
|
|
44
|
+
dataKey: 'backgroundColor',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'code',
|
|
48
|
+
label: 'Text',
|
|
49
|
+
dataKey: 'text',
|
|
50
|
+
language: 'markdown',
|
|
51
|
+
theme: 'vs-dark',
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
static getUIData() {
|
|
56
|
+
return {
|
|
57
|
+
infoBoxBody: dedent `
|
|
58
|
+
A comment node is a node that does nothing. It is useful for adding notes to a graph.
|
|
59
|
+
`,
|
|
60
|
+
infoBoxTitle: 'Comment Node',
|
|
61
|
+
contextMenuTitle: 'Comment',
|
|
62
|
+
group: ['Advanced'],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async process() {
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export const commentNode = nodeDefinition(CommentNodeImpl, 'Comment');
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import {} from '../GraphProcessor.js';
|
|
5
|
+
import {} from '../../index.js';
|
|
6
|
+
import { isEqual } from 'lodash-es';
|
|
7
|
+
import { match } from 'ts-pattern';
|
|
8
|
+
import { dedent } from 'ts-dedent';
|
|
9
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
10
|
+
import { coerceType, coerceTypeOptional } from '../../utils/coerceType.js';
|
|
11
|
+
export class CompareNodeImpl extends NodeImpl {
|
|
12
|
+
static create() {
|
|
13
|
+
const chartNode = {
|
|
14
|
+
type: 'compare',
|
|
15
|
+
title: 'Compare',
|
|
16
|
+
id: nanoid(),
|
|
17
|
+
visualData: {
|
|
18
|
+
x: 0,
|
|
19
|
+
y: 0,
|
|
20
|
+
width: 160,
|
|
21
|
+
},
|
|
22
|
+
data: {
|
|
23
|
+
comparisonFunction: '==',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
return chartNode;
|
|
27
|
+
}
|
|
28
|
+
getInputDefinitions() {
|
|
29
|
+
const inputs = [
|
|
30
|
+
{
|
|
31
|
+
dataType: 'any',
|
|
32
|
+
id: 'a',
|
|
33
|
+
title: 'A',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
dataType: 'any',
|
|
37
|
+
id: 'b',
|
|
38
|
+
title: 'B',
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
if (this.data.useComparisonFunctionInput) {
|
|
42
|
+
inputs.push({
|
|
43
|
+
dataType: 'string',
|
|
44
|
+
id: 'comparisonFunction',
|
|
45
|
+
title: 'Comparison Function',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return inputs;
|
|
49
|
+
}
|
|
50
|
+
getOutputDefinitions() {
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
dataType: 'boolean',
|
|
54
|
+
id: 'output',
|
|
55
|
+
title: 'Output',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
getEditors() {
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
type: 'dropdown',
|
|
63
|
+
label: 'Comparison Function',
|
|
64
|
+
dataKey: 'comparisonFunction',
|
|
65
|
+
options: [
|
|
66
|
+
{ label: '==', value: '==' },
|
|
67
|
+
{ label: '!=', value: '!=' },
|
|
68
|
+
{ label: '<', value: '<' },
|
|
69
|
+
{ label: '<=', value: '<=' },
|
|
70
|
+
{ label: '>', value: '>' },
|
|
71
|
+
{ label: '>=', value: '>=' },
|
|
72
|
+
{ label: 'and', value: 'and' },
|
|
73
|
+
{ label: 'or', value: 'or' },
|
|
74
|
+
{ label: 'xor', value: 'xor' },
|
|
75
|
+
{ label: 'nand', value: 'nand' },
|
|
76
|
+
{ label: 'nor', value: 'nor' },
|
|
77
|
+
{ label: 'xnor', value: 'xnor' },
|
|
78
|
+
],
|
|
79
|
+
useInputToggleDataKey: 'useComparisonFunctionInput',
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
getBody() {
|
|
84
|
+
return this.data.useComparisonFunctionInput ? 'A (Comparison Function) B' : `A ${this.data.comparisonFunction} B`;
|
|
85
|
+
}
|
|
86
|
+
static getUIData() {
|
|
87
|
+
return {
|
|
88
|
+
infoBoxBody: dedent `
|
|
89
|
+
Compares two values using the configured operator and outputs the result.
|
|
90
|
+
|
|
91
|
+
If the data types of the values do not match, then the B value is converted to the type of the A value.
|
|
92
|
+
`,
|
|
93
|
+
infoBoxTitle: 'Compare Node',
|
|
94
|
+
contextMenuTitle: 'Compare',
|
|
95
|
+
group: ['Logic'],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async process(inputs) {
|
|
99
|
+
const comparisonFunction = (this.data.useComparisonFunctionInput
|
|
100
|
+
? coerceType(inputs['comparisonFunction'], 'string')
|
|
101
|
+
: this.data.comparisonFunction);
|
|
102
|
+
const inputA = inputs['a'];
|
|
103
|
+
const inputB = inputs['b'];
|
|
104
|
+
if (!inputA) {
|
|
105
|
+
return {
|
|
106
|
+
['output']: {
|
|
107
|
+
type: 'boolean',
|
|
108
|
+
value: match(comparisonFunction)
|
|
109
|
+
.with('==', () => !inputB)
|
|
110
|
+
.with('!=', () => !!inputB)
|
|
111
|
+
.otherwise(() => false),
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const value1 = inputA.value;
|
|
116
|
+
const value2 = inputB?.type !== inputA.type ? coerceTypeOptional(inputB, inputA.type) : inputB.value;
|
|
117
|
+
return {
|
|
118
|
+
['output']: {
|
|
119
|
+
type: 'boolean',
|
|
120
|
+
value: match(comparisonFunction)
|
|
121
|
+
.with('==', () => isEqual(value1, value2))
|
|
122
|
+
.with('!=', () => !isEqual(value1, value2))
|
|
123
|
+
.with('<', () => value1 < value2)
|
|
124
|
+
.with('>', () => value1 > value2)
|
|
125
|
+
.with('<=', () => value1 <= value2)
|
|
126
|
+
.with('>=', () => value1 >= value2)
|
|
127
|
+
.with('and', () => !!(value1 && value2))
|
|
128
|
+
.with('or', () => !!(value1 || value2))
|
|
129
|
+
.with('xor', () => !!(value1 ? !value2 : value2))
|
|
130
|
+
.with('nand', () => !(value1 && value2))
|
|
131
|
+
.with('nor', () => !(value1 || value2))
|
|
132
|
+
.with('xnor', () => !(value1 ? !value2 : value2))
|
|
133
|
+
.exhaustive(),
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
export const compareNode = nodeDefinition(CompareNodeImpl, 'Compare');
|