@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.
Files changed (381) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +176 -0
  3. package/dist/cjs/bundle.cjs +18915 -0
  4. package/dist/cjs/bundle.cjs.map +7 -0
  5. package/dist/esm/api/createProcessor.js +131 -0
  6. package/dist/esm/api/streaming.js +116 -0
  7. package/dist/esm/exports.js +32 -0
  8. package/dist/esm/index.js +2 -0
  9. package/dist/esm/integrations/AudioProvider.js +1 -0
  10. package/dist/esm/integrations/DatasetProvider.js +92 -0
  11. package/dist/esm/integrations/EmbeddingGenerator.js +1 -0
  12. package/dist/esm/integrations/GptTokenizerTokenizer.js +65 -0
  13. package/dist/esm/integrations/LLMProvider.js +1 -0
  14. package/dist/esm/integrations/Tokenizer.js +1 -0
  15. package/dist/esm/integrations/VectorDatabase.js +1 -0
  16. package/dist/esm/integrations/enableIntegrations.js +3 -0
  17. package/dist/esm/integrations/integrations.js +19 -0
  18. package/dist/esm/integrations/openai/OpenAIEmbeddingGenerator.js +23 -0
  19. package/dist/esm/model/DataValue.js +176 -0
  20. package/dist/esm/model/Dataset.js +1 -0
  21. package/dist/esm/model/EditorDefinition.js +1 -0
  22. package/dist/esm/model/GraphProcessor.js +1198 -0
  23. package/dist/esm/model/NodeBase.js +1 -0
  24. package/dist/esm/model/NodeBodySpec.js +1 -0
  25. package/dist/esm/model/NodeDefinition.js +12 -0
  26. package/dist/esm/model/NodeGraph.js +14 -0
  27. package/dist/esm/model/NodeImpl.js +49 -0
  28. package/dist/esm/model/NodeRegistration.js +144 -0
  29. package/dist/esm/model/Nodes.js +227 -0
  30. package/dist/esm/model/PluginLoadSpec.js +1 -0
  31. package/dist/esm/model/ProcessContext.js +1 -0
  32. package/dist/esm/model/Project.js +2 -0
  33. package/dist/esm/model/RivetPlugin.js +1 -0
  34. package/dist/esm/model/RivetUIContext.js +1 -0
  35. package/dist/esm/model/Settings.js +1 -0
  36. package/dist/esm/model/nodes/AbortGraphNode.js +100 -0
  37. package/dist/esm/model/nodes/AppendToDatasetNode.js +115 -0
  38. package/dist/esm/model/nodes/ArrayNode.js +144 -0
  39. package/dist/esm/model/nodes/AssembleMessageNode.js +199 -0
  40. package/dist/esm/model/nodes/AssemblePromptNode.js +129 -0
  41. package/dist/esm/model/nodes/AudioNode.js +101 -0
  42. package/dist/esm/model/nodes/BooleanNode.js +74 -0
  43. package/dist/esm/model/nodes/CallGraphNode.js +136 -0
  44. package/dist/esm/model/nodes/ChatNode.js +964 -0
  45. package/dist/esm/model/nodes/ChunkNode.js +166 -0
  46. package/dist/esm/model/nodes/CoalesceNode.js +104 -0
  47. package/dist/esm/model/nodes/CodeNode.js +136 -0
  48. package/dist/esm/model/nodes/CommentNode.js +69 -0
  49. package/dist/esm/model/nodes/CompareNode.js +138 -0
  50. package/dist/esm/model/nodes/ContextNode.js +99 -0
  51. package/dist/esm/model/nodes/CreateDatasetNode.js +71 -0
  52. package/dist/esm/model/nodes/DatasetNearestNeigborsNode.js +97 -0
  53. package/dist/esm/model/nodes/DelayNode.js +105 -0
  54. package/dist/esm/model/nodes/DelegateFunctionCallNode.js +136 -0
  55. package/dist/esm/model/nodes/DestructureNode.js +86 -0
  56. package/dist/esm/model/nodes/EvaluateNode.js +141 -0
  57. package/dist/esm/model/nodes/ExternalCallNode.js +162 -0
  58. package/dist/esm/model/nodes/ExtractJsonNode.js +122 -0
  59. package/dist/esm/model/nodes/ExtractMarkdownCodeBlocksNode.js +100 -0
  60. package/dist/esm/model/nodes/ExtractObjectPathNode.js +128 -0
  61. package/dist/esm/model/nodes/ExtractRegexNode.js +201 -0
  62. package/dist/esm/model/nodes/ExtractYamlNode.js +214 -0
  63. package/dist/esm/model/nodes/FilterNode.js +73 -0
  64. package/dist/esm/model/nodes/GetAllDatasetsNode.js +53 -0
  65. package/dist/esm/model/nodes/GetDatasetRowNode.js +99 -0
  66. package/dist/esm/model/nodes/GetEmbeddingNode.js +130 -0
  67. package/dist/esm/model/nodes/GetGlobalNode.js +139 -0
  68. package/dist/esm/model/nodes/GptFunctionNode.js +169 -0
  69. package/dist/esm/model/nodes/GraphInputNode.js +130 -0
  70. package/dist/esm/model/nodes/GraphOutputNode.js +104 -0
  71. package/dist/esm/model/nodes/GraphReferenceNode.js +128 -0
  72. package/dist/esm/model/nodes/HashNode.js +97 -0
  73. package/dist/esm/model/nodes/HttpCallNode.js +257 -0
  74. package/dist/esm/model/nodes/IfElseNode.js +138 -0
  75. package/dist/esm/model/nodes/IfNode.js +124 -0
  76. package/dist/esm/model/nodes/ImageNode.js +107 -0
  77. package/dist/esm/model/nodes/JoinNode.js +135 -0
  78. package/dist/esm/model/nodes/ListGraphsNode.js +61 -0
  79. package/dist/esm/model/nodes/LoadDatasetNode.js +83 -0
  80. package/dist/esm/model/nodes/LoopControllerNode.js +206 -0
  81. package/dist/esm/model/nodes/MatchNode.js +137 -0
  82. package/dist/esm/model/nodes/NumberNode.js +86 -0
  83. package/dist/esm/model/nodes/ObjectNode.js +121 -0
  84. package/dist/esm/model/nodes/PassthroughNode.js +78 -0
  85. package/dist/esm/model/nodes/PlayAudioNode.js +61 -0
  86. package/dist/esm/model/nodes/PopNode.js +89 -0
  87. package/dist/esm/model/nodes/PromptNode.js +227 -0
  88. package/dist/esm/model/nodes/RaceInputsNode.js +86 -0
  89. package/dist/esm/model/nodes/RaiseEventNode.js +84 -0
  90. package/dist/esm/model/nodes/RandomNumberNode.js +106 -0
  91. package/dist/esm/model/nodes/ReadDirectoryNode.js +165 -0
  92. package/dist/esm/model/nodes/ReadFileNode.js +114 -0
  93. package/dist/esm/model/nodes/ReplaceDatasetNode.js +118 -0
  94. package/dist/esm/model/nodes/SetGlobalNode.js +124 -0
  95. package/dist/esm/model/nodes/ShuffleNode.js +64 -0
  96. package/dist/esm/model/nodes/SliceNode.js +100 -0
  97. package/dist/esm/model/nodes/SplitNode.js +101 -0
  98. package/dist/esm/model/nodes/SubGraphNode.js +181 -0
  99. package/dist/esm/model/nodes/TextNode.js +97 -0
  100. package/dist/esm/model/nodes/ToJsonNode.js +78 -0
  101. package/dist/esm/model/nodes/ToYamlNode.js +68 -0
  102. package/dist/esm/model/nodes/TrimChatMessagesNode.js +120 -0
  103. package/dist/esm/model/nodes/URLReferenceNode.js +79 -0
  104. package/dist/esm/model/nodes/UserInputNode.js +111 -0
  105. package/dist/esm/model/nodes/VectorNearestNeighborsNode.js +127 -0
  106. package/dist/esm/model/nodes/VectorStoreNode.js +124 -0
  107. package/dist/esm/model/nodes/WaitForEventNode.js +88 -0
  108. package/dist/esm/native/BaseDir.js +32 -0
  109. package/dist/esm/native/BrowserNativeApi.js +19 -0
  110. package/dist/esm/native/NativeApi.js +1 -0
  111. package/dist/esm/plugins/aidon/index.js +2 -0
  112. package/dist/esm/plugins/aidon/nodes/ChatAidonNode.js +215 -0
  113. package/dist/esm/plugins/aidon/plugin.js +9 -0
  114. package/dist/esm/plugins/anthropic/anthropic.js +187 -0
  115. package/dist/esm/plugins/anthropic/fetchEventSource.js +106 -0
  116. package/dist/esm/plugins/anthropic/index.js +2 -0
  117. package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +652 -0
  118. package/dist/esm/plugins/anthropic/plugin.js +18 -0
  119. package/dist/esm/plugins/assemblyAi/LemurActionItemsNode.js +75 -0
  120. package/dist/esm/plugins/assemblyAi/LemurQaNode.js +155 -0
  121. package/dist/esm/plugins/assemblyAi/LemurSummaryNode.js +79 -0
  122. package/dist/esm/plugins/assemblyAi/LemurTaskNode.js +82 -0
  123. package/dist/esm/plugins/assemblyAi/TranscribeAudioNode.js +125 -0
  124. package/dist/esm/plugins/assemblyAi/index.js +2 -0
  125. package/dist/esm/plugins/assemblyAi/lemurHelpers.js +114 -0
  126. package/dist/esm/plugins/assemblyAi/plugin.js +32 -0
  127. package/dist/esm/plugins/autoevals/AutoEvalsNode.js +223 -0
  128. package/dist/esm/plugins/autoevals/index.js +2 -0
  129. package/dist/esm/plugins/autoevals/plugin.js +8 -0
  130. package/dist/esm/plugins/gentrace/index.js +2 -0
  131. package/dist/esm/plugins/gentrace/plugin.js +192 -0
  132. package/dist/esm/plugins/google/google.js +60 -0
  133. package/dist/esm/plugins/google/index.js +2 -0
  134. package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +364 -0
  135. package/dist/esm/plugins/google/plugin.js +32 -0
  136. package/dist/esm/plugins/huggingface/index.js +2 -0
  137. package/dist/esm/plugins/huggingface/nodes/ChatHuggingFace.js +243 -0
  138. package/dist/esm/plugins/huggingface/nodes/TextToImageHuggingFace.js +189 -0
  139. package/dist/esm/plugins/huggingface/plugin.js +26 -0
  140. package/dist/esm/plugins/openai/handleOpenaiError.js +17 -0
  141. package/dist/esm/plugins/openai/index.js +2 -0
  142. package/dist/esm/plugins/openai/nodes/AttachAssistantFileNode.js +123 -0
  143. package/dist/esm/plugins/openai/nodes/CreateAssistantNode.js +289 -0
  144. package/dist/esm/plugins/openai/nodes/CreateThreadMessageNode.js +176 -0
  145. package/dist/esm/plugins/openai/nodes/CreateThreadNode.js +157 -0
  146. package/dist/esm/plugins/openai/nodes/DeleteAssistantNode.js +104 -0
  147. package/dist/esm/plugins/openai/nodes/DeleteThreadNode.js +97 -0
  148. package/dist/esm/plugins/openai/nodes/GetAssistantNode.js +118 -0
  149. package/dist/esm/plugins/openai/nodes/GetOpenAIFileNode.js +100 -0
  150. package/dist/esm/plugins/openai/nodes/GetThreadNode.js +108 -0
  151. package/dist/esm/plugins/openai/nodes/ListAssistantsNode.js +202 -0
  152. package/dist/esm/plugins/openai/nodes/ListOpenAIFilesNode.js +94 -0
  153. package/dist/esm/plugins/openai/nodes/ListThreadMessagesNode.js +224 -0
  154. package/dist/esm/plugins/openai/nodes/RunThreadNode.js +630 -0
  155. package/dist/esm/plugins/openai/nodes/ThreadMessageNode.js +145 -0
  156. package/dist/esm/plugins/openai/nodes/UploadFileNode.js +121 -0
  157. package/dist/esm/plugins/openai/plugin.js +44 -0
  158. package/dist/esm/plugins/pinecone/PineconeVectorDatabase.js +88 -0
  159. package/dist/esm/plugins/pinecone/index.js +2 -0
  160. package/dist/esm/plugins/pinecone/plugin.js +19 -0
  161. package/dist/esm/plugins.js +21 -0
  162. package/dist/esm/recording/ExecutionRecorder.js +177 -0
  163. package/dist/esm/recording/RecordedEvents.js +1 -0
  164. package/dist/esm/utils/assertNever.js +3 -0
  165. package/dist/esm/utils/base64.js +25 -0
  166. package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +60 -0
  167. package/dist/esm/utils/coerceType.js +322 -0
  168. package/dist/esm/utils/compatibility.js +27 -0
  169. package/dist/esm/utils/copyToClipboard.js +10 -0
  170. package/dist/esm/utils/defaults.js +2 -0
  171. package/dist/esm/utils/errors.js +7 -0
  172. package/dist/esm/utils/expectType.js +34 -0
  173. package/dist/esm/utils/fetchEventSource.js +120 -0
  174. package/dist/esm/utils/genericUtilFunctions.js +25 -0
  175. package/dist/esm/utils/getPluginConfig.js +23 -0
  176. package/dist/esm/utils/handleEscapeCharacters.js +11 -0
  177. package/dist/esm/utils/index.js +14 -0
  178. package/dist/esm/utils/inputs.js +16 -0
  179. package/dist/esm/utils/interpolation.js +6 -0
  180. package/dist/esm/utils/misc.js +1 -0
  181. package/dist/esm/utils/newId.js +4 -0
  182. package/dist/esm/utils/openai.js +219 -0
  183. package/dist/esm/utils/outputs.js +14 -0
  184. package/dist/esm/utils/serialization/serialization.js +86 -0
  185. package/dist/esm/utils/serialization/serializationUtils.js +13 -0
  186. package/dist/esm/utils/serialization/serialization_v1.js +19 -0
  187. package/dist/esm/utils/serialization/serialization_v2.js +24 -0
  188. package/dist/esm/utils/serialization/serialization_v3.js +145 -0
  189. package/dist/esm/utils/serialization/serialization_v4.js +200 -0
  190. package/dist/esm/utils/symbols.js +2 -0
  191. package/dist/esm/utils/time.js +14 -0
  192. package/dist/esm/utils/typeSafety.js +42 -0
  193. package/dist/types/api/createProcessor.d.ts +37 -0
  194. package/dist/types/api/streaming.d.ts +56 -0
  195. package/dist/types/exports.d.ts +33 -0
  196. package/dist/types/index.d.ts +4 -0
  197. package/dist/types/integrations/AudioProvider.d.ts +4 -0
  198. package/dist/types/integrations/DatasetProvider.d.ts +33 -0
  199. package/dist/types/integrations/EmbeddingGenerator.d.ts +3 -0
  200. package/dist/types/integrations/GptTokenizerTokenizer.d.ts +20 -0
  201. package/dist/types/integrations/LLMProvider.d.ts +7 -0
  202. package/dist/types/integrations/Tokenizer.d.ts +11 -0
  203. package/dist/types/integrations/VectorDatabase.d.ts +7 -0
  204. package/dist/types/integrations/enableIntegrations.d.ts +1 -0
  205. package/dist/types/integrations/integrations.d.ts +12 -0
  206. package/dist/types/integrations/openai/OpenAIEmbeddingGenerator.d.ts +10 -0
  207. package/dist/types/model/DataValue.d.ts +138 -0
  208. package/dist/types/model/Dataset.d.ts +19 -0
  209. package/dist/types/model/EditorDefinition.d.ts +142 -0
  210. package/dist/types/model/GraphProcessor.d.ts +192 -0
  211. package/dist/types/model/NodeBase.d.ts +110 -0
  212. package/dist/types/model/NodeBodySpec.d.ts +19 -0
  213. package/dist/types/model/NodeDefinition.d.ts +13 -0
  214. package/dist/types/model/NodeGraph.d.ts +15 -0
  215. package/dist/types/model/NodeImpl.d.ts +55 -0
  216. package/dist/types/model/NodeRegistration.d.ts +24 -0
  217. package/dist/types/model/Nodes.d.ts +84 -0
  218. package/dist/types/model/PluginLoadSpec.d.ts +17 -0
  219. package/dist/types/model/ProcessContext.d.ts +69 -0
  220. package/dist/types/model/Project.d.ts +17 -0
  221. package/dist/types/model/RivetPlugin.d.ts +45 -0
  222. package/dist/types/model/RivetUIContext.d.ts +18 -0
  223. package/dist/types/model/Settings.d.ts +15 -0
  224. package/dist/types/model/nodes/AbortGraphNode.d.ts +22 -0
  225. package/dist/types/model/nodes/AppendToDatasetNode.d.ts +21 -0
  226. package/dist/types/model/nodes/ArrayNode.d.ts +20 -0
  227. package/dist/types/model/nodes/AssembleMessageNode.d.ts +23 -0
  228. package/dist/types/model/nodes/AssemblePromptNode.d.ts +20 -0
  229. package/dist/types/model/nodes/AudioNode.d.ts +20 -0
  230. package/dist/types/model/nodes/BooleanNode.d.ts +19 -0
  231. package/dist/types/model/nodes/CallGraphNode.d.ts +16 -0
  232. package/dist/types/model/nodes/ChatNode.d.ts +77 -0
  233. package/dist/types/model/nodes/ChunkNode.d.ts +22 -0
  234. package/dist/types/model/nodes/CoalesceNode.d.ts +14 -0
  235. package/dist/types/model/nodes/CodeNode.d.ts +21 -0
  236. package/dist/types/model/nodes/CommentNode.d.ts +20 -0
  237. package/dist/types/model/nodes/CompareNode.d.ts +19 -0
  238. package/dist/types/model/nodes/ContextNode.d.ts +24 -0
  239. package/dist/types/model/nodes/CreateDatasetNode.d.ts +13 -0
  240. package/dist/types/model/nodes/DatasetNearestNeigborsNode.d.ts +19 -0
  241. package/dist/types/model/nodes/DelayNode.d.ts +20 -0
  242. package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +25 -0
  243. package/dist/types/model/nodes/DestructureNode.d.ts +18 -0
  244. package/dist/types/model/nodes/EvaluateNode.d.ts +19 -0
  245. package/dist/types/model/nodes/ExternalCallNode.d.ts +22 -0
  246. package/dist/types/model/nodes/ExtractJsonNode.d.ts +13 -0
  247. package/dist/types/model/nodes/ExtractMarkdownCodeBlocksNode.d.ts +12 -0
  248. package/dist/types/model/nodes/ExtractObjectPathNode.d.ts +19 -0
  249. package/dist/types/model/nodes/ExtractRegexNode.d.ts +22 -0
  250. package/dist/types/model/nodes/ExtractYamlNode.d.ts +21 -0
  251. package/dist/types/model/nodes/FilterNode.d.ts +13 -0
  252. package/dist/types/model/nodes/GetAllDatasetsNode.d.ts +14 -0
  253. package/dist/types/model/nodes/GetDatasetRowNode.d.ts +19 -0
  254. package/dist/types/model/nodes/GetEmbeddingNode.d.ts +24 -0
  255. package/dist/types/model/nodes/GetGlobalNode.d.ts +29 -0
  256. package/dist/types/model/nodes/GptFunctionNode.d.ts +25 -0
  257. package/dist/types/model/nodes/GraphInputNode.d.ts +24 -0
  258. package/dist/types/model/nodes/GraphOutputNode.d.ts +22 -0
  259. package/dist/types/model/nodes/GraphReferenceNode.d.ts +22 -0
  260. package/dist/types/model/nodes/HashNode.d.ts +17 -0
  261. package/dist/types/model/nodes/HttpCallNode.d.ts +27 -0
  262. package/dist/types/model/nodes/IfElseNode.d.ts +18 -0
  263. package/dist/types/model/nodes/IfNode.d.ts +17 -0
  264. package/dist/types/model/nodes/ImageNode.d.ts +20 -0
  265. package/dist/types/model/nodes/JoinNode.d.ts +21 -0
  266. package/dist/types/model/nodes/ListGraphsNode.d.ts +14 -0
  267. package/dist/types/model/nodes/LoadDatasetNode.d.ts +17 -0
  268. package/dist/types/model/nodes/LoopControllerNode.d.ts +20 -0
  269. package/dist/types/model/nodes/MatchNode.d.ts +19 -0
  270. package/dist/types/model/nodes/NumberNode.d.ts +21 -0
  271. package/dist/types/model/nodes/ObjectNode.d.ts +18 -0
  272. package/dist/types/model/nodes/PassthroughNode.d.ts +14 -0
  273. package/dist/types/model/nodes/PlayAudioNode.d.ts +15 -0
  274. package/dist/types/model/nodes/PopNode.d.ts +19 -0
  275. package/dist/types/model/nodes/PromptNode.d.ts +23 -0
  276. package/dist/types/model/nodes/RaceInputsNode.d.ts +17 -0
  277. package/dist/types/model/nodes/RaiseEventNode.d.ts +22 -0
  278. package/dist/types/model/nodes/RandomNumberNode.d.ts +23 -0
  279. package/dist/types/model/nodes/ReadDirectoryNode.d.ts +30 -0
  280. package/dist/types/model/nodes/ReadFileNode.d.ts +23 -0
  281. package/dist/types/model/nodes/ReplaceDatasetNode.d.ts +21 -0
  282. package/dist/types/model/nodes/SetGlobalNode.d.ts +23 -0
  283. package/dist/types/model/nodes/ShuffleNode.d.ts +12 -0
  284. package/dist/types/model/nodes/SliceNode.d.ts +22 -0
  285. package/dist/types/model/nodes/SplitNode.d.ts +19 -0
  286. package/dist/types/model/nodes/SubGraphNode.d.ts +29 -0
  287. package/dist/types/model/nodes/TextNode.d.ts +18 -0
  288. package/dist/types/model/nodes/ToJsonNode.d.ts +18 -0
  289. package/dist/types/model/nodes/ToYamlNode.d.ts +13 -0
  290. package/dist/types/model/nodes/TrimChatMessagesNode.d.ts +20 -0
  291. package/dist/types/model/nodes/URLReferenceNode.d.ts +19 -0
  292. package/dist/types/model/nodes/UserInputNode.d.ts +21 -0
  293. package/dist/types/model/nodes/VectorNearestNeighborsNode.d.ts +24 -0
  294. package/dist/types/model/nodes/VectorStoreNode.d.ts +22 -0
  295. package/dist/types/model/nodes/WaitForEventNode.d.ts +21 -0
  296. package/dist/types/native/BaseDir.d.ts +29 -0
  297. package/dist/types/native/BrowserNativeApi.d.ts +11 -0
  298. package/dist/types/native/NativeApi.d.ts +17 -0
  299. package/dist/types/plugins/aidon/index.d.ts +2 -0
  300. package/dist/types/plugins/aidon/nodes/ChatAidonNode.d.ts +3 -0
  301. package/dist/types/plugins/aidon/plugin.d.ts +2 -0
  302. package/dist/types/plugins/anthropic/anthropic.d.ts +216 -0
  303. package/dist/types/plugins/anthropic/fetchEventSource.d.ts +11 -0
  304. package/dist/types/plugins/anthropic/index.d.ts +2 -0
  305. package/dist/types/plugins/anthropic/nodes/ChatAnthropicNode.d.ts +30 -0
  306. package/dist/types/plugins/anthropic/plugin.d.ts +2 -0
  307. package/dist/types/plugins/assemblyAi/LemurActionItemsNode.d.ts +6 -0
  308. package/dist/types/plugins/assemblyAi/LemurQaNode.d.ts +22 -0
  309. package/dist/types/plugins/assemblyAi/LemurSummaryNode.d.ts +8 -0
  310. package/dist/types/plugins/assemblyAi/LemurTaskNode.d.ts +8 -0
  311. package/dist/types/plugins/assemblyAi/TranscribeAudioNode.d.ts +7 -0
  312. package/dist/types/plugins/assemblyAi/index.d.ts +2 -0
  313. package/dist/types/plugins/assemblyAi/lemurHelpers.d.ts +67 -0
  314. package/dist/types/plugins/assemblyAi/plugin.d.ts +2 -0
  315. package/dist/types/plugins/autoevals/AutoEvalsNode.d.ts +8 -0
  316. package/dist/types/plugins/autoevals/index.d.ts +2 -0
  317. package/dist/types/plugins/autoevals/plugin.d.ts +2 -0
  318. package/dist/types/plugins/gentrace/index.d.ts +2 -0
  319. package/dist/types/plugins/gentrace/plugin.d.ts +5 -0
  320. package/dist/types/plugins/google/google.d.ts +60 -0
  321. package/dist/types/plugins/google/index.d.ts +2 -0
  322. package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +27 -0
  323. package/dist/types/plugins/google/plugin.d.ts +2 -0
  324. package/dist/types/plugins/huggingface/index.d.ts +2 -0
  325. package/dist/types/plugins/huggingface/nodes/ChatHuggingFace.d.ts +24 -0
  326. package/dist/types/plugins/huggingface/nodes/TextToImageHuggingFace.d.ts +20 -0
  327. package/dist/types/plugins/huggingface/plugin.d.ts +2 -0
  328. package/dist/types/plugins/openai/handleOpenaiError.d.ts +1 -0
  329. package/dist/types/plugins/openai/index.d.ts +2 -0
  330. package/dist/types/plugins/openai/nodes/AttachAssistantFileNode.d.ts +10 -0
  331. package/dist/types/plugins/openai/nodes/CreateAssistantNode.d.ts +26 -0
  332. package/dist/types/plugins/openai/nodes/CreateThreadMessageNode.d.ts +15 -0
  333. package/dist/types/plugins/openai/nodes/CreateThreadNode.d.ts +13 -0
  334. package/dist/types/plugins/openai/nodes/DeleteAssistantNode.d.ts +8 -0
  335. package/dist/types/plugins/openai/nodes/DeleteThreadNode.d.ts +8 -0
  336. package/dist/types/plugins/openai/nodes/GetAssistantNode.d.ts +8 -0
  337. package/dist/types/plugins/openai/nodes/GetOpenAIFileNode.d.ts +8 -0
  338. package/dist/types/plugins/openai/nodes/GetThreadNode.d.ts +8 -0
  339. package/dist/types/plugins/openai/nodes/ListAssistantsNode.d.ts +14 -0
  340. package/dist/types/plugins/openai/nodes/ListOpenAIFilesNode.d.ts +8 -0
  341. package/dist/types/plugins/openai/nodes/ListThreadMessagesNode.d.ts +16 -0
  342. package/dist/types/plugins/openai/nodes/RunThreadNode.d.ts +28 -0
  343. package/dist/types/plugins/openai/nodes/ThreadMessageNode.d.ts +14 -0
  344. package/dist/types/plugins/openai/nodes/UploadFileNode.d.ts +7 -0
  345. package/dist/types/plugins/openai/plugin.d.ts +2 -0
  346. package/dist/types/plugins/pinecone/PineconeVectorDatabase.d.ts +9 -0
  347. package/dist/types/plugins/pinecone/index.d.ts +2 -0
  348. package/dist/types/plugins/pinecone/plugin.d.ts +2 -0
  349. package/dist/types/plugins.d.ts +20 -0
  350. package/dist/types/recording/ExecutionRecorder.d.ts +25 -0
  351. package/dist/types/recording/RecordedEvents.d.ts +100 -0
  352. package/dist/types/utils/assertNever.d.ts +1 -0
  353. package/dist/types/utils/base64.d.ts +2 -0
  354. package/dist/types/utils/chatMessageToOpenAIChatCompletionMessage.d.ts +3 -0
  355. package/dist/types/utils/coerceType.d.ts +6 -0
  356. package/dist/types/utils/compatibility.d.ts +3 -0
  357. package/dist/types/utils/copyToClipboard.d.ts +1 -0
  358. package/dist/types/utils/defaults.d.ts +2 -0
  359. package/dist/types/utils/errors.d.ts +2 -0
  360. package/dist/types/utils/expectType.d.ts +3 -0
  361. package/dist/types/utils/fetchEventSource.d.ts +12 -0
  362. package/dist/types/utils/genericUtilFunctions.d.ts +21 -0
  363. package/dist/types/utils/getPluginConfig.d.ts +2 -0
  364. package/dist/types/utils/handleEscapeCharacters.d.ts +2 -0
  365. package/dist/types/utils/index.d.ts +14 -0
  366. package/dist/types/utils/inputs.d.ts +3 -0
  367. package/dist/types/utils/interpolation.d.ts +1 -0
  368. package/dist/types/utils/misc.d.ts +1 -0
  369. package/dist/types/utils/newId.d.ts +1 -0
  370. package/dist/types/utils/openai.d.ts +739 -0
  371. package/dist/types/utils/outputs.d.ts +3 -0
  372. package/dist/types/utils/serialization/serialization.d.ts +12 -0
  373. package/dist/types/utils/serialization/serializationUtils.d.ts +6 -0
  374. package/dist/types/utils/serialization/serialization_v1.d.ts +3 -0
  375. package/dist/types/utils/serialization/serialization_v2.d.ts +3 -0
  376. package/dist/types/utils/serialization/serialization_v3.d.ts +19 -0
  377. package/dist/types/utils/serialization/serialization_v4.d.ts +9 -0
  378. package/dist/types/utils/symbols.d.ts +3 -0
  379. package/dist/types/utils/time.d.ts +22 -0
  380. package/dist/types/utils/typeSafety.d.ts +37 -0
  381. package/package.json +97 -0
