@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,99 @@
|
|
|
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 {} from '../GraphProcessor.js';
|
|
6
|
+
import {} from '../ProcessContext.js';
|
|
7
|
+
import { dedent } from 'ts-dedent';
|
|
8
|
+
import {} from '../EditorDefinition.js';
|
|
9
|
+
import {} from '../NodeBodySpec.js';
|
|
10
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
11
|
+
export class ContextNodeImpl extends NodeImpl {
|
|
12
|
+
static create() {
|
|
13
|
+
const chartNode = {
|
|
14
|
+
type: 'context',
|
|
15
|
+
title: 'Context',
|
|
16
|
+
id: nanoid(),
|
|
17
|
+
visualData: {
|
|
18
|
+
x: 0,
|
|
19
|
+
y: 0,
|
|
20
|
+
width: 300,
|
|
21
|
+
},
|
|
22
|
+
data: {
|
|
23
|
+
id: 'input',
|
|
24
|
+
dataType: 'string',
|
|
25
|
+
defaultValue: undefined,
|
|
26
|
+
useDefaultValueInput: false,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
return chartNode;
|
|
30
|
+
}
|
|
31
|
+
getInputDefinitions() {
|
|
32
|
+
if (this.data.useDefaultValueInput) {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
id: 'default',
|
|
36
|
+
title: 'Default Value',
|
|
37
|
+
dataType: this.chartNode.data.dataType,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
getOutputDefinitions() {
|
|
44
|
+
return [
|
|
45
|
+
{
|
|
46
|
+
id: 'data',
|
|
47
|
+
title: this.data.id,
|
|
48
|
+
dataType: this.chartNode.data.dataType,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
getEditors() {
|
|
53
|
+
return [
|
|
54
|
+
{ type: 'string', label: 'ID', dataKey: 'id' },
|
|
55
|
+
{ type: 'dataTypeSelector', label: 'Data Type', dataKey: 'dataType' },
|
|
56
|
+
{
|
|
57
|
+
type: 'anyData',
|
|
58
|
+
label: 'Default Value',
|
|
59
|
+
dataKey: 'defaultValue',
|
|
60
|
+
useInputToggleDataKey: 'useDefaultValueInput',
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
getBody() {
|
|
65
|
+
return dedent `
|
|
66
|
+
${this.data.id}
|
|
67
|
+
Type: ${this.data.dataType}
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
static getUIData() {
|
|
71
|
+
return {
|
|
72
|
+
infoBoxBody: dedent `
|
|
73
|
+
Retrieves a value from the graph's context using a configured id. The context serves as a "global graph input", allowing the same values to be accessible from any graph or subgraph.
|
|
74
|
+
`,
|
|
75
|
+
infoBoxTitle: 'Context Node',
|
|
76
|
+
contextMenuTitle: 'Context',
|
|
77
|
+
group: ['Advanced'],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async process(inputs, context) {
|
|
81
|
+
const contextValue = context.contextValues[this.data.id];
|
|
82
|
+
if (contextValue !== undefined) {
|
|
83
|
+
return {
|
|
84
|
+
['data']: contextValue,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
let defaultValue;
|
|
88
|
+
if (this.data.useDefaultValueInput) {
|
|
89
|
+
defaultValue = inputs['default'];
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
defaultValue = { type: this.data.dataType, value: this.data.defaultValue };
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
['data']: defaultValue,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export const contextNode = nodeDefinition(ContextNodeImpl, 'Context');
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
2
|
+
import { coerceTypeOptional, dedent, newId } from '../../utils/index.js';
|
|
3
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
4
|
+
export class CreateDatasetNodeImpl extends NodeImpl {
|
|
5
|
+
static create() {
|
|
6
|
+
return {
|
|
7
|
+
id: newId(),
|
|
8
|
+
type: 'createDataset',
|
|
9
|
+
title: 'Create Dataset',
|
|
10
|
+
visualData: { x: 0, y: 0, width: 250 },
|
|
11
|
+
data: {},
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
getInputDefinitions() {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
id: 'datasetId',
|
|
18
|
+
title: 'Dataset ID',
|
|
19
|
+
dataType: 'string',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'datasetName',
|
|
23
|
+
title: 'Dataset Name',
|
|
24
|
+
dataType: 'string',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
getOutputDefinitions() {
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
id: 'datasetId_out',
|
|
32
|
+
title: 'Dataset ID',
|
|
33
|
+
dataType: 'string',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
static getUIData() {
|
|
38
|
+
return {
|
|
39
|
+
infoBoxBody: dedent `
|
|
40
|
+
Creates a new dataset with the provided ID and name. If the dataset already exists, it does nothing.
|
|
41
|
+
`,
|
|
42
|
+
infoBoxTitle: 'Create Dataset Node',
|
|
43
|
+
contextMenuTitle: 'Create Dataset',
|
|
44
|
+
group: ['Input/Output'],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async process(inputs, context) {
|
|
48
|
+
const { datasetProvider } = context;
|
|
49
|
+
if (datasetProvider == null) {
|
|
50
|
+
throw new Error('datasetProvider is required');
|
|
51
|
+
}
|
|
52
|
+
const datasetId = coerceTypeOptional(inputs['datasetId'], 'string') || newId();
|
|
53
|
+
const datasetName = coerceTypeOptional(inputs['datasetName'], 'string') || datasetId;
|
|
54
|
+
const existingDataset = await datasetProvider.getDatasetMetadata(datasetId);
|
|
55
|
+
if (!existingDataset) {
|
|
56
|
+
await datasetProvider.putDatasetMetadata({
|
|
57
|
+
id: datasetId,
|
|
58
|
+
name: datasetName,
|
|
59
|
+
description: '',
|
|
60
|
+
projectId: context.project.metadata.id,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
['datasetId_out']: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
value: datasetId || datasetName,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export const createDatasetNode = nodeDefinition(CreateDatasetNodeImpl, 'Create Dataset');
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
2
|
+
import { coerceType, dedent, getInputOrData, newId } from '../../utils/index.js';
|
|
3
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
4
|
+
export class DatasetNearestNeighborsNodeImpl extends NodeImpl {
|
|
5
|
+
static create() {
|
|
6
|
+
return {
|
|
7
|
+
id: newId(),
|
|
8
|
+
type: 'datasetNearestNeighbors',
|
|
9
|
+
title: 'KNN Dataset',
|
|
10
|
+
visualData: { x: 0, y: 0, width: 250 },
|
|
11
|
+
data: {
|
|
12
|
+
datasetId: '',
|
|
13
|
+
k: 5,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
getInputDefinitions() {
|
|
18
|
+
const inputs = [
|
|
19
|
+
{
|
|
20
|
+
id: 'embedding',
|
|
21
|
+
title: 'Embedding',
|
|
22
|
+
dataType: 'object',
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
if (this.data.useDatasetIdInput) {
|
|
26
|
+
inputs.push({
|
|
27
|
+
id: 'datasetId',
|
|
28
|
+
title: 'Dataset ID',
|
|
29
|
+
dataType: 'string',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (this.data.useKInput) {
|
|
33
|
+
inputs.push({
|
|
34
|
+
id: 'k',
|
|
35
|
+
title: 'K',
|
|
36
|
+
dataType: 'number',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return inputs;
|
|
40
|
+
}
|
|
41
|
+
getOutputDefinitions() {
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
id: 'nearestNeighbors',
|
|
45
|
+
title: 'Nearest Neighbors',
|
|
46
|
+
dataType: 'object[]',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
static getUIData() {
|
|
51
|
+
return {
|
|
52
|
+
infoBoxBody: dedent `
|
|
53
|
+
Finds the k nearest neighbors in the dataset with the provided ID, given an embedding.
|
|
54
|
+
`,
|
|
55
|
+
infoBoxTitle: 'KNN Dataset Node',
|
|
56
|
+
contextMenuTitle: 'KNN Dataset',
|
|
57
|
+
group: ['Input/Output'],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
getEditors() {
|
|
61
|
+
return [
|
|
62
|
+
{
|
|
63
|
+
type: 'datasetSelector',
|
|
64
|
+
label: 'Dataset',
|
|
65
|
+
dataKey: 'datasetId',
|
|
66
|
+
useInputToggleDataKey: 'useDatasetIdInput',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'number',
|
|
70
|
+
label: 'K',
|
|
71
|
+
dataKey: 'k',
|
|
72
|
+
useInputToggleDataKey: 'useKInput',
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
async process(inputs, context) {
|
|
77
|
+
const { datasetProvider } = context;
|
|
78
|
+
if (datasetProvider == null) {
|
|
79
|
+
throw new Error('datasetProvider is required');
|
|
80
|
+
}
|
|
81
|
+
const datasetId = getInputOrData(this.data, inputs, 'datasetId');
|
|
82
|
+
const k = getInputOrData(this.data, inputs, 'k', 'number');
|
|
83
|
+
const embedding = coerceType(inputs['embedding'], 'vector');
|
|
84
|
+
const nearestNeighbors = await datasetProvider.knnDatasetRows(datasetId, k, embedding);
|
|
85
|
+
return {
|
|
86
|
+
['nearestNeighbors']: {
|
|
87
|
+
type: 'object[]',
|
|
88
|
+
value: nearestNeighbors.map((neighbor) => ({
|
|
89
|
+
id: neighbor.id,
|
|
90
|
+
distance: neighbor.distance,
|
|
91
|
+
data: neighbor.data,
|
|
92
|
+
})),
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export const datasetNearestNeighborsNode = nodeDefinition(DatasetNearestNeighborsNodeImpl, 'Dataset Nearest Neighbors');
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import {} from '../GraphProcessor.js';
|
|
6
|
+
import {} from '../../index.js';
|
|
7
|
+
import { dedent } from 'ts-dedent';
|
|
8
|
+
import { getInputOrData } from '../../utils/inputs.js';
|
|
9
|
+
export class DelayNodeImpl extends NodeImpl {
|
|
10
|
+
static create() {
|
|
11
|
+
const chartNode = {
|
|
12
|
+
type: 'delay',
|
|
13
|
+
title: 'Delay',
|
|
14
|
+
id: nanoid(),
|
|
15
|
+
visualData: {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0,
|
|
18
|
+
width: 175,
|
|
19
|
+
},
|
|
20
|
+
data: {
|
|
21
|
+
delay: 0,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
return chartNode;
|
|
25
|
+
}
|
|
26
|
+
getInputDefinitions(connections) {
|
|
27
|
+
const inputs = [];
|
|
28
|
+
const inputCount = this.#getInputPortCount(connections);
|
|
29
|
+
if (this.data.useDelayInput) {
|
|
30
|
+
inputs.push({
|
|
31
|
+
dataType: 'number',
|
|
32
|
+
id: 'delay',
|
|
33
|
+
title: 'Delay (ms)',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
for (let i = 1; i <= inputCount; i++) {
|
|
37
|
+
inputs.push({
|
|
38
|
+
dataType: 'any',
|
|
39
|
+
id: `input${i}`,
|
|
40
|
+
title: `Input ${i}`,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return inputs;
|
|
44
|
+
}
|
|
45
|
+
getOutputDefinitions(connections) {
|
|
46
|
+
const outputs = [];
|
|
47
|
+
const inputCount = this.#getInputPortCount(connections);
|
|
48
|
+
for (let i = 1; i <= inputCount - 1; i++) {
|
|
49
|
+
outputs.push({
|
|
50
|
+
dataType: 'any',
|
|
51
|
+
id: `output${i}`,
|
|
52
|
+
title: `Output ${i}`,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return outputs;
|
|
56
|
+
}
|
|
57
|
+
static getUIData() {
|
|
58
|
+
return {
|
|
59
|
+
infoBoxBody: dedent `
|
|
60
|
+
Delays the execution and then passes the input value to the output without any modifications.
|
|
61
|
+
`,
|
|
62
|
+
infoBoxTitle: 'Delay Node',
|
|
63
|
+
contextMenuTitle: 'Delay',
|
|
64
|
+
group: ['Logic'],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
#getInputPortCount(connections) {
|
|
68
|
+
const inputNodeId = this.chartNode.id;
|
|
69
|
+
const inputConnections = connections.filter((connection) => connection.inputNodeId === inputNodeId && connection.inputId.startsWith('input'));
|
|
70
|
+
let maxInputNumber = 0;
|
|
71
|
+
for (const connection of inputConnections) {
|
|
72
|
+
const messageNumber = parseInt(connection.inputId.replace('input', ''), 10);
|
|
73
|
+
if (messageNumber > maxInputNumber) {
|
|
74
|
+
maxInputNumber = messageNumber;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return maxInputNumber + 1;
|
|
78
|
+
}
|
|
79
|
+
getEditors() {
|
|
80
|
+
return [
|
|
81
|
+
{
|
|
82
|
+
type: 'number',
|
|
83
|
+
label: 'Delay (ms)',
|
|
84
|
+
dataKey: 'delay',
|
|
85
|
+
useInputToggleDataKey: 'useDelayInput',
|
|
86
|
+
defaultValue: 0,
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
getBody() {
|
|
91
|
+
return `Delay ${this.data.useDelayInput ? '(Input ms)' : `${this.chartNode.data.delay}ms`}`;
|
|
92
|
+
}
|
|
93
|
+
async process(inputData) {
|
|
94
|
+
const delayAmount = getInputOrData(this.data, inputData, 'delay', 'number');
|
|
95
|
+
await new Promise((resolve) => setTimeout(resolve, delayAmount));
|
|
96
|
+
const inputCount = Object.keys(inputData).filter((key) => key.startsWith('input')).length;
|
|
97
|
+
const outputs = {};
|
|
98
|
+
for (let i = 1; i <= inputCount; i++) {
|
|
99
|
+
const input = inputData[`input${i}`];
|
|
100
|
+
outputs[`output${i}`] = input;
|
|
101
|
+
}
|
|
102
|
+
return outputs;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export const delayNode = nodeDefinition(DelayNodeImpl, 'Delay');
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { nanoid } from 'nanoid';
|
|
2
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
3
|
+
import { dedent } from 'ts-dedent';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import { coerceType, coerceTypeOptional } from '../../utils/coerceType.js';
|
|
6
|
+
export class DelegateFunctionCallNodeImpl extends NodeImpl {
|
|
7
|
+
static create() {
|
|
8
|
+
const chartNode = {
|
|
9
|
+
type: 'delegateFunctionCall',
|
|
10
|
+
title: 'Delegate Function Call',
|
|
11
|
+
id: nanoid(),
|
|
12
|
+
visualData: {
|
|
13
|
+
x: 0,
|
|
14
|
+
y: 0,
|
|
15
|
+
width: 325,
|
|
16
|
+
},
|
|
17
|
+
data: {
|
|
18
|
+
handlers: [],
|
|
19
|
+
unknownHandler: undefined,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
return chartNode;
|
|
23
|
+
}
|
|
24
|
+
getInputDefinitions() {
|
|
25
|
+
const inputs = [];
|
|
26
|
+
inputs.push({
|
|
27
|
+
id: 'function-call',
|
|
28
|
+
dataType: 'object',
|
|
29
|
+
title: 'Function Call',
|
|
30
|
+
coerced: true,
|
|
31
|
+
required: true,
|
|
32
|
+
description: 'The function call to delegate to a subgraph.',
|
|
33
|
+
});
|
|
34
|
+
return inputs;
|
|
35
|
+
}
|
|
36
|
+
getOutputDefinitions() {
|
|
37
|
+
const outputs = [];
|
|
38
|
+
outputs.push({
|
|
39
|
+
id: 'output',
|
|
40
|
+
dataType: 'string',
|
|
41
|
+
title: 'Output',
|
|
42
|
+
description: 'The output of the function call.',
|
|
43
|
+
});
|
|
44
|
+
outputs.push({
|
|
45
|
+
id: 'message',
|
|
46
|
+
dataType: 'object',
|
|
47
|
+
title: 'Message Output',
|
|
48
|
+
description: 'Maps the output for use directly with an Assemble Prompt node and GPT.',
|
|
49
|
+
});
|
|
50
|
+
return outputs;
|
|
51
|
+
}
|
|
52
|
+
static getUIData() {
|
|
53
|
+
return {
|
|
54
|
+
infoBoxBody: dedent `
|
|
55
|
+
Handles a function call by delegating it to a different subgraph depending on the function call.
|
|
56
|
+
`,
|
|
57
|
+
infoBoxTitle: 'Delegate Function Call Node',
|
|
58
|
+
contextMenuTitle: 'Delegate Function Call',
|
|
59
|
+
group: ['Advanced'],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
getEditors() {
|
|
63
|
+
return [
|
|
64
|
+
{
|
|
65
|
+
type: 'custom',
|
|
66
|
+
customEditorId: 'ToolCallHandlers',
|
|
67
|
+
label: 'Handlers',
|
|
68
|
+
dataKey: 'handlers',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: 'graphSelector',
|
|
72
|
+
dataKey: 'unknownHandler',
|
|
73
|
+
label: 'Unknown Handler',
|
|
74
|
+
helperMessage: 'The subgraph to delegate to if the function call does not match any handlers.',
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
getBody(context) {
|
|
79
|
+
if (this.data.handlers.length === 0) {
|
|
80
|
+
return 'No handlers defined';
|
|
81
|
+
}
|
|
82
|
+
const lines = ['Handlers:'];
|
|
83
|
+
this.data.handlers.forEach(({ key, value }) => {
|
|
84
|
+
const subgraphName = context.project.graphs[value]?.metadata.name ?? 'Unknown Subgraph';
|
|
85
|
+
lines.push(` ${key || '(MISSING!)'} -> ${subgraphName}`);
|
|
86
|
+
});
|
|
87
|
+
return lines.join('\n');
|
|
88
|
+
}
|
|
89
|
+
async process(inputs, context) {
|
|
90
|
+
const functionCall = coerceType(inputs['function-call'], 'object');
|
|
91
|
+
let handler = this.data.handlers.find((handler) => handler.key === functionCall.name);
|
|
92
|
+
if (!handler) {
|
|
93
|
+
if (this.data.unknownHandler) {
|
|
94
|
+
handler = { key: undefined, value: this.data.unknownHandler };
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
throw new Error(`No handler found for function call: ${functionCall.name}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const subgraphInputs = {
|
|
101
|
+
_function_name: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
value: functionCall.name,
|
|
104
|
+
},
|
|
105
|
+
_arguments: {
|
|
106
|
+
type: 'object',
|
|
107
|
+
value: functionCall.arguments,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
for (const [argName, argument] of Object.entries(functionCall.arguments)) {
|
|
111
|
+
subgraphInputs[argName] = {
|
|
112
|
+
type: 'any',
|
|
113
|
+
value: argument,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const handlerGraphId = handler.value;
|
|
117
|
+
const subprocessor = context.createSubProcessor(handlerGraphId, { signal: context.signal });
|
|
118
|
+
const outputs = await subprocessor.processGraph(context, subgraphInputs, context.contextValues);
|
|
119
|
+
const outputString = coerceTypeOptional(outputs.output, 'string') ?? '';
|
|
120
|
+
return {
|
|
121
|
+
['output']: {
|
|
122
|
+
type: 'string',
|
|
123
|
+
value: outputString,
|
|
124
|
+
},
|
|
125
|
+
['message']: {
|
|
126
|
+
type: 'chat-message',
|
|
127
|
+
value: {
|
|
128
|
+
type: 'function',
|
|
129
|
+
message: outputString,
|
|
130
|
+
name: functionCall.id ?? '',
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export const delegateFunctionCallNode = nodeDefinition(DelegateFunctionCallNodeImpl, 'Delegate Function Call');
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {} from '../NodeBase.js';
|
|
2
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
3
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
4
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
5
|
+
import {} from '../DataValue.js';
|
|
6
|
+
import { JSONPath } from 'jsonpath-plus';
|
|
7
|
+
import {} from '../../index.js';
|
|
8
|
+
import { dedent } from 'ts-dedent';
|
|
9
|
+
import { coerceTypeOptional } from '../../utils/coerceType.js';
|
|
10
|
+
export class DestructureNodeImpl extends NodeImpl {
|
|
11
|
+
static create() {
|
|
12
|
+
const chartNode = {
|
|
13
|
+
type: 'destructure',
|
|
14
|
+
title: 'Destructure',
|
|
15
|
+
id: nanoid(),
|
|
16
|
+
visualData: {
|
|
17
|
+
x: 0,
|
|
18
|
+
y: 0,
|
|
19
|
+
width: 250,
|
|
20
|
+
},
|
|
21
|
+
data: {
|
|
22
|
+
paths: ['$.value'],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
return chartNode;
|
|
26
|
+
}
|
|
27
|
+
getInputDefinitions() {
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
id: 'object',
|
|
31
|
+
title: 'Object',
|
|
32
|
+
dataType: 'object',
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
getOutputDefinitions() {
|
|
38
|
+
return this.chartNode.data.paths.map((path, index) => ({
|
|
39
|
+
id: `match_${index}`,
|
|
40
|
+
title: path,
|
|
41
|
+
dataType: 'any',
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
getEditors() {
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
type: 'stringList',
|
|
48
|
+
label: 'Paths',
|
|
49
|
+
dataKey: 'paths',
|
|
50
|
+
helperMessage: 'One or more JSONPath expressions. Each expression will correspond to an output port of the node.',
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
getBody() {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
static getUIData() {
|
|
58
|
+
return {
|
|
59
|
+
infoBoxBody: dedent `
|
|
60
|
+
Destructures the input value by extracting values at the specified paths. The paths use JSONPath notation to navigate through the value.
|
|
61
|
+
`,
|
|
62
|
+
infoBoxTitle: 'Destructure Node',
|
|
63
|
+
contextMenuTitle: 'Destructure',
|
|
64
|
+
group: ['Objects'],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async process(inputs) {
|
|
68
|
+
const inputObject = coerceTypeOptional(inputs['object'], 'object');
|
|
69
|
+
const output = {};
|
|
70
|
+
this.data.paths.forEach((path, index) => {
|
|
71
|
+
let match;
|
|
72
|
+
try {
|
|
73
|
+
match = JSONPath({ json: inputObject ?? null, path: path.trim(), wrap: false });
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
match = undefined;
|
|
77
|
+
}
|
|
78
|
+
output[`match_${index}`] = {
|
|
79
|
+
type: 'any',
|
|
80
|
+
value: match,
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
return output;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export const destructureNode = nodeDefinition(DestructureNodeImpl, 'Destructure');
|