@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,115 @@
|
|
|
1
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { dedent } from 'ts-dedent';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import { getInputOrData, coerceTypeOptional, newId, coerceType } from '../../utils/index.js';
|
|
6
|
+
import { arrayizeDataValue, unwrapDataValue } from '../DataValue.js';
|
|
7
|
+
export class AppendToDatasetNodeImpl extends NodeImpl {
|
|
8
|
+
static create() {
|
|
9
|
+
return {
|
|
10
|
+
id: nanoid(),
|
|
11
|
+
type: 'appendToDataset',
|
|
12
|
+
title: 'Append to Dataset',
|
|
13
|
+
visualData: { x: 0, y: 0, width: 250 },
|
|
14
|
+
data: {
|
|
15
|
+
datasetId: '',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
getInputDefinitions() {
|
|
20
|
+
const inputDefinitions = [];
|
|
21
|
+
inputDefinitions.push({
|
|
22
|
+
id: 'data',
|
|
23
|
+
dataType: 'string[]',
|
|
24
|
+
title: 'Data',
|
|
25
|
+
description: 'The data to append to the dataset. May be a string or array of strings. If an array, each element will be a column in the dataset.',
|
|
26
|
+
});
|
|
27
|
+
inputDefinitions.push({
|
|
28
|
+
id: 'id',
|
|
29
|
+
dataType: 'string',
|
|
30
|
+
title: 'ID',
|
|
31
|
+
description: 'The ID of the row to append. If not provided, a random ID will be generated. If an existing ID is provided, the row will be overwritten.',
|
|
32
|
+
});
|
|
33
|
+
inputDefinitions.push({
|
|
34
|
+
id: 'embedding',
|
|
35
|
+
dataType: 'vector',
|
|
36
|
+
title: 'Embedding',
|
|
37
|
+
description: 'The vector embedding to store with the row.',
|
|
38
|
+
});
|
|
39
|
+
if (this.data.useDatasetIdInput) {
|
|
40
|
+
inputDefinitions.push({
|
|
41
|
+
id: 'datasetId',
|
|
42
|
+
title: 'Dataset ID',
|
|
43
|
+
dataType: 'string',
|
|
44
|
+
description: 'The ID of the dataset to append to.',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return inputDefinitions;
|
|
48
|
+
}
|
|
49
|
+
getOutputDefinitions() {
|
|
50
|
+
return [
|
|
51
|
+
{
|
|
52
|
+
id: 'dataset',
|
|
53
|
+
title: 'Dataset',
|
|
54
|
+
dataType: 'object', // technically string[][]...
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'id_out',
|
|
58
|
+
title: 'ID',
|
|
59
|
+
dataType: 'string',
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
static getUIData() {
|
|
64
|
+
return {
|
|
65
|
+
infoBoxBody: dedent `
|
|
66
|
+
Appends a row of data to the specified dataset.
|
|
67
|
+
`,
|
|
68
|
+
infoBoxTitle: 'Append to Dataset Node',
|
|
69
|
+
contextMenuTitle: 'Append to Dataset',
|
|
70
|
+
group: ['Input/Output'],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
getEditors() {
|
|
74
|
+
return [
|
|
75
|
+
{
|
|
76
|
+
type: 'datasetSelector',
|
|
77
|
+
label: 'Dataset',
|
|
78
|
+
dataKey: 'datasetId',
|
|
79
|
+
useInputToggleDataKey: 'useDatasetIdInput',
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
async process(inputs, context) {
|
|
84
|
+
const { datasetProvider } = context;
|
|
85
|
+
if (datasetProvider == null) {
|
|
86
|
+
throw new Error('datasetProvider is required');
|
|
87
|
+
}
|
|
88
|
+
const datasetId = getInputOrData(this.data, inputs, 'datasetId', 'string');
|
|
89
|
+
const dataId = coerceTypeOptional(inputs['id'], 'string') || newId();
|
|
90
|
+
const embedding = coerceTypeOptional(inputs['embedding'], 'vector');
|
|
91
|
+
const dataInput = inputs['data'];
|
|
92
|
+
if (!dataInput) {
|
|
93
|
+
throw new Error('data input is required');
|
|
94
|
+
}
|
|
95
|
+
const data = arrayizeDataValue(unwrapDataValue(dataInput));
|
|
96
|
+
const stringData = data.map((d) => coerceType(d, 'string'));
|
|
97
|
+
const newData = {
|
|
98
|
+
id: dataId,
|
|
99
|
+
data: stringData,
|
|
100
|
+
embedding,
|
|
101
|
+
};
|
|
102
|
+
await datasetProvider.putDatasetRow(datasetId, newData);
|
|
103
|
+
return {
|
|
104
|
+
['dataset']: {
|
|
105
|
+
type: 'object',
|
|
106
|
+
value: newData,
|
|
107
|
+
},
|
|
108
|
+
['id_out']: {
|
|
109
|
+
type: 'string',
|
|
110
|
+
value: datasetId,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export const appendToDatasetNode = nodeDefinition(AppendToDatasetNodeImpl, 'Append To Dataset');
|
|
@@ -0,0 +1,144 @@
|
|
|
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 { entries } from '../../utils/typeSafety.js';
|
|
6
|
+
import { flattenDeep } from 'lodash-es';
|
|
7
|
+
import { dedent } from 'ts-dedent';
|
|
8
|
+
import {} from '../EditorDefinition.js';
|
|
9
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
10
|
+
export class ArrayNodeImpl extends NodeImpl {
|
|
11
|
+
static create() {
|
|
12
|
+
const chartNode = {
|
|
13
|
+
type: 'array',
|
|
14
|
+
title: 'Array',
|
|
15
|
+
id: nanoid(),
|
|
16
|
+
visualData: {
|
|
17
|
+
x: 0,
|
|
18
|
+
y: 0,
|
|
19
|
+
width: 200,
|
|
20
|
+
},
|
|
21
|
+
data: {
|
|
22
|
+
flatten: true,
|
|
23
|
+
flattenDeep: false,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
return chartNode;
|
|
27
|
+
}
|
|
28
|
+
getInputDefinitions(connections) {
|
|
29
|
+
const inputs = [];
|
|
30
|
+
const inputCount = this.#getInputPortCount(connections);
|
|
31
|
+
for (let i = 1; i <= inputCount; i++) {
|
|
32
|
+
inputs.push({
|
|
33
|
+
dataType: 'any',
|
|
34
|
+
id: `input${i}`,
|
|
35
|
+
title: `Input ${i}`,
|
|
36
|
+
description: 'An input to create the array from. If an array, will be flattened if the "Flatten" option is enabled.',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return inputs;
|
|
40
|
+
}
|
|
41
|
+
getOutputDefinitions() {
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
dataType: 'any[]',
|
|
45
|
+
id: 'output',
|
|
46
|
+
title: 'Output',
|
|
47
|
+
description: 'The array created from the inputs.',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
dataType: 'number[]',
|
|
51
|
+
id: 'indices',
|
|
52
|
+
title: 'Indices',
|
|
53
|
+
description: 'The indices of the array. I.e. [0, 1, 2, 3, etc]. Useful for zipping with the output array to get the indexes.',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
dataType: 'number',
|
|
57
|
+
id: 'length',
|
|
58
|
+
title: 'Length',
|
|
59
|
+
description: 'The length of the output array.',
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
getEditors() {
|
|
64
|
+
return [
|
|
65
|
+
{ type: 'toggle', label: 'Flatten', dataKey: 'flatten' },
|
|
66
|
+
{
|
|
67
|
+
type: 'toggle',
|
|
68
|
+
label: 'Deep',
|
|
69
|
+
dataKey: 'flattenDeep',
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
#getInputPortCount(connections) {
|
|
74
|
+
const inputNodeId = this.chartNode.id;
|
|
75
|
+
const inputConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('input'));
|
|
76
|
+
let maxInputNumber = 0;
|
|
77
|
+
for (const connection of inputConnections) {
|
|
78
|
+
const inputNumber = parseInt(connection.inputId.replace('input', ''));
|
|
79
|
+
if (inputNumber > maxInputNumber) {
|
|
80
|
+
maxInputNumber = inputNumber;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return maxInputNumber + 1;
|
|
84
|
+
}
|
|
85
|
+
static getUIData() {
|
|
86
|
+
return {
|
|
87
|
+
infoBoxBody: dedent `
|
|
88
|
+
Creates an array from the input values. By default, flattens any arrays which are inputs into a single array. Can be configured to keep the arrays separate, or deeply flatten arrays.
|
|
89
|
+
|
|
90
|
+
Useful for both creating and merging arrays.
|
|
91
|
+
|
|
92
|
+
The number of inputs is dynamic based on the number of connections.
|
|
93
|
+
`,
|
|
94
|
+
infoBoxTitle: 'Array Node',
|
|
95
|
+
contextMenuTitle: 'Array',
|
|
96
|
+
group: ['Lists'],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
getBody() {
|
|
100
|
+
return dedent `
|
|
101
|
+
${this.data.flatten ? (this.data.flattenDeep ? 'Flatten (Deep)' : 'Flatten') : 'No Flatten'}
|
|
102
|
+
`;
|
|
103
|
+
}
|
|
104
|
+
async process(inputs) {
|
|
105
|
+
const outputArray = [];
|
|
106
|
+
for (const [key, input] of entries(inputs)) {
|
|
107
|
+
if (key.startsWith('input')) {
|
|
108
|
+
if (this.data.flatten) {
|
|
109
|
+
if (Array.isArray(input?.value)) {
|
|
110
|
+
for (const value of input?.value ?? []) {
|
|
111
|
+
if (this.data.flattenDeep) {
|
|
112
|
+
outputArray.push(...(Array.isArray(value) ? flattenDeep(value) : [value]));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
outputArray.push(value);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
outputArray.push(input?.value);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
outputArray.push(input?.value);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
['output']: {
|
|
130
|
+
type: 'any[]',
|
|
131
|
+
value: outputArray,
|
|
132
|
+
},
|
|
133
|
+
['indices']: {
|
|
134
|
+
type: 'number[]',
|
|
135
|
+
value: outputArray.map((_, index) => index),
|
|
136
|
+
},
|
|
137
|
+
['length']: {
|
|
138
|
+
type: 'number',
|
|
139
|
+
value: outputArray.length,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export const arrayNode = nodeDefinition(ArrayNodeImpl, 'Array');
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import { arrayizeDataValue, unwrapDataValue } from '../DataValue.js';
|
|
5
|
+
import {} from '../GraphProcessor.js';
|
|
6
|
+
import { orderBy } from 'lodash-es';
|
|
7
|
+
import { coerceTypeOptional, dedent, getInputOrData } from '../../utils/index.js';
|
|
8
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
9
|
+
import { match } from 'ts-pattern';
|
|
10
|
+
const messageTypeToTitle = {
|
|
11
|
+
assistant: 'Assistant',
|
|
12
|
+
function: 'Function Tool Call',
|
|
13
|
+
system: 'System',
|
|
14
|
+
user: 'User',
|
|
15
|
+
};
|
|
16
|
+
export class AssembleMessageNodeImpl extends NodeImpl {
|
|
17
|
+
static create() {
|
|
18
|
+
const chartNode = {
|
|
19
|
+
type: 'assembleMessage',
|
|
20
|
+
title: 'Assemble Message',
|
|
21
|
+
id: nanoid(),
|
|
22
|
+
visualData: {
|
|
23
|
+
x: 0,
|
|
24
|
+
y: 0,
|
|
25
|
+
width: 250,
|
|
26
|
+
},
|
|
27
|
+
data: {
|
|
28
|
+
type: 'user',
|
|
29
|
+
useTypeInput: false,
|
|
30
|
+
toolCallId: '',
|
|
31
|
+
useToolCallIdInput: false,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
return chartNode;
|
|
35
|
+
}
|
|
36
|
+
getInputDefinitions(connections) {
|
|
37
|
+
const inputs = [];
|
|
38
|
+
const messageCount = this.#getInputPortCount(connections);
|
|
39
|
+
if (this.data.useTypeInput) {
|
|
40
|
+
inputs.push({
|
|
41
|
+
dataType: 'string',
|
|
42
|
+
id: 'type',
|
|
43
|
+
title: 'Type',
|
|
44
|
+
description: 'The type of message to assemble.',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (this.data.useToolCallIdInput) {
|
|
48
|
+
inputs.push({
|
|
49
|
+
dataType: 'string',
|
|
50
|
+
id: 'toolCallId',
|
|
51
|
+
title: 'Tool Call ID',
|
|
52
|
+
description: 'The ID of the tool call to associate with the message.',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
for (let i = 1; i <= messageCount; i++) {
|
|
56
|
+
inputs.push({
|
|
57
|
+
dataType: ['string', 'image', 'string[]', 'image[]', 'object', 'object[]'],
|
|
58
|
+
id: `part${i}`,
|
|
59
|
+
title: `Part ${i}`,
|
|
60
|
+
description: 'A part of the message to assemble.',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return inputs;
|
|
64
|
+
}
|
|
65
|
+
getOutputDefinitions() {
|
|
66
|
+
return [
|
|
67
|
+
{
|
|
68
|
+
dataType: 'chat-message',
|
|
69
|
+
id: 'message',
|
|
70
|
+
title: 'Message',
|
|
71
|
+
description: 'The assembled message.',
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
getEditors() {
|
|
76
|
+
return [
|
|
77
|
+
{
|
|
78
|
+
type: 'dropdown',
|
|
79
|
+
label: 'Type',
|
|
80
|
+
dataKey: 'type',
|
|
81
|
+
options: [
|
|
82
|
+
{ value: 'system', label: 'System' },
|
|
83
|
+
{ value: 'user', label: 'User' },
|
|
84
|
+
{ value: 'assistant', label: 'Assistant' },
|
|
85
|
+
{ value: 'function', label: 'Function' },
|
|
86
|
+
],
|
|
87
|
+
defaultValue: 'user',
|
|
88
|
+
useInputToggleDataKey: 'useTypeInput',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'string',
|
|
92
|
+
label: 'Tool Call ID',
|
|
93
|
+
dataKey: 'toolCallId',
|
|
94
|
+
useInputToggleDataKey: 'useToolCallIdInput',
|
|
95
|
+
hideIf: (data) => data.type !== 'function',
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
#getInputPortCount(connections) {
|
|
100
|
+
const inputNodeId = this.chartNode.id;
|
|
101
|
+
const messageConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('part'));
|
|
102
|
+
let maxMessageNumber = 0;
|
|
103
|
+
for (const connection of messageConnections) {
|
|
104
|
+
const messageNumber = parseInt(connection.inputId.replace('part', ''));
|
|
105
|
+
if (messageNumber > maxMessageNumber) {
|
|
106
|
+
maxMessageNumber = messageNumber;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return maxMessageNumber + 1;
|
|
110
|
+
}
|
|
111
|
+
static getUIData() {
|
|
112
|
+
return {
|
|
113
|
+
infoBoxBody: dedent `
|
|
114
|
+
Assembles a single chat message from multiple parts. This is similar to a Prompt node, but works with multimodal
|
|
115
|
+
models, as you can include both text and images in the message.
|
|
116
|
+
`,
|
|
117
|
+
infoBoxTitle: 'Assemble Message Node',
|
|
118
|
+
contextMenuTitle: 'Assemble Message',
|
|
119
|
+
group: 'AI',
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
getBody(_context) {
|
|
123
|
+
return dedent `
|
|
124
|
+
${this.data.useTypeInput ? '(Type From Input)' : messageTypeToTitle[this.data.type]}
|
|
125
|
+
${this.data.useTypeInput || this.data.type === 'function'
|
|
126
|
+
? `Tool Call ID: ${this.data.useToolCallIdInput ? '(From Input)' : this.data.toolCallId}`
|
|
127
|
+
: ``}
|
|
128
|
+
`;
|
|
129
|
+
}
|
|
130
|
+
async process(inputs) {
|
|
131
|
+
const output = {};
|
|
132
|
+
const type = getInputOrData(this.data, inputs, 'type');
|
|
133
|
+
const outMessage = match(type)
|
|
134
|
+
.with('system', (type) => ({
|
|
135
|
+
type,
|
|
136
|
+
message: [],
|
|
137
|
+
}))
|
|
138
|
+
.with('user', (type) => ({
|
|
139
|
+
type,
|
|
140
|
+
message: [],
|
|
141
|
+
}))
|
|
142
|
+
.with('assistant', (type) => ({
|
|
143
|
+
type,
|
|
144
|
+
message: [],
|
|
145
|
+
function_call: undefined, // Not supported yet in Assemble Message node
|
|
146
|
+
function_calls: undefined, // Not supported yet in Assemble Message node
|
|
147
|
+
}))
|
|
148
|
+
.with('function', (type) => ({
|
|
149
|
+
type,
|
|
150
|
+
message: [],
|
|
151
|
+
name: getInputOrData(this.data, inputs, 'toolCallId'),
|
|
152
|
+
}))
|
|
153
|
+
.otherwise(() => {
|
|
154
|
+
throw new Error(`Invalid type: ${type}`);
|
|
155
|
+
});
|
|
156
|
+
const inputParts = orderBy(Object.entries(inputs).filter(([key]) => key.startsWith('part')), ([key]) => key, 'asc');
|
|
157
|
+
for (const [, inputPart] of inputParts) {
|
|
158
|
+
if (!inputPart || inputPart.type === 'control-flow-excluded' || !inputPart.value) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const inPart = arrayizeDataValue(unwrapDataValue(inputPart));
|
|
162
|
+
for (const message of inPart) {
|
|
163
|
+
if (message.type === 'string') {
|
|
164
|
+
outMessage.message.push(message.value);
|
|
165
|
+
}
|
|
166
|
+
else if (message.type === 'image') {
|
|
167
|
+
outMessage.message.push({
|
|
168
|
+
type: 'image',
|
|
169
|
+
data: message.value.data,
|
|
170
|
+
mediaType: message.value.mediaType,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
else if (message.type === 'object') {
|
|
174
|
+
if (message.value &&
|
|
175
|
+
'type' in message.value &&
|
|
176
|
+
message.value.type === 'url_reference' &&
|
|
177
|
+
typeof message.value.url === 'string') {
|
|
178
|
+
outMessage.message.push({
|
|
179
|
+
type: 'url',
|
|
180
|
+
url: message.value.url,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
const coerced = coerceTypeOptional(message, 'string');
|
|
186
|
+
if (coerced) {
|
|
187
|
+
outMessage.message.push(coerced);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
output['message'] = {
|
|
193
|
+
type: 'chat-message',
|
|
194
|
+
value: outMessage,
|
|
195
|
+
};
|
|
196
|
+
return output;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
export const assembleMessageNode = nodeDefinition(AssembleMessageNodeImpl, 'Assemble Prompt');
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import { arrayizeDataValue, unwrapDataValue } from '../DataValue.js';
|
|
5
|
+
import {} from '../GraphProcessor.js';
|
|
6
|
+
import { coerceType } from '../../utils/coerceType.js';
|
|
7
|
+
import { orderBy } from 'lodash-es';
|
|
8
|
+
import { dedent } from 'ts-dedent';
|
|
9
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
10
|
+
export class AssemblePromptNodeImpl extends NodeImpl {
|
|
11
|
+
static create() {
|
|
12
|
+
const chartNode = {
|
|
13
|
+
type: 'assemblePrompt',
|
|
14
|
+
title: 'Assemble Prompt',
|
|
15
|
+
id: nanoid(),
|
|
16
|
+
visualData: {
|
|
17
|
+
x: 0,
|
|
18
|
+
y: 0,
|
|
19
|
+
width: 250,
|
|
20
|
+
},
|
|
21
|
+
data: {},
|
|
22
|
+
};
|
|
23
|
+
return chartNode;
|
|
24
|
+
}
|
|
25
|
+
getInputDefinitions(connections) {
|
|
26
|
+
const inputs = [];
|
|
27
|
+
const messageCount = this.#getMessagePortCount(connections);
|
|
28
|
+
for (let i = 1; i <= messageCount; i++) {
|
|
29
|
+
inputs.push({
|
|
30
|
+
dataType: ['chat-message', 'chat-message[]'],
|
|
31
|
+
id: `message${i}`,
|
|
32
|
+
title: `Message ${i}`,
|
|
33
|
+
description: 'A message, or messages, to include in the full prompt.',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return inputs;
|
|
37
|
+
}
|
|
38
|
+
getOutputDefinitions() {
|
|
39
|
+
const outputs = [
|
|
40
|
+
{
|
|
41
|
+
dataType: 'chat-message[]',
|
|
42
|
+
id: 'prompt',
|
|
43
|
+
title: 'Prompt',
|
|
44
|
+
description: 'The assembled prompt, a list of chat messages.',
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
if (this.data.computeTokenCount) {
|
|
48
|
+
outputs.push({
|
|
49
|
+
dataType: 'number',
|
|
50
|
+
id: 'tokenCount',
|
|
51
|
+
title: 'Token Count',
|
|
52
|
+
description: 'The number of tokens in the full output prompt.',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return outputs;
|
|
56
|
+
}
|
|
57
|
+
#getMessagePortCount(connections) {
|
|
58
|
+
const inputNodeId = this.chartNode.id;
|
|
59
|
+
const messageConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('message'));
|
|
60
|
+
let maxMessageNumber = 0;
|
|
61
|
+
for (const connection of messageConnections) {
|
|
62
|
+
const messageNumber = parseInt(connection.inputId.replace('message', ''));
|
|
63
|
+
if (messageNumber > maxMessageNumber) {
|
|
64
|
+
maxMessageNumber = messageNumber;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return maxMessageNumber + 1;
|
|
68
|
+
}
|
|
69
|
+
static getUIData() {
|
|
70
|
+
return {
|
|
71
|
+
infoBoxBody: dedent `
|
|
72
|
+
Assembles an array of chat messages for use with a Chat node. The inputs can be strings or chat messages.
|
|
73
|
+
|
|
74
|
+
The number of inputs is dynamic based on the number of connections.
|
|
75
|
+
|
|
76
|
+
Strings are converted to User type chat messages.
|
|
77
|
+
`,
|
|
78
|
+
infoBoxTitle: 'Assemble Prompt Node',
|
|
79
|
+
contextMenuTitle: 'Assemble Prompt',
|
|
80
|
+
group: ['AI'],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
getEditors(_context) {
|
|
84
|
+
return [
|
|
85
|
+
{
|
|
86
|
+
type: 'toggle',
|
|
87
|
+
label: 'Compute Token Count',
|
|
88
|
+
dataKey: 'computeTokenCount',
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
async process(inputs, context) {
|
|
93
|
+
const output = {};
|
|
94
|
+
const outMessages = [];
|
|
95
|
+
const inputMessages = orderBy(Object.entries(inputs).filter(([key]) => key.startsWith('message')), ([key]) => key, 'asc');
|
|
96
|
+
for (const [, inputMessage] of inputMessages) {
|
|
97
|
+
if (!inputMessage || inputMessage.type === 'control-flow-excluded' || !inputMessage.value) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const inMessages = arrayizeDataValue(unwrapDataValue(inputMessage));
|
|
101
|
+
for (const message of inMessages) {
|
|
102
|
+
if (message.type === 'chat-message') {
|
|
103
|
+
outMessages.push(message.value);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const coerced = coerceType(message, 'chat-message');
|
|
107
|
+
if (coerced) {
|
|
108
|
+
outMessages.push(coerced);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
output['prompt'] = {
|
|
114
|
+
type: 'chat-message[]',
|
|
115
|
+
value: outMessages,
|
|
116
|
+
};
|
|
117
|
+
if (this.data.computeTokenCount) {
|
|
118
|
+
const tokenCount = await context.tokenizer.getTokenCountForMessages(outMessages, undefined, {
|
|
119
|
+
node: this.chartNode,
|
|
120
|
+
});
|
|
121
|
+
output['tokenCount'] = {
|
|
122
|
+
type: 'number',
|
|
123
|
+
value: tokenCount,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return output;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export const assemblePromptNode = nodeDefinition(AssemblePromptNodeImpl, 'Assemble Prompt');
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
3
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
4
|
+
import {} from '../../index.js';
|
|
5
|
+
import { base64ToUint8Array, expectType } from '../../utils/index.js';
|
|
6
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
7
|
+
import { getInputOrData } from '../../utils/inputs.js';
|
|
8
|
+
export class AudioNodeImpl extends NodeImpl {
|
|
9
|
+
static create() {
|
|
10
|
+
return {
|
|
11
|
+
id: nanoid(),
|
|
12
|
+
type: 'audio',
|
|
13
|
+
title: 'Audio',
|
|
14
|
+
visualData: { x: 0, y: 0, width: 300 },
|
|
15
|
+
data: {
|
|
16
|
+
useDataInput: false,
|
|
17
|
+
useMediaTypeInput: false,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
getInputDefinitions() {
|
|
22
|
+
const inputDefinitions = [];
|
|
23
|
+
if (this.chartNode.data.useDataInput) {
|
|
24
|
+
inputDefinitions.push({
|
|
25
|
+
id: 'data',
|
|
26
|
+
title: 'Data',
|
|
27
|
+
dataType: 'string',
|
|
28
|
+
coerced: false,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (this.chartNode.data.useMediaTypeInput) {
|
|
32
|
+
inputDefinitions.push({
|
|
33
|
+
id: 'mediaType',
|
|
34
|
+
title: 'Media Type',
|
|
35
|
+
dataType: 'string',
|
|
36
|
+
coerced: false,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return inputDefinitions;
|
|
40
|
+
}
|
|
41
|
+
getOutputDefinitions() {
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
id: 'data',
|
|
45
|
+
title: 'Audio Data',
|
|
46
|
+
dataType: 'audio',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
getEditors() {
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
type: 'fileBrowser',
|
|
54
|
+
label: 'Audio File',
|
|
55
|
+
dataKey: 'data',
|
|
56
|
+
mediaTypeDataKey: 'mediaType',
|
|
57
|
+
useInputToggleDataKey: 'useDataInput',
|
|
58
|
+
accept: 'audio/*',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: 'string',
|
|
62
|
+
label: 'Media Type',
|
|
63
|
+
dataKey: 'mediaType',
|
|
64
|
+
useInputToggleDataKey: 'useMediaTypeInput',
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
static getUIData() {
|
|
69
|
+
return {
|
|
70
|
+
contextMenuTitle: 'Audio',
|
|
71
|
+
group: 'Data',
|
|
72
|
+
infoBoxTitle: 'Audio Node',
|
|
73
|
+
infoBoxBody: 'Defines an audio sample for use with other nodes. Can convert a binary type into an audio type.',
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async process(inputData, context) {
|
|
77
|
+
let data;
|
|
78
|
+
const mediaType = getInputOrData(this.data, inputData, 'mediaType', 'string') || 'audio/wav';
|
|
79
|
+
if (this.chartNode.data.useDataInput) {
|
|
80
|
+
data = expectType(inputData['data'], 'binary');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const dataRef = this.data.data?.refId;
|
|
84
|
+
if (!dataRef) {
|
|
85
|
+
throw new Error('No data ref');
|
|
86
|
+
}
|
|
87
|
+
const encodedData = context.project.data?.[dataRef];
|
|
88
|
+
if (!encodedData) {
|
|
89
|
+
throw new Error(`No data at ref ${dataRef}`);
|
|
90
|
+
}
|
|
91
|
+
data = base64ToUint8Array(encodedData);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
['data']: {
|
|
95
|
+
type: 'audio',
|
|
96
|
+
value: { data, mediaType },
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export const audioNode = nodeDefinition(AudioNodeImpl, 'Audio');
|