@@ -0,0 +1,200 @@
1
+ import { mapValues } from 'lodash-es';
2
+ import stableStringify from 'safe-stable-stringify';
3
+ import * as yaml from 'yaml';
4
+ import { doubleCheckProject } from './serializationUtils.js';
5
+ import { entries } from '../typeSafety.js';
6
+ export function projectV4Deserializer(data) {
7
+ if (typeof data !== 'string') {
8
+ throw new Error('Project v4 deserializer requires a string');
9
+ }
10
+ const serializedProject = yaml.parse(data);
11
+ if (serializedProject.version !== 4) {
12
+ throw new Error('Project v4 deserializer requires a version 4 project');
13
+ }
14
+ const [project, attachedData] = fromSerializedProject(serializedProject.data);
15
+ doubleCheckProject(project);
16
+ return [project, attachedData];
17
+ }
18
+ export function graphV4Deserializer(data) {
19
+ if (typeof data !== 'string') {
20
+ throw new Error('Graph v4 deserializer requires a string');
21
+ }
22
+ const serializedGraph = yaml.parse(data);
23
+ if (serializedGraph.version !== 4) {
24
+ throw new Error('Graph v4 deserializer requires a version 4 graph');
25
+ }
26
+ return fromSerializedGraph(serializedGraph.data);
27
+ }
28
+ export function projectV4Serializer(project, attachedData) {
29
+ const filteredProject = {
30
+ ...project,
31
+ metadata: {
32
+ ...project.metadata,
33
+ path: undefined,
34
+ },
35
+ };
36
+ // Make sure all data is ordered deterministically first
37
+ const stabilized = JSON.parse(stableStringify(toSerializedProject(filteredProject, attachedData)));
38
+ const serialized = yaml.stringify({
39
+ version: 4,
40
+ data: stabilized,
41
+ }, null, {
42
+ indent: 2,
43
+ });
44
+ return serialized;
45
+ }
46
+ export function graphV4Serializer(graph) {
47
+ // Make sure all data is ordered deterministically first
48
+ const stabilized = JSON.parse(stableStringify(toSerializedGraph(graph)));
49
+ const serialized = yaml.stringify({
50
+ version: 4,
51
+ data: stabilized,
52
+ }, null, {
53
+ indent: 2,
54
+ });
55
+ return serialized;
56
+ }
57
+ function toSerializedProject(project, attachedData) {
58
+ return {
59
+ metadata: project.metadata,
60
+ graphs: mapValues(project.graphs, (graph) => toSerializedGraph(graph)),
61
+ attachedData,
62
+ plugins: project.plugins ?? [],
63
+ };
64
+ }
65
+ function fromSerializedProject(serializedProject) {
66
+ return [
67
+ {
68
+ metadata: serializedProject.metadata,
69
+ graphs: mapValues(serializedProject.graphs, (graph) => fromSerializedGraph(graph)),
70
+ plugins: serializedProject.plugins ?? [],
71
+ },
72
+ serializedProject.attachedData ?? {},
73
+ ];
74
+ }
75
+ function toSerializedGraph(graph) {
76
+ const graphMetadata = {
77
+ id: graph.metadata.id,
78
+ name: graph.metadata.name,
79
+ description: graph.metadata.description,
80
+ };
81
+ if (graph.metadata.attachedData) {
82
+ graphMetadata.attachedData = graph.metadata.attachedData;
83
+ }
84
+ return {
85
+ metadata: graphMetadata,
86
+ nodes: graph.nodes.reduce((acc, node) => ({
87
+ ...acc,
88
+ [getGraphNodeKey(node)]: toSerializedNode(node, graph.nodes, graph.connections),
89
+ }), {}),
90
+ };
91
+ }
92
+ function getGraphNodeKey(node) {
93
+ return `[${node.id}]:${node.type} "${node.title}"`;
94
+ }
95
+ function deserializeGraphNodeKey(key) {
96
+ const { nodeId, type, title } = key.match(/^\[(?<nodeId>[^\]]+)\]:(?<type>[^\s]+) "(?<title>.*)"$/)?.groups ?? {};
97
+ if (!nodeId || !type || !title) {
98
+ throw new Error(`Invalid graph node key: ${key}`);
99
+ }
100
+ return [nodeId, type, title];
101
+ }
102
+ function fromSerializedGraph(serializedGraph) {
103
+ const allConnections = [];
104
+ const allNodes = [];
105
+ for (const [serializedNodeInfo, node] of entries(serializedGraph.nodes)) {
106
+ const [chartNode, connections] = fromSerializedNode(node, serializedNodeInfo);
107
+ allNodes.push(chartNode);
108
+ allConnections.push(...connections);
109
+ }
110
+ const metadata = {
111
+ id: serializedGraph.metadata.id,
112
+ name: serializedGraph.metadata.name,
113
+ description: serializedGraph.metadata.description,
114
+ };
115
+ if (serializedGraph.metadata.attachedData) {
116
+ metadata.attachedData = serializedGraph.metadata.attachedData;
117
+ }
118
+ return {
119
+ metadata,
120
+ nodes: allNodes,
121
+ connections: allConnections,
122
+ };
123
+ }
124
+ function toSerializedNode(node, allNodes, allConnections) {
125
+ const outgoingConnections = allConnections
126
+ .filter((connection) => connection.outputNodeId === node.id)
127
+ .map((connection) => toSerializedConnection(connection, allNodes))
128
+ .sort();
129
+ return {
130
+ description: node.description?.trim() ? node.description : undefined,
131
+ visualData: `${node.visualData.x}/${node.visualData.y}/${node.visualData.width ?? 'null'}/${node.visualData.zIndex ?? 'null'}/${node.visualData.color?.border ?? ''}/${node.visualData.color?.bg ?? ''}`,
132
+ isSplitRun: node.isSplitRun ? true : undefined,
133
+ splitRunMax: node.isSplitRun ? node.splitRunMax : undefined,
134
+ isSplitSequential: node.isSplitSequential ? true : undefined,
135
+ data: Object.keys(node.data ?? {}).length > 0 ? node.data : undefined,
136
+ outgoingConnections: outgoingConnections.length > 0 ? outgoingConnections : undefined,
137
+ variants: (node.variants?.length ?? 0) > 0 ? node.variants : undefined,
138
+ disabled: node.disabled ? true : undefined,
139
+ };
140
+ }
141
+ function fromSerializedNode(serializedNode, serializedNodeInfo) {
142
+ const [nodeId, type, title] = deserializeGraphNodeKey(serializedNodeInfo);
143
+ const [x, y, width, zIndex, borderColor, bgColor] = serializedNode.visualData.split('/');
144
+ const connections = serializedNode.outgoingConnections?.map((serializedConnection) => fromSerializedConnection(serializedConnection, nodeId)) ?? [];
145
+ const color = borderColor || bgColor ? { border: borderColor, bg: bgColor } : undefined;
146
+ return [
147
+ {
148
+ id: nodeId,
149
+ type,
150
+ title,
151
+ description: serializedNode.description,
152
+ isSplitRun: serializedNode.isSplitRun ?? false,
153
+ splitRunMax: serializedNode.splitRunMax ?? 10,
154
+ isSplitSequential: serializedNode.isSplitSequential ?? false,
155
+ visualData: {
156
+ x: parseFloat(x),
157
+ y: parseFloat(y),
158
+ width: width === 'null' ? undefined : parseFloat(width),
159
+ zIndex: zIndex === 'null' ? undefined : parseFloat(zIndex),
160
+ color,
161
+ },
162
+ data: serializedNode.data ?? {},
163
+ variants: serializedNode.variants ?? [],
164
+ disabled: serializedNode.disabled,
165
+ },
166
+ connections,
167
+ ];
168
+ }
169
+ function toSerializedConnection(connection, allNodes) {
170
+ return `${connection.outputId}->"${allNodes.find((node) => node.id === connection.inputNodeId)?.title}" ${connection.inputNodeId}/${connection.inputId}`;
171
+ }
172
+ function fromSerializedConnection(connection, nodeId) {
173
+ try {
174
+ const [, outputId, , inputNodeId, inputId] = connection.match(/(.+)->"(.+)"\s+(.+)\/(.+)/);
175
+ return {
176
+ outputId: outputId,
177
+ outputNodeId: nodeId,
178
+ inputId: inputId,
179
+ inputNodeId: inputNodeId,
180
+ };
181
+ }
182
+ catch (err) {
183
+ throw new Error(`Invalid connection: ${connection}`);
184
+ }
185
+ }
186
+ export function datasetV4Serializer(datasets) {
187
+ const dataContainer = {
188
+ datasets,
189
+ };
190
+ const data = JSON.stringify(dataContainer);
191
+ return data;
192
+ }
193
+ export function datasetV4Deserializer(serializedDatasets) {
194
+ const stringData = serializedDatasets;
195
+ const dataContainer = JSON.parse(stringData);
196
+ if (!dataContainer.datasets) {
197
+ throw new Error('Invalid dataset data');
198
+ }
199
+ return dataContainer.datasets;
200
+ }
@@ -0,0 +1,2 @@
1
+ export const Warnings = '__internalPort_Warnings';
2
+ export const WarningsPort = Warnings;
@@ -0,0 +1,14 @@
1
+ /** Returns a number of milliseconds, strongly typed. */
2
+ export const ms = (numMilliseconds) => numMilliseconds;
3
+ /** Returns a number of seconds, as milliseconds. */
4
+ export const seconds = (numSeconds) => ms(numSeconds * 1000);
5
+ /** Returns a number of minutes, as milliseconds. */
6
+ export const minutes = (numMinutes) => seconds(numMinutes * 60);
7
+ /** Returns a number of hours, as milliseconds. */
8
+ export const hours = (numHours) => minutes(numHours * 60);
9
+ /** Returns a number of days, as milliseconds. */
10
+ export const days = (numDays) => hours(numDays * 24);
11
+ /** Returns a number of microseconds, strongly typed. To type a µ, press option+m on mac os. */
12
+ export const µs = (numMicroseconds) => numMicroseconds;
13
+ export const µsToMs = (numMicroseconds) => ms(numMicroseconds / 1000);
14
+ export const msToµs = (numMilliseconds) => µs(numMilliseconds * 1000);
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Type-safe version of {@link Object.entries} which can infer the type for the keys in the
3
+ * returned pairs when the input object has a branded type as its key.
4
+ *
5
+ * @example
6
+ * type MyId = string & { __myIdBrand: unknown };
7
+ * // Types check out!
8
+ * const things: [MyId, Thing][] = Objects.entries({} as Record<MyId, Thing>);
9
+ *
10
+ * @see {@link fromEntries}
11
+ */
12
+ export const entries = (
13
+ // In principle we should be able to use only Partial<> as the type is a superset of the non-
14
+ // Partial type, but in practice this causes the compiler to infer a too-restricted type for V
15
+ // in some cases involving unions.
16
+ object) => (object == null ? [] : Object.entries(object));
17
+ /**
18
+ * Type-safe version of {@link Object.fromEntries} which can infer the type for the key in the
19
+ * returned object when the input array has a branded type as its key.
20
+ *
21
+ * @example
22
+ * type MyId = string & { __myIdBrand: unknown };
23
+ * // Types check out!
24
+ * const things: Partial<Record<MyId, Thing>> = Objects.fromEntries([] as [MyId, Thing][]);
25
+ *
26
+ * @see {@link entries}
27
+ */
28
+ // This returns a Partial<> because we can't guarantee that every key is present when K is a
29
+ // string literal union (which is what Record<K, V> would be saying). As a side effect, this means
30
+ // that using this with branded IDs will force null checks downstream, which is good practice.
31
+ export function fromEntries(entries_) {
32
+ return Object.fromEntries(entries_);
33
+ }
34
+ export function keys(o) {
35
+ return Object.keys(o);
36
+ }
37
+ export function values(o) {
38
+ return Object.values(o);
39
+ }
40
+ export function mapValues(o, fn) {
41
+ return Object.fromEntries(Object.entries(o).map(([key, value]) => [key, fn(value)]));
42
+ }
@@ -0,0 +1,37 @@
1
+ import type { PascalCase } from 'type-fest';
2
+ import { type AttachedData, type AudioProvider, type DataValue, type DatasetProvider, type ExternalFunction, type NativeApi, type NodeRegistration, type ProcessContext, type ProcessEvents, type Project, type RivetEventStreamFilterSpec, type Settings } from '../index.js';
3
+ import { GraphProcessor } from '../model/GraphProcessor.js';
4
+ export type LooseDataValue = DataValue | string | number | boolean;
5
+ export type RunGraphOptions = {
6
+ graph?: string;
7
+ inputs?: Record<string, LooseDataValue>;
8
+ context?: Record<string, LooseDataValue>;
9
+ nativeApi?: NativeApi;
10
+ datasetProvider?: DatasetProvider;
11
+ audioProvider?: AudioProvider;
12
+ externalFunctions?: {
13
+ [key: string]: ExternalFunction;
14
+ };
15
+ onUserEvent?: {
16
+ [key: string]: (data: DataValue | undefined) => void;
17
+ };
18
+ abortSignal?: AbortSignal;
19
+ registry?: NodeRegistration;
20
+ getChatNodeEndpoint?: ProcessContext['getChatNodeEndpoint'];
21
+ } & {
22
+ [P in keyof ProcessEvents as `on${PascalCase<P>}`]?: (params: ProcessEvents[P]) => void;
23
+ } & Settings;
24
+ export declare function looseDataValuesToDataValues(values: Record<string, LooseDataValue>): Record<string, DataValue>;
25
+ export declare function looseDataValueToDataValue(value: LooseDataValue): DataValue;
26
+ export declare function coreCreateProcessor(project: Project, options: RunGraphOptions): {
27
+ processor: GraphProcessor;
28
+ inputs: Record<string, DataValue>;
29
+ contextValues: Record<string, DataValue>;
30
+ getEvents: (spec: RivetEventStreamFilterSpec) => AsyncGenerator<import("./streaming.js").RivetEventStreamEventInfo, void, unknown>;
31
+ getSSEStream: (spec: RivetEventStreamFilterSpec) => ReadableStream<Uint8Array>;
32
+ streamNode: (nodeIdOrTitle: string) => ReadableStream<string>;
33
+ run(): Promise<import("../index.js").GraphOutputs>;
34
+ };
35
+ export declare function coreRunGraph(project: Project, options: RunGraphOptions): Promise<Record<string, DataValue>>;
36
+ export declare function loadProjectFromString(content: string): Project;
37
+ export declare function loadProjectAndAttachedDataFromString(content: string): [Project, AttachedData];
@@ -0,0 +1,56 @@
1
+ import { type NodeId, type Inputs, type Outputs, type GraphOutputs, type GraphProcessor } from '../index.js';
2
+ export type RivetEventStreamFilterSpec = {
3
+ /** Stream partial output deltas for the specified node IDs or node titles. */
4
+ partialOutputs?: string[] | true;
5
+ /** Send the graph output when done? */
6
+ done?: boolean;
7
+ /** If the graph errors, send an error event? */
8
+ error?: boolean;
9
+ /** Stream node start events for the specified node IDs or node titles. */
10
+ nodeStart?: string[] | true;
11
+ /** Stream node finish events for the specified nodeIDs or node titles. */
12
+ nodeFinish?: string[] | true;
13
+ };
14
+ /** Map of all possible event names to their data for streaming events. */
15
+ export type RivetEventStreamEvent = {
16
+ /** Deltas for partial outputs. */
17
+ partialOutput: {
18
+ nodeId: NodeId;
19
+ nodeTitle: string;
20
+ delta: string;
21
+ };
22
+ nodeStart: {
23
+ nodeId: NodeId;
24
+ nodeTitle: string;
25
+ inputs: Inputs;
26
+ };
27
+ nodeFinish: {
28
+ nodeId: NodeId;
29
+ nodeTitle: string;
30
+ outputs: Outputs;
31
+ };
32
+ done: {
33
+ graphOutput: GraphOutputs;
34
+ };
35
+ error: {
36
+ error: string;
37
+ };
38
+ };
39
+ export type RivetEventStreamEventInfo = {
40
+ [P in keyof RivetEventStreamEvent]: {
41
+ type: P;
42
+ } & RivetEventStreamEvent[P];
43
+ }[keyof RivetEventStreamEvent];
44
+ /** A simplified way to listen and stream processor events, including filtering. */
45
+ export declare function getProcessorEvents(processor: GraphProcessor, spec: RivetEventStreamFilterSpec): AsyncGenerator<RivetEventStreamEventInfo, void>;
46
+ /**
47
+ * Creates a ReadableStream for processor events, following the Server-Sent Events protocol.
48
+ * https://developer.mozilla.org/en-US/docs/Web/API/EventSource
49
+ *
50
+ * Includes configuration for what events to send to the client, for example you can stream the partial output deltas
51
+ * for specific nodes, and/or the graph output when done.
52
+ */
53
+ export declare function getProcessorSSEStream(processor: GraphProcessor,
54
+ /** The spec for what you're streaming to the client */
55
+ spec: RivetEventStreamFilterSpec): ReadableStream<Uint8Array>;
56
+ export declare function getSingleNodeStream(processor: GraphProcessor, nodeIdOrTitle: string): ReadableStream<string>;
@@ -0,0 +1,33 @@
1
+ export * from './utils/index.js';
2
+ export * from './model/GraphProcessor.js';
3
+ export * from './model/DataValue.js';
4
+ export * from './model/NodeBase.js';
5
+ export * from './model/NodeGraph.js';
6
+ export * from './model/NodeImpl.js';
7
+ export * from './model/NodeDefinition.js';
8
+ export * from './model/Nodes.js';
9
+ export * from './model/Project.js';
10
+ export * from './native/BaseDir.js';
11
+ export * from './native/NativeApi.js';
12
+ export * from './native/BrowserNativeApi.js';
13
+ export * from './model/ProcessContext.js';
14
+ export * from './integrations/integrations.js';
15
+ import './integrations/enableIntegrations.js';
16
+ export * from './integrations/VectorDatabase.js';
17
+ export * from './integrations/EmbeddingGenerator.js';
18
+ export * from './integrations/LLMProvider.js';
19
+ export * from './recording/ExecutionRecorder.js';
20
+ export * from './recording/RecordedEvents.js';
21
+ export * from './model/RivetPlugin.js';
22
+ export * from './plugins.js';
23
+ export * from './model/NodeRegistration.js';
24
+ export type * from './model/Settings.js';
25
+ export * from './model/EditorDefinition.js';
26
+ export * from './model/NodeBodySpec.js';
27
+ export * from './integrations/DatasetProvider.js';
28
+ export * from './model/Dataset.js';
29
+ export * from './api/streaming.js';
30
+ export * from './api/createProcessor.js';
31
+ export * from './integrations/AudioProvider.js';
32
+ import * as openai from './utils/openai.js';
33
+ export { openai };
@@ -0,0 +1,4 @@
1
+ import type * as RivetTypes from './exports.js';
2
+ export * from './exports.js';
3
+ export declare const Rivet: typeof RivetTypes;
4
+ export type RivetPluginInitializer = (rivet: typeof Rivet) => RivetTypes.RivetPlugin;
@@ -0,0 +1,4 @@
1
+ import type { AudioDataValue } from '../model/DataValue.js';
2
+ export interface AudioProvider {
3
+ playAudio(audio: AudioDataValue, abort: AbortSignal): Promise<void>;
4
+ }
@@ -0,0 +1,33 @@
1
+ import { type Dataset, type DatasetId, type DatasetMetadata, type DatasetRow, type ProjectId } from '../index.js';
2
+ import type { CombinedDataset } from '../utils/index.js';
3
+ export interface DatasetProvider {
4
+ getDatasetMetadata(id: DatasetId): Promise<DatasetMetadata | undefined>;
5
+ getDatasetsForProject(projectId: ProjectId): Promise<DatasetMetadata[]>;
6
+ getDatasetData(id: DatasetId): Promise<Dataset>;
7
+ putDatasetData(id: DatasetId, data: Dataset): Promise<void>;
8
+ putDatasetRow(id: DatasetId, row: DatasetRow): Promise<void>;
9
+ putDatasetMetadata(metadata: DatasetMetadata): Promise<void>;
10
+ clearDatasetData(id: DatasetId): Promise<void>;
11
+ deleteDataset(id: DatasetId): Promise<void>;
12
+ /** Gets the K nearest neighbor rows to the given vector. */
13
+ knnDatasetRows(datasetId: DatasetId, k: number, vector: number[]): Promise<(DatasetRow & {
14
+ distance?: number;
15
+ })[]>;
16
+ exportDatasetsForProject(projectId: ProjectId): Promise<CombinedDataset[]>;
17
+ }
18
+ export declare class InMemoryDatasetProvider implements DatasetProvider {
19
+ #private;
20
+ constructor(datasets: CombinedDataset[]);
21
+ getDatasetMetadata(id: DatasetId): Promise<DatasetMetadata | undefined>;
22
+ getDatasetsForProject(projectId: ProjectId): Promise<DatasetMetadata[]>;
23
+ getDatasetData(id: DatasetId): Promise<Dataset>;
24
+ putDatasetRow(id: DatasetId, row: DatasetRow): Promise<void>;
25
+ putDatasetData(id: DatasetId, data: Dataset): Promise<void>;
26
+ putDatasetMetadata(metadata: DatasetMetadata): Promise<void>;
27
+ clearDatasetData(id: DatasetId): Promise<void>;
28
+ deleteDataset(id: DatasetId): Promise<void>;
29
+ knnDatasetRows(datasetId: DatasetId, k: number, vector: number[]): Promise<(DatasetRow & {
30
+ distance?: number | undefined;
31
+ })[]>;
32
+ exportDatasetsForProject(_projectId: ProjectId): Promise<CombinedDataset[]>;
33
+ }
@@ -0,0 +1,3 @@
1
+ export interface EmbeddingGenerator {
2
+ generateEmbedding(text: string, options?: Record<string, unknown>): Promise<number[]>;
3
+ }
@@ -0,0 +1,20 @@
1
+ import { type ChatMessage, type GptFunction } from '../index.js';
2
+ import type { Tokenizer, TokenizerCallInfo } from './Tokenizer.js';
3
+ import Emittery from 'emittery';
4
+ export declare class GptTokenizerTokenizer implements Tokenizer {
5
+ emitter: Emittery<{
6
+ error: Error;
7
+ }, {
8
+ error: Error;
9
+ } & import("emittery").OmnipresentEventData, never>;
10
+ on(event: 'error', listener: (err: Error) => void): void;
11
+ getTokenCountForString(input: string, _info: TokenizerCallInfo): Promise<number>;
12
+ getTokenCountForMessages(messages: ChatMessage[], functions: GptFunction[] | undefined, _info: TokenizerCallInfo): Promise<number>;
13
+ /**
14
+ * Converts GPT Functions to approximate TypeScript-style string.
15
+ * Per thread: https://community.openai.com/t/how-to-calculate-the-tokens-when-using-function-call/266573/24
16
+ * We should consider using a different library, eg. https://github.com/hmarr/openai-chat-tokens
17
+ * @param functions
18
+ */
19
+ private convertGptFunctionsToPromptString;
20
+ }
@@ -0,0 +1,7 @@
1
+ import { type ArrayDataValue, type ChatMessageDataValue } from '../model/DataValue.js';
2
+ export type LLMParameters = {
3
+ [key: string]: string;
4
+ };
5
+ export interface LLMProvider {
6
+ getCompletions(messages: ArrayDataValue<ChatMessageDataValue>, parameters: LLMParameters): Promise<ArrayDataValue<ChatMessageDataValue>>;
7
+ }
@@ -0,0 +1,11 @@
1
+ import type { ChartNode, ChatMessage, GptFunction } from '../index.js';
2
+ export type TokenizerCallInfo = {
3
+ node: ChartNode;
4
+ model?: string;
5
+ endpoint?: string;
6
+ };
7
+ export type Tokenizer = {
8
+ on(event: 'error', listener: (err: Error) => void): void;
9
+ getTokenCountForString(input: string, info: TokenizerCallInfo): Promise<number>;
10
+ getTokenCountForMessages(messages: ChatMessage[], gptFunctions: GptFunction[] | undefined, info: TokenizerCallInfo): Promise<number>;
11
+ };
@@ -0,0 +1,7 @@
1
+ import { type DataValue, type VectorDataValue, type ArrayDataValue, type ScalarDataValue } from '../model/DataValue.js';
2
+ export interface VectorDatabase {
3
+ store(collection: DataValue, vector: VectorDataValue, data: DataValue, metadata: {
4
+ id?: string;
5
+ }): Promise<void>;
6
+ nearestNeighbors(collection: DataValue, vector: VectorDataValue, k: number): Promise<ArrayDataValue<ScalarDataValue>>;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { type InternalProcessContext } from '../model/ProcessContext.js';
2
+ import { type EmbeddingGenerator } from './EmbeddingGenerator.js';
3
+ import { type LLMProvider } from './LLMProvider.js';
4
+ import { type VectorDatabase } from './VectorDatabase.js';
5
+ export type IntegrationFactories = {
6
+ vectorDatabase: (context: InternalProcessContext) => VectorDatabase;
7
+ llmProvider: (context: InternalProcessContext) => LLMProvider;
8
+ embeddingGenerator: (context: InternalProcessContext) => EmbeddingGenerator;
9
+ };
10
+ export type IntegrationType = keyof IntegrationFactories;
11
+ export declare function registerIntegration<T extends IntegrationType>(type: T, integrationKey: string, factory: IntegrationFactories[T]): void;
12
+ export declare function getIntegration<T extends IntegrationType>(type: T, integrationKey: string, context: InternalProcessContext): ReturnType<IntegrationFactories[T]>;
@@ -0,0 +1,10 @@
1
+ import { type Settings } from '../../index.js';
2
+ import { type EmbeddingGenerator } from '../EmbeddingGenerator.js';
3
+ import { OpenAI } from 'openai';
4
+ type OpenAIOptions = Pick<OpenAI.EmbeddingCreateParams, 'model' | 'dimensions'>;
5
+ export declare class OpenAIEmbeddingGenerator implements EmbeddingGenerator {
6
+ #private;
7
+ constructor(settings: Settings);
8
+ generateEmbedding(text: string, options?: OpenAIOptions): Promise<number[]>;
9
+ }
10
+ export {};