@nodetool-ai/base-nodes 0.7.0-rc.22 → 0.8.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 (363) hide show
  1. package/README.md +21 -0
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/index.d.ts +61 -67
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +179 -173
  6. package/dist/index.js.map +1 -1
  7. package/dist/platforms/browser.d.ts +19 -0
  8. package/dist/platforms/browser.d.ts.map +1 -0
  9. package/dist/platforms/browser.js +29 -0
  10. package/dist/platforms/browser.js.map +1 -0
  11. package/package.json +53 -65
  12. package/dist/lib/audio-wav.d.ts +0 -66
  13. package/dist/lib/audio-wav.d.ts.map +0 -1
  14. package/dist/lib/audio-wav.js +0 -215
  15. package/dist/lib/audio-wav.js.map +0 -1
  16. package/dist/nodes/agent-tool-hydration.d.ts +0 -10
  17. package/dist/nodes/agent-tool-hydration.d.ts.map +0 -1
  18. package/dist/nodes/agent-tool-hydration.js +0 -43
  19. package/dist/nodes/agent-tool-hydration.js.map +0 -1
  20. package/dist/nodes/agents.d.ts +0 -262
  21. package/dist/nodes/agents.d.ts.map +0 -1
  22. package/dist/nodes/agents.js +0 -2856
  23. package/dist/nodes/agents.js.map +0 -1
  24. package/dist/nodes/anthropic.d.ts +0 -26
  25. package/dist/nodes/anthropic.d.ts.map +0 -1
  26. package/dist/nodes/anthropic.js +0 -133
  27. package/dist/nodes/anthropic.js.map +0 -1
  28. package/dist/nodes/apify.d.ts +0 -120
  29. package/dist/nodes/apify.d.ts.map +0 -1
  30. package/dist/nodes/apify.js +0 -618
  31. package/dist/nodes/apify.js.map +0 -1
  32. package/dist/nodes/audio.d.ts +0 -301
  33. package/dist/nodes/audio.d.ts.map +0 -1
  34. package/dist/nodes/audio.js +0 -1274
  35. package/dist/nodes/audio.js.map +0 -1
  36. package/dist/nodes/code-node.d.ts +0 -34
  37. package/dist/nodes/code-node.d.ts.map +0 -1
  38. package/dist/nodes/code-node.js +0 -343
  39. package/dist/nodes/code-node.js.map +0 -1
  40. package/dist/nodes/code.d.ts +0 -301
  41. package/dist/nodes/code.d.ts.map +0 -1
  42. package/dist/nodes/code.js +0 -850
  43. package/dist/nodes/code.js.map +0 -1
  44. package/dist/nodes/compare.d.ts +0 -18
  45. package/dist/nodes/compare.d.ts.map +0 -1
  46. package/dist/nodes/compare.js +0 -122
  47. package/dist/nodes/compare.js.map +0 -1
  48. package/dist/nodes/constant.d.ts +0 -315
  49. package/dist/nodes/constant.d.ts.map +0 -1
  50. package/dist/nodes/constant.js +0 -715
  51. package/dist/nodes/constant.js.map +0 -1
  52. package/dist/nodes/control.d.ts +0 -83
  53. package/dist/nodes/control.d.ts.map +0 -1
  54. package/dist/nodes/control.js +0 -212
  55. package/dist/nodes/control.js.map +0 -1
  56. package/dist/nodes/data.d.ts +0 -369
  57. package/dist/nodes/data.d.ts.map +0 -1
  58. package/dist/nodes/data.js +0 -1590
  59. package/dist/nodes/data.js.map +0 -1
  60. package/dist/nodes/document.d.ts +0 -134
  61. package/dist/nodes/document.d.ts.map +0 -1
  62. package/dist/nodes/document.js +0 -984
  63. package/dist/nodes/document.js.map +0 -1
  64. package/dist/nodes/extended-placeholders.d.ts +0 -6
  65. package/dist/nodes/extended-placeholders.d.ts.map +0 -1
  66. package/dist/nodes/extended-placeholders.js +0 -19
  67. package/dist/nodes/extended-placeholders.js.map +0 -1
  68. package/dist/nodes/gemini.d.ts +0 -110
  69. package/dist/nodes/gemini.d.ts.map +0 -1
  70. package/dist/nodes/gemini.js +0 -871
  71. package/dist/nodes/gemini.js.map +0 -1
  72. package/dist/nodes/generators.d.ts +0 -84
  73. package/dist/nodes/generators.d.ts.map +0 -1
  74. package/dist/nodes/generators.js +0 -968
  75. package/dist/nodes/generators.js.map +0 -1
  76. package/dist/nodes/image.d.ts +0 -232
  77. package/dist/nodes/image.d.ts.map +0 -1
  78. package/dist/nodes/image.js +0 -1395
  79. package/dist/nodes/image.js.map +0 -1
  80. package/dist/nodes/input.d.ts +0 -445
  81. package/dist/nodes/input.d.ts.map +0 -1
  82. package/dist/nodes/input.js +0 -1459
  83. package/dist/nodes/input.js.map +0 -1
  84. package/dist/nodes/kie-dynamic.d.ts +0 -31
  85. package/dist/nodes/kie-dynamic.d.ts.map +0 -1
  86. package/dist/nodes/kie-dynamic.js +0 -270
  87. package/dist/nodes/kie-dynamic.js.map +0 -1
  88. package/dist/nodes/lib-audio-dsp.d.ts +0 -85
  89. package/dist/nodes/lib-audio-dsp.d.ts.map +0 -1
  90. package/dist/nodes/lib-audio-dsp.js +0 -450
  91. package/dist/nodes/lib-audio-dsp.js.map +0 -1
  92. package/dist/nodes/lib-audio-effects.d.ts +0 -116
  93. package/dist/nodes/lib-audio-effects.d.ts.map +0 -1
  94. package/dist/nodes/lib-audio-effects.js +0 -905
  95. package/dist/nodes/lib-audio-effects.js.map +0 -1
  96. package/dist/nodes/lib-browser.d.ts +0 -99
  97. package/dist/nodes/lib-browser.d.ts.map +0 -1
  98. package/dist/nodes/lib-browser.js +0 -692
  99. package/dist/nodes/lib-browser.js.map +0 -1
  100. package/dist/nodes/lib-charts.d.ts +0 -20
  101. package/dist/nodes/lib-charts.d.ts.map +0 -1
  102. package/dist/nodes/lib-charts.js +0 -245
  103. package/dist/nodes/lib-charts.js.map +0 -1
  104. package/dist/nodes/lib-datetime.d.ts +0 -108
  105. package/dist/nodes/lib-datetime.d.ts.map +0 -1
  106. package/dist/nodes/lib-datetime.js +0 -421
  107. package/dist/nodes/lib-datetime.js.map +0 -1
  108. package/dist/nodes/lib-doc-convert.d.ts +0 -19
  109. package/dist/nodes/lib-doc-convert.d.ts.map +0 -1
  110. package/dist/nodes/lib-doc-convert.js +0 -257
  111. package/dist/nodes/lib-doc-convert.js.map +0 -1
  112. package/dist/nodes/lib-doc-transform.d.ts +0 -39
  113. package/dist/nodes/lib-doc-transform.d.ts.map +0 -1
  114. package/dist/nodes/lib-doc-transform.js +0 -335
  115. package/dist/nodes/lib-doc-transform.js.map +0 -1
  116. package/dist/nodes/lib-docx.d.ts +0 -106
  117. package/dist/nodes/lib-docx.d.ts.map +0 -1
  118. package/dist/nodes/lib-docx.js +0 -595
  119. package/dist/nodes/lib-docx.js.map +0 -1
  120. package/dist/nodes/lib-epub.d.ts +0 -55
  121. package/dist/nodes/lib-epub.d.ts.map +0 -1
  122. package/dist/nodes/lib-epub.js +0 -220
  123. package/dist/nodes/lib-epub.js.map +0 -1
  124. package/dist/nodes/lib-excel.d.ts +0 -74
  125. package/dist/nodes/lib-excel.d.ts.map +0 -1
  126. package/dist/nodes/lib-excel.js +0 -448
  127. package/dist/nodes/lib-excel.js.map +0 -1
  128. package/dist/nodes/lib-graphql.d.ts +0 -66
  129. package/dist/nodes/lib-graphql.d.ts.map +0 -1
  130. package/dist/nodes/lib-graphql.js +0 -333
  131. package/dist/nodes/lib-graphql.js.map +0 -1
  132. package/dist/nodes/lib-grid.d.ts +0 -27
  133. package/dist/nodes/lib-grid.d.ts.map +0 -1
  134. package/dist/nodes/lib-grid.js +0 -172
  135. package/dist/nodes/lib-grid.js.map +0 -1
  136. package/dist/nodes/lib-html-parse.d.ts +0 -108
  137. package/dist/nodes/lib-html-parse.d.ts.map +0 -1
  138. package/dist/nodes/lib-html-parse.js +0 -365
  139. package/dist/nodes/lib-html-parse.js.map +0 -1
  140. package/dist/nodes/lib-http.d.ts +0 -98
  141. package/dist/nodes/lib-http.d.ts.map +0 -1
  142. package/dist/nodes/lib-http.js +0 -267
  143. package/dist/nodes/lib-http.js.map +0 -1
  144. package/dist/nodes/lib-image-color-grading.d.ts +0 -3
  145. package/dist/nodes/lib-image-color-grading.d.ts.map +0 -1
  146. package/dist/nodes/lib-image-color-grading.js +0 -1386
  147. package/dist/nodes/lib-image-color-grading.js.map +0 -1
  148. package/dist/nodes/lib-image-draw.d.ts +0 -3
  149. package/dist/nodes/lib-image-draw.d.ts.map +0 -1
  150. package/dist/nodes/lib-image-draw.js +0 -470
  151. package/dist/nodes/lib-image-draw.js.map +0 -1
  152. package/dist/nodes/lib-image-enhance.d.ts +0 -3
  153. package/dist/nodes/lib-image-enhance.d.ts.map +0 -1
  154. package/dist/nodes/lib-image-enhance.js +0 -731
  155. package/dist/nodes/lib-image-enhance.js.map +0 -1
  156. package/dist/nodes/lib-image-filter.d.ts +0 -3
  157. package/dist/nodes/lib-image-filter.d.ts.map +0 -1
  158. package/dist/nodes/lib-image-filter.js +0 -684
  159. package/dist/nodes/lib-image-filter.js.map +0 -1
  160. package/dist/nodes/lib-image-utils.d.ts +0 -24
  161. package/dist/nodes/lib-image-utils.d.ts.map +0 -1
  162. package/dist/nodes/lib-image-utils.js +0 -150
  163. package/dist/nodes/lib-image-utils.js.map +0 -1
  164. package/dist/nodes/lib-mail.d.ts +0 -74
  165. package/dist/nodes/lib-mail.d.ts.map +0 -1
  166. package/dist/nodes/lib-mail.js +0 -452
  167. package/dist/nodes/lib-mail.js.map +0 -1
  168. package/dist/nodes/lib-markdown.d.ts +0 -70
  169. package/dist/nodes/lib-markdown.d.ts.map +0 -1
  170. package/dist/nodes/lib-markdown.js +0 -236
  171. package/dist/nodes/lib-markdown.js.map +0 -1
  172. package/dist/nodes/lib-nlp.d.ts +0 -98
  173. package/dist/nodes/lib-nlp.d.ts.map +0 -1
  174. package/dist/nodes/lib-nlp.js +0 -374
  175. package/dist/nodes/lib-nlp.js.map +0 -1
  176. package/dist/nodes/lib-notion.d.ts +0 -99
  177. package/dist/nodes/lib-notion.d.ts.map +0 -1
  178. package/dist/nodes/lib-notion.js +0 -601
  179. package/dist/nodes/lib-notion.js.map +0 -1
  180. package/dist/nodes/lib-ocr.d.ts +0 -31
  181. package/dist/nodes/lib-ocr.d.ts.map +0 -1
  182. package/dist/nodes/lib-ocr.js +0 -143
  183. package/dist/nodes/lib-ocr.js.map +0 -1
  184. package/dist/nodes/lib-os.d.ts +0 -312
  185. package/dist/nodes/lib-os.d.ts.map +0 -1
  186. package/dist/nodes/lib-os.js +0 -909
  187. package/dist/nodes/lib-os.js.map +0 -1
  188. package/dist/nodes/lib-pdf.d.ts +0 -142
  189. package/dist/nodes/lib-pdf.d.ts.map +0 -1
  190. package/dist/nodes/lib-pdf.js +0 -871
  191. package/dist/nodes/lib-pdf.js.map +0 -1
  192. package/dist/nodes/lib-pptx.d.ts +0 -29
  193. package/dist/nodes/lib-pptx.d.ts.map +0 -1
  194. package/dist/nodes/lib-pptx.js +0 -122
  195. package/dist/nodes/lib-pptx.js.map +0 -1
  196. package/dist/nodes/lib-rss.d.ts +0 -31
  197. package/dist/nodes/lib-rss.d.ts.map +0 -1
  198. package/dist/nodes/lib-rss.js +0 -163
  199. package/dist/nodes/lib-rss.js.map +0 -1
  200. package/dist/nodes/lib-s3.d.ts +0 -112
  201. package/dist/nodes/lib-s3.d.ts.map +0 -1
  202. package/dist/nodes/lib-s3.js +0 -521
  203. package/dist/nodes/lib-s3.js.map +0 -1
  204. package/dist/nodes/lib-secret.d.ts +0 -15
  205. package/dist/nodes/lib-secret.d.ts.map +0 -1
  206. package/dist/nodes/lib-secret.js +0 -42
  207. package/dist/nodes/lib-secret.js.map +0 -1
  208. package/dist/nodes/lib-sqlite.d.ts +0 -102
  209. package/dist/nodes/lib-sqlite.d.ts.map +0 -1
  210. package/dist/nodes/lib-sqlite.js +0 -532
  211. package/dist/nodes/lib-sqlite.js.map +0 -1
  212. package/dist/nodes/lib-supabase.d.ts +0 -86
  213. package/dist/nodes/lib-supabase.d.ts.map +0 -1
  214. package/dist/nodes/lib-supabase.js +0 -425
  215. package/dist/nodes/lib-supabase.js.map +0 -1
  216. package/dist/nodes/lib-svg.d.ts +0 -199
  217. package/dist/nodes/lib-svg.d.ts.map +0 -1
  218. package/dist/nodes/lib-svg.js +0 -1027
  219. package/dist/nodes/lib-svg.js.map +0 -1
  220. package/dist/nodes/lib-tensorflow.d.ts +0 -71
  221. package/dist/nodes/lib-tensorflow.d.ts.map +0 -1
  222. package/dist/nodes/lib-tensorflow.js +0 -351
  223. package/dist/nodes/lib-tensorflow.js.map +0 -1
  224. package/dist/nodes/lib-twilio.d.ts +0 -71
  225. package/dist/nodes/lib-twilio.d.ts.map +0 -1
  226. package/dist/nodes/lib-twilio.js +0 -469
  227. package/dist/nodes/lib-twilio.js.map +0 -1
  228. package/dist/nodes/lib-validate.d.ts +0 -84
  229. package/dist/nodes/lib-validate.d.ts.map +0 -1
  230. package/dist/nodes/lib-validate.js +0 -215
  231. package/dist/nodes/lib-validate.js.map +0 -1
  232. package/dist/nodes/lib-video-download.d.ts +0 -26
  233. package/dist/nodes/lib-video-download.d.ts.map +0 -1
  234. package/dist/nodes/lib-video-download.js +0 -299
  235. package/dist/nodes/lib-video-download.js.map +0 -1
  236. package/dist/nodes/messaging.d.ts +0 -88
  237. package/dist/nodes/messaging.d.ts.map +0 -1
  238. package/dist/nodes/messaging.js +0 -418
  239. package/dist/nodes/messaging.js.map +0 -1
  240. package/dist/nodes/mistral.d.ts +0 -83
  241. package/dist/nodes/mistral.d.ts.map +0 -1
  242. package/dist/nodes/mistral.js +0 -450
  243. package/dist/nodes/mistral.js.map +0 -1
  244. package/dist/nodes/model3d/analysis.d.ts +0 -13
  245. package/dist/nodes/model3d/analysis.d.ts.map +0 -1
  246. package/dist/nodes/model3d/analysis.js +0 -36
  247. package/dist/nodes/model3d/analysis.js.map +0 -1
  248. package/dist/nodes/model3d/base.d.ts +0 -11
  249. package/dist/nodes/model3d/base.d.ts.map +0 -1
  250. package/dist/nodes/model3d/base.js +0 -20
  251. package/dist/nodes/model3d/base.js.map +0 -1
  252. package/dist/nodes/model3d/boolean-ops.d.ts +0 -2
  253. package/dist/nodes/model3d/boolean-ops.d.ts.map +0 -1
  254. package/dist/nodes/model3d/boolean-ops.js +0 -172
  255. package/dist/nodes/model3d/boolean-ops.js.map +0 -1
  256. package/dist/nodes/model3d/cleanup.d.ts +0 -47
  257. package/dist/nodes/model3d/cleanup.d.ts.map +0 -1
  258. package/dist/nodes/model3d/cleanup.js +0 -136
  259. package/dist/nodes/model3d/cleanup.js.map +0 -1
  260. package/dist/nodes/model3d/convert.d.ts +0 -14
  261. package/dist/nodes/model3d/convert.d.ts.map +0 -1
  262. package/dist/nodes/model3d/convert.js +0 -64
  263. package/dist/nodes/model3d/convert.js.map +0 -1
  264. package/dist/nodes/model3d/defaults.d.ts +0 -34
  265. package/dist/nodes/model3d/defaults.d.ts.map +0 -1
  266. package/dist/nodes/model3d/defaults.js +0 -28
  267. package/dist/nodes/model3d/defaults.js.map +0 -1
  268. package/dist/nodes/model3d/document-ops.d.ts +0 -4
  269. package/dist/nodes/model3d/document-ops.d.ts.map +0 -1
  270. package/dist/nodes/model3d/document-ops.js +0 -40
  271. package/dist/nodes/model3d/document-ops.js.map +0 -1
  272. package/dist/nodes/model3d/generation.d.ts +0 -39
  273. package/dist/nodes/model3d/generation.d.ts.map +0 -1
  274. package/dist/nodes/model3d/generation.js +0 -179
  275. package/dist/nodes/model3d/generation.js.map +0 -1
  276. package/dist/nodes/model3d/glb.d.ts +0 -29
  277. package/dist/nodes/model3d/glb.d.ts.map +0 -1
  278. package/dist/nodes/model3d/glb.js +0 -255
  279. package/dist/nodes/model3d/glb.js.map +0 -1
  280. package/dist/nodes/model3d/index.d.ts +0 -20
  281. package/dist/nodes/model3d/index.d.ts.map +0 -1
  282. package/dist/nodes/model3d/index.js +0 -38
  283. package/dist/nodes/model3d/index.js.map +0 -1
  284. package/dist/nodes/model3d/io.d.ts +0 -38
  285. package/dist/nodes/model3d/io.d.ts.map +0 -1
  286. package/dist/nodes/model3d/io.js +0 -162
  287. package/dist/nodes/model3d/io.js.map +0 -1
  288. package/dist/nodes/model3d/mesh-ops.d.ts +0 -40
  289. package/dist/nodes/model3d/mesh-ops.d.ts.map +0 -1
  290. package/dist/nodes/model3d/mesh-ops.js +0 -775
  291. package/dist/nodes/model3d/mesh-ops.js.map +0 -1
  292. package/dist/nodes/model3d/nodes.d.ts +0 -2
  293. package/dist/nodes/model3d/nodes.d.ts.map +0 -1
  294. package/dist/nodes/model3d/nodes.js +0 -2
  295. package/dist/nodes/model3d/nodes.js.map +0 -1
  296. package/dist/nodes/model3d/ops.d.ts +0 -37
  297. package/dist/nodes/model3d/ops.d.ts.map +0 -1
  298. package/dist/nodes/model3d/ops.js +0 -137
  299. package/dist/nodes/model3d/ops.js.map +0 -1
  300. package/dist/nodes/model3d/transforms.d.ts +0 -49
  301. package/dist/nodes/model3d/transforms.d.ts.map +0 -1
  302. package/dist/nodes/model3d/transforms.js +0 -142
  303. package/dist/nodes/model3d/transforms.js.map +0 -1
  304. package/dist/nodes/model3d/types.d.ts +0 -81
  305. package/dist/nodes/model3d/types.d.ts.map +0 -1
  306. package/dist/nodes/model3d/types.js +0 -2
  307. package/dist/nodes/model3d/types.js.map +0 -1
  308. package/dist/nodes/model3d/utils.d.ts +0 -34
  309. package/dist/nodes/model3d/utils.d.ts.map +0 -1
  310. package/dist/nodes/model3d/utils.js +0 -185
  311. package/dist/nodes/model3d/utils.js.map +0 -1
  312. package/dist/nodes/model3d.d.ts +0 -2
  313. package/dist/nodes/model3d.d.ts.map +0 -1
  314. package/dist/nodes/model3d.js +0 -2
  315. package/dist/nodes/model3d.js.map +0 -1
  316. package/dist/nodes/openai.d.ts +0 -172
  317. package/dist/nodes/openai.d.ts.map +0 -1
  318. package/dist/nodes/openai.js +0 -1294
  319. package/dist/nodes/openai.js.map +0 -1
  320. package/dist/nodes/output.d.ts +0 -29
  321. package/dist/nodes/output.d.ts.map +0 -1
  322. package/dist/nodes/output.js +0 -87
  323. package/dist/nodes/output.js.map +0 -1
  324. package/dist/nodes/sandbox.d.ts +0 -63
  325. package/dist/nodes/sandbox.d.ts.map +0 -1
  326. package/dist/nodes/sandbox.js +0 -633
  327. package/dist/nodes/sandbox.js.map +0 -1
  328. package/dist/nodes/search.d.ts +0 -117
  329. package/dist/nodes/search.d.ts.map +0 -1
  330. package/dist/nodes/search.js +0 -607
  331. package/dist/nodes/search.js.map +0 -1
  332. package/dist/nodes/team.d.ts +0 -74
  333. package/dist/nodes/team.d.ts.map +0 -1
  334. package/dist/nodes/team.js +0 -309
  335. package/dist/nodes/team.js.map +0 -1
  336. package/dist/nodes/text-extra.d.ts +0 -633
  337. package/dist/nodes/text-extra.d.ts.map +0 -1
  338. package/dist/nodes/text-extra.js +0 -2226
  339. package/dist/nodes/text-extra.js.map +0 -1
  340. package/dist/nodes/tool-agents.d.ts +0 -334
  341. package/dist/nodes/tool-agents.d.ts.map +0 -1
  342. package/dist/nodes/tool-agents.js +0 -1861
  343. package/dist/nodes/tool-agents.js.map +0 -1
  344. package/dist/nodes/triggers.d.ts +0 -107
  345. package/dist/nodes/triggers.d.ts.map +0 -1
  346. package/dist/nodes/triggers.js +0 -706
  347. package/dist/nodes/triggers.js.map +0 -1
  348. package/dist/nodes/vector.d.ts +0 -168
  349. package/dist/nodes/vector.d.ts.map +0 -1
  350. package/dist/nodes/vector.js +0 -1121
  351. package/dist/nodes/vector.js.map +0 -1
  352. package/dist/nodes/video.d.ts +0 -387
  353. package/dist/nodes/video.d.ts.map +0 -1
  354. package/dist/nodes/video.js +0 -2383
  355. package/dist/nodes/video.js.map +0 -1
  356. package/dist/nodes/workflow.d.ts +0 -24
  357. package/dist/nodes/workflow.d.ts.map +0 -1
  358. package/dist/nodes/workflow.js +0 -146
  359. package/dist/nodes/workflow.js.map +0 -1
  360. package/dist/nodes/workspace.d.ts +0 -203
  361. package/dist/nodes/workspace.d.ts.map +0 -1
  362. package/dist/nodes/workspace.js +0 -795
  363. package/dist/nodes/workspace.js.map +0 -1
@@ -1,968 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { BaseNode, prop } from "@nodetool-ai/node-sdk";
8
- import { isChunkItem, isToolCallItem, serializeToolResult, streamProviderMessages, toProviderTools } from "./agents.js";
9
- function asText(value) {
10
- if (typeof value === "string")
11
- return value;
12
- if (typeof value === "number" || typeof value === "boolean")
13
- return String(value);
14
- if (!value)
15
- return "";
16
- return JSON.stringify(value);
17
- }
18
- function parseRequestedCount(prompt, fallback) {
19
- const m = prompt.match(/\b(\d{1,3})\b/);
20
- if (!m)
21
- return fallback;
22
- const n = Number(m[1]);
23
- if (!Number.isFinite(n))
24
- return fallback;
25
- return Math.max(1, Math.min(200, Math.floor(n)));
26
- }
27
- function parseColumns(input) {
28
- return parseColumnSpecs(input).map((column) => column.name);
29
- }
30
- function parseColumnSpecs(input) {
31
- if (Array.isArray(input)) {
32
- return input
33
- .map((c) => {
34
- if (c && typeof c === "object") {
35
- const record = c;
36
- const name = typeof record.name === "string"
37
- ? record.name
38
- : String(record.name ?? "");
39
- const dataType = typeof record.data_type === "string"
40
- ? record.data_type
41
- : typeof record.type === "string"
42
- ? record.type
43
- : undefined;
44
- return { name, data_type: dataType };
45
- }
46
- return { name: String(c) };
47
- })
48
- .filter((c) => c.name.length > 0);
49
- }
50
- if (input && typeof input === "object") {
51
- const columns = input.columns;
52
- if (Array.isArray(columns))
53
- return parseColumnSpecs(columns);
54
- }
55
- return [];
56
- }
57
- function makeRows(columns, count, seedText) {
58
- const names = columns.length > 0 ? columns : ["value"];
59
- const rows = [];
60
- for (let i = 0; i < count; i += 1) {
61
- const row = {};
62
- for (const col of names) {
63
- const lower = col.toLowerCase();
64
- if (lower.includes("id"))
65
- row[col] = i + 1;
66
- else if (lower.includes("name"))
67
- row[col] = `${seedText || "item"}_${i + 1}`;
68
- else if (lower.includes("date"))
69
- row[col] = new Date(Date.now() + i * 86_400_000).toISOString();
70
- else if (lower.includes("price") ||
71
- lower.includes("amount") ||
72
- lower.includes("score")) {
73
- row[col] = Number((10 + i * 1.5).toFixed(2));
74
- }
75
- else if (lower.includes("active") || lower.startsWith("is_")) {
76
- row[col] = i % 2 === 0;
77
- }
78
- else
79
- row[col] = `${seedText || "value"}_${i + 1}`;
80
- }
81
- rows.push(row);
82
- }
83
- return rows;
84
- }
85
- function buildSchemaFromDynamicOutputs(outputs) {
86
- if (!outputs || typeof outputs !== "object" || Array.isArray(outputs))
87
- return null;
88
- const properties = {};
89
- const required = [];
90
- for (const [name, spec] of Object.entries(outputs)) {
91
- required.push(name);
92
- const value = spec && typeof spec === "object" ? spec : {};
93
- const declared = typeof value.type === "string" ? value.type.toLowerCase() : "str";
94
- let type = "string";
95
- if (["int", "integer"].includes(declared))
96
- type = "integer";
97
- else if (["float", "number"].includes(declared))
98
- type = "number";
99
- else if (["bool", "boolean"].includes(declared))
100
- type = "boolean";
101
- else if (["list", "array"].includes(declared))
102
- type = "array";
103
- else if (["dict", "object"].includes(declared))
104
- type = "object";
105
- properties[name] = { type };
106
- }
107
- if (required.length === 0)
108
- return null;
109
- return { type: "object", additionalProperties: false, required, properties };
110
- }
111
- function normalizeBinaryRef(value) {
112
- if (!value || typeof value !== "object")
113
- return null;
114
- const record = value;
115
- const out = {};
116
- if (typeof record.uri === "string" && record.uri)
117
- out.uri = record.uri;
118
- if (record.data instanceof Uint8Array || typeof record.data === "string")
119
- out.data = record.data;
120
- if (typeof record.mimeType === "string" && record.mimeType)
121
- out.mimeType = record.mimeType;
122
- if (typeof record.mime_type === "string" && record.mime_type)
123
- out.mimeType = record.mime_type;
124
- return out.uri || out.data ? out : null;
125
- }
126
- function buildMessageContent(text, image, audio) {
127
- const imageRef = normalizeBinaryRef(image);
128
- const audioRef = normalizeBinaryRef(audio);
129
- if (!imageRef && !audioRef)
130
- return text;
131
- const parts = [{ type: "text", text }];
132
- if (imageRef)
133
- parts.push({ type: "image", image: imageRef });
134
- if (audioRef)
135
- parts.push({ type: "audio", audio: audioRef });
136
- return parts;
137
- }
138
- function getModelConfig(props) {
139
- const model = (props.model ?? {}) ?? {};
140
- return {
141
- providerId: typeof model.provider === "string" ? model.provider : "",
142
- modelId: typeof model.id === "string" ? model.id : ""
143
- };
144
- }
145
- function hasProviderSupport(context, providerId, modelId) {
146
- return (!!context &&
147
- typeof context.runProviderPrediction === "function" &&
148
- typeof context.streamProviderPrediction === "function" &&
149
- !!providerId &&
150
- !!modelId);
151
- }
152
- const LIST_GENERATOR_SYSTEM_PROMPT = "You generate a list by calling the `add_item` tool exactly once per item. " +
153
- "Each call submits a single item as a short string. " +
154
- "Continue calling `add_item` until all requested items have been emitted. " +
155
- "If the user does not specify a count, emit 5 items. " +
156
- "Do not output prose, explanations, or markdown — only emit tool calls. " +
157
- "When the list is complete, stop without calling the tool again.";
158
- function makeAddItemTool() {
159
- return {
160
- name: "add_item",
161
- description: "Add one item to the output list. Call this once per item in the list.",
162
- inputSchema: {
163
- type: "object",
164
- additionalProperties: false,
165
- required: ["item"],
166
- properties: {
167
- item: {
168
- type: "string",
169
- description: "The list item content (a single string)."
170
- }
171
- }
172
- },
173
- process: async (_ctx, params) => {
174
- const item = asText(params?.item ?? "");
175
- return { ok: true, item };
176
- }
177
- };
178
- }
179
- async function* streamListItemsViaToolCalls(context, providerId, modelId, prompt, maxTokens) {
180
- const provider = await context.getProvider(providerId);
181
- const tool = makeAddItemTool();
182
- const providerTools = toProviderTools([tool]);
183
- const messages = [
184
- { role: "system", content: LIST_GENERATOR_SYSTEM_PROMPT },
185
- { role: "user", content: prompt }
186
- ];
187
- const maxIterations = parseRequestedCount(prompt, 5);
188
- for (let iteration = 0; iteration < maxIterations; iteration += 1) {
189
- const assistantToolCalls = [];
190
- let assistantText = "";
191
- for await (const item of streamProviderMessages(provider, {
192
- messages,
193
- model: modelId,
194
- tools: providerTools,
195
- maxTokens
196
- })) {
197
- if (isToolCallItem(item)) {
198
- assistantToolCalls.push(item);
199
- if (item.name === "add_item") {
200
- const text = asText(item.args?.item ?? "").trim();
201
- if (text) {
202
- yield text;
203
- }
204
- }
205
- }
206
- else if (isChunkItem(item) && !item.thinking) {
207
- // Narrative text is ignored for output, but kept in the conversation
208
- // history so providers can continue after tool calls correctly.
209
- assistantText += item.content ?? "";
210
- }
211
- }
212
- if (assistantToolCalls.length === 0) {
213
- break;
214
- }
215
- messages.push({
216
- role: "assistant",
217
- content: assistantText || null,
218
- toolCalls: assistantToolCalls
219
- });
220
- for (const toolCall of assistantToolCalls) {
221
- const result = toolCall.name === "add_item" && typeof tool.process === "function"
222
- ? await tool.process(context, toolCall.args)
223
- : { error: `Unknown tool: ${toolCall.name}` };
224
- messages.push({
225
- role: "tool",
226
- toolCallId: toolCall.id,
227
- content: JSON.stringify(serializeToolResult(result))
228
- });
229
- }
230
- }
231
- }
232
- function dataframeFromRows(rows, columnsInput) {
233
- const names = rows.length > 0
234
- ? Object.keys(rows[0])
235
- : parseColumnSpecs(columnsInput).map((s) => s.name);
236
- return {
237
- rows,
238
- columns: names.map((name) => ({ name })),
239
- data: rows.map((row) => names.map((name) => row[name] ?? null))
240
- };
241
- }
242
- function parseCsv(text, specs) {
243
- const lines = text
244
- .split(/\r?\n/)
245
- .map((l) => l.trim())
246
- .filter((l) => l.length > 0 && !l.startsWith("```"));
247
- if (lines.length < 2)
248
- return [];
249
- const header = lines[0].split(",").map((h) => h.trim().replace(/^"|"$/g, ""));
250
- return lines.slice(1).map((line) => {
251
- const cells = line.match(/(".*?"|[^,]+|(?<=,)(?=,)|(?<=,)$|^(?=,))/g) ??
252
- line.split(",");
253
- const row = {};
254
- header.forEach((name, i) => {
255
- const raw = (cells[i] ?? "").trim().replace(/^"|"$/g, "");
256
- const spec = specs.find((s) => s.name === name);
257
- const kind = (spec?.data_type ?? "").toLowerCase();
258
- if (kind === "int" || kind === "integer") {
259
- const n = Number.parseInt(raw, 10);
260
- row[name] = Number.isFinite(n) ? n : raw;
261
- }
262
- else if (kind === "float" || kind === "number") {
263
- const n = Number.parseFloat(raw);
264
- row[name] = Number.isFinite(n) ? n : raw;
265
- }
266
- else {
267
- row[name] = raw;
268
- }
269
- });
270
- return row;
271
- });
272
- }
273
- async function generateDataframeFromCsv(context, providerId, modelId, prompt, columnsInput, count, maxTokens) {
274
- const specs = parseColumnSpecs(columnsInput);
275
- const columnHint = specs.length > 0
276
- ? `Use exactly these columns: ${specs.map((s) => s.name).join(", ")}.`
277
- : "Choose appropriate columns for the data.";
278
- const systemPrompt = `You are a data generator. Return ONLY a CSV with a header row and exactly ${count} data rows. No explanation, no markdown fences, no extra text. ${columnHint}`;
279
- const result = await context.runProviderPrediction({
280
- provider: providerId,
281
- capability: "generate_message",
282
- model: modelId,
283
- params: {
284
- model: modelId,
285
- messages: [
286
- { role: "system", content: systemPrompt },
287
- { role: "user", content: prompt }
288
- ],
289
- max_tokens: maxTokens
290
- }
291
- });
292
- const content = asText(result.content ?? result);
293
- return parseCsv(content, specs);
294
- }
295
- export class StructuredOutputGeneratorNode extends BaseNode {
296
- static nodeType = "nodetool.generators.StructuredOutputGenerator";
297
- static title = "Structured Output Generator";
298
- static description = "Generate structured JSON objects from instructions using LLM providers.\n data-generation, structured-data, json, synthesis\n\n Specialized for creating structured information:\n - Generating JSON that follows dynamic schemas\n - Fabricating records from requirements and guidance\n - Simulating sample data for downstream workflows\n - Producing consistent structured outputs for testing";
299
- static basicFields = ["instructions", "context", "model"];
300
- static supportsDynamicOutputs = true;
301
- async process(context) {
302
- const { providerId, modelId } = getModelConfig(this.serialize());
303
- const schema = buildSchemaFromDynamicOutputs(this._dynamic_outputs);
304
- if (schema && hasProviderSupport(context, providerId, modelId)) {
305
- const instructions = asText(this.instructions ?? this.instructions ?? "");
306
- const extraContext = asText(this.context ?? this.context ?? "");
307
- const systemPrompt = asText(this.system_prompt ?? "");
308
- const userText = [instructions, extraContext]
309
- .filter(Boolean)
310
- .join("\n\n");
311
- const messages = [];
312
- if (systemPrompt) {
313
- messages.push({ role: "system", content: systemPrompt });
314
- }
315
- messages.push({
316
- role: "user",
317
- content: buildMessageContent(userText, this.image, this.audio)
318
- });
319
- const result = await context.runProviderPrediction({
320
- provider: providerId,
321
- capability: "generate_message",
322
- model: modelId,
323
- params: {
324
- model: modelId,
325
- messages,
326
- response_format: {
327
- type: "json_schema",
328
- json_schema: {
329
- name: "structured_output",
330
- schema
331
- }
332
- }
333
- }
334
- });
335
- if (result &&
336
- typeof result === "object" &&
337
- "content" in result) {
338
- const content = asText(result.content ?? "");
339
- try {
340
- return JSON.parse(content);
341
- }
342
- catch {
343
- return { output: content };
344
- }
345
- }
346
- }
347
- if (schema && typeof schema === "object" && !Array.isArray(schema)) {
348
- const props = schema.properties ?? {};
349
- const out = {};
350
- for (const key of Object.keys(props)) {
351
- const spec = props[key];
352
- if (spec?.type === "number" || spec?.type === "integer")
353
- out[key] = 0;
354
- else if (spec?.type === "boolean")
355
- out[key] = false;
356
- else if (spec?.type === "array")
357
- out[key] = [];
358
- else if (spec?.type === "object")
359
- out[key] = {};
360
- else
361
- out[key] = "";
362
- }
363
- return out;
364
- }
365
- const instructions = asText(this.instructions ?? this.instructions ?? "");
366
- const contextText = asText(this.context ?? this.context ?? "");
367
- return {
368
- output: {
369
- instructions,
370
- context: contextText
371
- }
372
- };
373
- }
374
- }
375
- __decorate([
376
- prop({
377
- type: "str",
378
- default: "\nYou are a structured data generator focused on JSON outputs.\n\nGoal\n- Produce a high-quality JSON object that matches <JSON_SCHEMA> using the guidance in <INSTRUCTIONS> and any supplemental <CONTEXT>.\n\nOutput format (MANDATORY)\n- Output exactly ONE fenced code block labeled json containing ONLY the JSON object:\n\n ```json\n { ...single JSON object matching <JSON_SCHEMA>... }\n ```\n\n- No additional prose before or after the block.\n\nGeneration rules\n- Invent plausible, internally consistent values when not explicitly provided.\n- Honor all constraints from <JSON_SCHEMA> (types, enums, ranges, formats).\n- Prefer ISO 8601 for dates/times when applicable.\n- Ensure numbers respect reasonable magnitudes and relationships described in <INSTRUCTIONS>.\n- Avoid referencing external sources; rely solely on the provided guidance.\n\nValidation\n- Ensure the final JSON validates against <JSON_SCHEMA> exactly.\n",
379
- title: "System Prompt",
380
- description: "The system prompt guiding JSON generation."
381
- })
382
- ], StructuredOutputGeneratorNode.prototype, "system_prompt", void 0);
383
- __decorate([
384
- prop({
385
- type: "language_model",
386
- default: {
387
- type: "language_model",
388
- provider: "empty",
389
- id: "",
390
- name: "",
391
- path: null,
392
- supported_tasks: []
393
- },
394
- title: "Model",
395
- description: "Model to use for structured generation."
396
- })
397
- ], StructuredOutputGeneratorNode.prototype, "model", void 0);
398
- __decorate([
399
- prop({
400
- type: "str",
401
- default: "",
402
- title: "Instructions",
403
- description: "Detailed instructions for the structured output."
404
- })
405
- ], StructuredOutputGeneratorNode.prototype, "instructions", void 0);
406
- __decorate([
407
- prop({
408
- type: "str",
409
- default: "",
410
- title: "Context",
411
- description: "Optional context to ground the generation."
412
- })
413
- ], StructuredOutputGeneratorNode.prototype, "context", void 0);
414
- __decorate([
415
- prop({
416
- type: "int",
417
- default: 4096,
418
- title: "Max Tokens",
419
- description: "The maximum number of tokens to generate.",
420
- min: 1,
421
- max: 16384
422
- })
423
- ], StructuredOutputGeneratorNode.prototype, "max_tokens", void 0);
424
- __decorate([
425
- prop({
426
- type: "image",
427
- default: {
428
- type: "image",
429
- uri: "",
430
- asset_id: null,
431
- data: null,
432
- metadata: null
433
- },
434
- title: "Image",
435
- description: "Optional image to include in the generation request."
436
- })
437
- ], StructuredOutputGeneratorNode.prototype, "image", void 0);
438
- __decorate([
439
- prop({
440
- type: "audio",
441
- default: {
442
- type: "audio",
443
- uri: "",
444
- asset_id: null,
445
- data: null,
446
- metadata: null
447
- },
448
- title: "Audio",
449
- description: "Optional audio to include in the generation request."
450
- })
451
- ], StructuredOutputGeneratorNode.prototype, "audio", void 0);
452
- export class DataGeneratorNode extends BaseNode {
453
- static nodeType = "nodetool.generators.DataGenerator";
454
- static title = "Data Generator";
455
- static description = "LLM Agent to create a dataframe based on a user prompt.\n llm, dataframe creation, data structuring\n\n Use cases:\n - Generating structured data from natural language descriptions\n - Creating sample datasets for testing or demonstration\n - Converting unstructured text into tabular format";
456
- static metadataOutputTypes = {
457
- record: "dict",
458
- dataframe: "dataframe",
459
- index: "int"
460
- };
461
- static basicFields = ["prompt", "model", "columns"];
462
- static isStreamingOutput = true;
463
- async process(context) {
464
- const prompt = asText(this.prompt ?? this.prompt ?? "");
465
- const inputText = asText(this.input_text ?? this.input_text ?? "");
466
- const columnsInput = this.columns ?? this.columns;
467
- const columns = parseColumns(columnsInput);
468
- const count = parseRequestedCount(`${prompt} ${inputText}`, 5);
469
- const { providerId, modelId } = getModelConfig(this.serialize());
470
- if (hasProviderSupport(context, providerId, modelId)) {
471
- const rows = await generateDataframeFromCsv(context, providerId, modelId, [prompt, inputText].filter(Boolean).join("\n\n"), columnsInput, count, Number(this.max_tokens ?? 4096));
472
- if (rows.length > 0) {
473
- return { output: dataframeFromRows(rows, columnsInput) };
474
- }
475
- }
476
- const rows = makeRows(columns, count, inputText || prompt || "item");
477
- return { output: dataframeFromRows(rows, columnsInput) };
478
- }
479
- async *genProcess(context) {
480
- const full = await this.process(context);
481
- const rows = (full.output.rows ?? []);
482
- for (let i = 0; i < rows.length; i += 1) {
483
- yield { record: rows[i], index: i, dataframe: null };
484
- }
485
- yield { record: null, index: null, dataframe: full.output };
486
- }
487
- }
488
- __decorate([
489
- prop({
490
- type: "language_model",
491
- default: {
492
- type: "language_model",
493
- provider: "empty",
494
- id: "",
495
- name: "",
496
- path: null,
497
- supported_tasks: []
498
- },
499
- title: "Model",
500
- description: "The model to use for data generation."
501
- })
502
- ], DataGeneratorNode.prototype, "model", void 0);
503
- __decorate([
504
- prop({
505
- type: "str",
506
- default: "",
507
- title: "Prompt",
508
- description: "The user prompt"
509
- })
510
- ], DataGeneratorNode.prototype, "prompt", void 0);
511
- __decorate([
512
- prop({
513
- type: "str",
514
- default: "",
515
- title: "Input Text",
516
- description: "The input text to be analyzed by the agent."
517
- })
518
- ], DataGeneratorNode.prototype, "input_text", void 0);
519
- __decorate([
520
- prop({
521
- type: "int",
522
- default: 4096,
523
- title: "Max Tokens",
524
- description: "The maximum number of tokens to generate.",
525
- min: 1,
526
- max: 100000
527
- })
528
- ], DataGeneratorNode.prototype, "max_tokens", void 0);
529
- __decorate([
530
- prop({
531
- type: "record_type",
532
- default: {
533
- type: "record_type",
534
- columns: []
535
- },
536
- title: "Columns",
537
- description: "The columns to use in the dataframe."
538
- })
539
- ], DataGeneratorNode.prototype, "columns", void 0);
540
- export class ListGeneratorNode extends BaseNode {
541
- static nodeType = "nodetool.generators.ListGenerator";
542
- static title = "List Generator";
543
- static description = "LLM Agent to create a stream of strings based on a user prompt.\n llm, text streaming\n\n Use cases:\n - Generating text from natural language descriptions\n - Streaming responses from an LLM";
544
- static metadataOutputTypes = {
545
- item: "str",
546
- index: "int"
547
- };
548
- static basicFields = ["prompt", "model"];
549
- static isStreamingOutput = true;
550
- async process(context) {
551
- const items = [];
552
- for await (const chunk of this.genProcess(context)) {
553
- const item = chunk.item;
554
- if (typeof item === "string")
555
- items.push(item);
556
- }
557
- return { output: items };
558
- }
559
- async *genProcess(context) {
560
- const prompt = asText(this.prompt ?? "");
561
- const inputText = asText(this.input_text ?? "");
562
- const userMessage = [prompt, inputText].filter(Boolean).join("\n\n");
563
- const { providerId, modelId } = getModelConfig(this.serialize());
564
- if (context &&
565
- typeof context.getProvider === "function" &&
566
- providerId &&
567
- modelId) {
568
- let index = 0;
569
- for await (const item of streamListItemsViaToolCalls(context, providerId, modelId, userMessage, Number(this.max_tokens ?? 128))) {
570
- yield { item, index };
571
- index += 1;
572
- }
573
- if (index === 0) {
574
- throw new Error("Model returned no add_item tool calls — list is empty.");
575
- }
576
- return;
577
- }
578
- const seed = inputText || prompt || "item";
579
- const count = parseRequestedCount(userMessage, 5);
580
- for (let i = 0; i < count; i += 1) {
581
- yield { item: `${seed}_${i + 1}`, index: i };
582
- }
583
- }
584
- }
585
- __decorate([
586
- prop({
587
- type: "language_model",
588
- default: {
589
- type: "language_model",
590
- provider: "empty",
591
- id: "",
592
- name: "",
593
- path: null,
594
- supported_tasks: []
595
- },
596
- title: "Model",
597
- description: "The model to use for string generation."
598
- })
599
- ], ListGeneratorNode.prototype, "model", void 0);
600
- __decorate([
601
- prop({
602
- type: "str",
603
- default: "",
604
- title: "Prompt",
605
- description: "The user prompt"
606
- })
607
- ], ListGeneratorNode.prototype, "prompt", void 0);
608
- __decorate([
609
- prop({
610
- type: "str",
611
- default: "",
612
- title: "Input Text",
613
- description: "The input text to be analyzed by the agent."
614
- })
615
- ], ListGeneratorNode.prototype, "input_text", void 0);
616
- __decorate([
617
- prop({
618
- type: "int",
619
- default: 4096,
620
- title: "Max Tokens",
621
- description: "The maximum number of tokens to generate.",
622
- min: 1,
623
- max: 100000
624
- })
625
- ], ListGeneratorNode.prototype, "max_tokens", void 0);
626
- export class ChartGeneratorNode extends BaseNode {
627
- static nodeType = "nodetool.generators.ChartGenerator";
628
- static title = "Chart Generator";
629
- static description = "LLM Agent to create Plotly Express charts based on natural language descriptions.\n llm, data visualization, charts\n\n Use cases:\n - Generating interactive charts from natural language descriptions\n - Creating data visualizations with minimal configuration\n - Converting data analysis requirements into visual representations";
630
- static metadataOutputTypes = {
631
- output: "chart_config"
632
- };
633
- static basicFields = ["prompt", "data", "model"];
634
- async process(context) {
635
- const prompt = asText(this.prompt ?? this.prompt ?? "");
636
- const data = this.data ?? this.data ?? { rows: [] };
637
- const rows = Array.isArray(data.rows)
638
- ? (data.rows ?? [])
639
- : [];
640
- const keys = rows.length > 0 ? Object.keys(rows[0]) : [];
641
- const xKey = keys[0] ?? "x";
642
- const yKey = keys[1] ?? xKey;
643
- const { providerId, modelId } = getModelConfig(this.serialize());
644
- if (hasProviderSupport(context, providerId, modelId)) {
645
- const dataSample = rows.length > 0
646
- ? `Data columns: ${keys.join(", ")}\nSample rows:\n${JSON.stringify(rows.slice(0, 5), null, 2)}`
647
- : "No data provided.";
648
- const systemPrompt = `You are a Plotly visualization expert. Given a user's description and optional data, generate a Plotly chart configuration as JSON.
649
- The JSON must conform to the provided schema. Choose appropriate chart types (bar, line, scatter, pie, histogram, box, heatmap, etc.) based on the user's description.
650
- Use the data columns provided to set x_column, y_column, and label fields in the series array.
651
- Set a descriptive title, axis labels, and legend settings.`;
652
- const userMessage = `${prompt}\n\n${dataSample}`;
653
- const chartSchema = {
654
- type: "object",
655
- additionalProperties: false,
656
- required: ["title", "x_label", "y_label", "legend", "data"],
657
- properties: {
658
- title: { type: "string" },
659
- x_label: { type: "string" },
660
- y_label: { type: "string" },
661
- legend: { type: "boolean" },
662
- legend_position: { type: "string" },
663
- data: {
664
- type: "object",
665
- additionalProperties: false,
666
- required: ["series"],
667
- properties: {
668
- series: {
669
- type: "array",
670
- items: {
671
- type: "object",
672
- additionalProperties: false,
673
- required: ["type", "x_column", "y_column", "label"],
674
- properties: {
675
- type: { type: "string" },
676
- x_column: { type: "string" },
677
- y_column: { type: "string" },
678
- label: { type: "string" }
679
- }
680
- }
681
- }
682
- }
683
- }
684
- }
685
- };
686
- const result = await context.runProviderPrediction({
687
- provider: providerId,
688
- capability: "generate_message",
689
- model: modelId,
690
- params: {
691
- model: modelId,
692
- messages: [
693
- { role: "system", content: systemPrompt },
694
- { role: "user", content: userMessage }
695
- ],
696
- max_tokens: Number(this.max_tokens ?? 4096),
697
- response_format: {
698
- type: "json_schema",
699
- json_schema: {
700
- name: "chart_config",
701
- schema: chartSchema
702
- }
703
- }
704
- }
705
- });
706
- const content = asText(result.content ?? result);
707
- try {
708
- const parsed = JSON.parse(content);
709
- return {
710
- output: {
711
- type: "chart_config",
712
- ...parsed,
713
- data: {
714
- type: "chart_data",
715
- ...(parsed.data ?? {}),
716
- row: null,
717
- col: null,
718
- col_wrap: null
719
- },
720
- height: null,
721
- aspect: null,
722
- x_lim: null,
723
- y_lim: null,
724
- x_scale: null,
725
- y_scale: null,
726
- palette: null,
727
- hue_order: null,
728
- hue_norm: null,
729
- sizes: null,
730
- size_order: null,
731
- size_norm: null,
732
- marginal_kws: null,
733
- joint_kws: null,
734
- diag_kind: null,
735
- corner: false,
736
- center: null,
737
- vmin: null,
738
- vmax: null,
739
- cmap: null,
740
- annot: false,
741
- fmt: ".2g",
742
- square: false
743
- }
744
- };
745
- }
746
- catch {
747
- // Fall through to hardcoded fallback
748
- }
749
- }
750
- return {
751
- output: {
752
- type: "chart_config",
753
- title: prompt || "Generated Chart",
754
- x_label: xKey,
755
- y_label: yKey,
756
- legend: true,
757
- data: {
758
- type: "chart_data",
759
- series: [
760
- {
761
- type: "bar",
762
- x_column: xKey,
763
- y_column: yKey,
764
- label: prompt || "series"
765
- }
766
- ],
767
- row: null,
768
- col: null,
769
- col_wrap: null
770
- },
771
- height: null,
772
- aspect: null,
773
- x_lim: null,
774
- y_lim: null,
775
- x_scale: null,
776
- y_scale: null,
777
- legend_position: "auto",
778
- palette: null,
779
- hue_order: null,
780
- hue_norm: null,
781
- sizes: null,
782
- size_order: null,
783
- size_norm: null,
784
- marginal_kws: null,
785
- joint_kws: null,
786
- diag_kind: null,
787
- corner: false,
788
- center: null,
789
- vmin: null,
790
- vmax: null,
791
- cmap: null,
792
- annot: false,
793
- fmt: ".2g",
794
- square: false
795
- }
796
- };
797
- }
798
- }
799
- __decorate([
800
- prop({
801
- type: "language_model",
802
- default: {
803
- type: "language_model",
804
- provider: "empty",
805
- id: "",
806
- name: "",
807
- path: null,
808
- supported_tasks: []
809
- },
810
- title: "Model",
811
- description: "The model to use for chart generation."
812
- })
813
- ], ChartGeneratorNode.prototype, "model", void 0);
814
- __decorate([
815
- prop({
816
- type: "str",
817
- default: "",
818
- title: "Prompt",
819
- description: "Natural language description of the desired chart"
820
- })
821
- ], ChartGeneratorNode.prototype, "prompt", void 0);
822
- __decorate([
823
- prop({
824
- type: "dataframe",
825
- default: {
826
- type: "dataframe",
827
- uri: "",
828
- asset_id: null,
829
- data: null,
830
- metadata: null,
831
- columns: null
832
- },
833
- title: "Data",
834
- description: "The data to visualize"
835
- })
836
- ], ChartGeneratorNode.prototype, "data", void 0);
837
- __decorate([
838
- prop({
839
- type: "int",
840
- default: 4096,
841
- title: "Max Tokens",
842
- description: "The maximum number of tokens to generate.",
843
- min: 1,
844
- max: 100000
845
- })
846
- ], ChartGeneratorNode.prototype, "max_tokens", void 0);
847
- export class SVGGeneratorNode extends BaseNode {
848
- static nodeType = "nodetool.generators.SVGGenerator";
849
- static title = "SVGGenerator";
850
- static description = "LLM Agent to create SVG elements based on user prompts.\n svg, generator, vector, graphics\n\n Use cases:\n - Creating vector graphics from text descriptions\n - Generating scalable illustrations\n - Creating custom icons and diagrams";
851
- static metadataOutputTypes = {
852
- output: "list[svg_element]"
853
- };
854
- static basicFields = ["prompt", "image", "audio", "model"];
855
- async process(context) {
856
- const prompt = asText(this.prompt ?? this.prompt ?? "");
857
- const width = Number(this.width ?? 512) || 512;
858
- const height = Number(this.height ?? 512) || 512;
859
- const { providerId, modelId } = getModelConfig(this.serialize());
860
- if (hasProviderSupport(context, providerId, modelId)) {
861
- const systemPrompt = `You are an SVG graphics expert. Generate SVG markup based on the user's description.
862
- Return one or more complete <svg>...</svg> elements. Each SVG should use the xmlns="http://www.w3.org/2000/svg" attribute.
863
- Default canvas size is ${width}x${height} unless the user specifies otherwise.
864
- Output only SVG markup, no explanations or markdown fences.`;
865
- const messages = [
866
- { role: "system", content: systemPrompt },
867
- {
868
- role: "user",
869
- content: buildMessageContent(prompt, this.image, this.audio)
870
- }
871
- ];
872
- const result = await context.runProviderPrediction({
873
- provider: providerId,
874
- capability: "generate_message",
875
- model: modelId,
876
- params: {
877
- model: modelId,
878
- messages,
879
- max_tokens: Number(this.max_tokens ?? 8192)
880
- }
881
- });
882
- const content = asText(result.content ?? result);
883
- const svgMatches = Array.from(content.matchAll(/<svg[\s\S]*?<\/svg>/gi));
884
- if (svgMatches.length > 0) {
885
- return {
886
- output: svgMatches.map((m) => ({ content: m[0] }))
887
- };
888
- }
889
- }
890
- // Fallback: generate a simple placeholder SVG
891
- const text = prompt || "SVG";
892
- const safeText = text
893
- .replace(/&/g, "&amp;")
894
- .replace(/</g, "&lt;")
895
- .replace(/>/g, "&gt;");
896
- const svg = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" fill="#f2f2f2"/><text x="16" y="32" font-size="20" fill="#111">${safeText}</text></svg>`;
897
- return { output: [{ content: svg }] };
898
- }
899
- }
900
- __decorate([
901
- prop({
902
- type: "language_model",
903
- default: {
904
- type: "language_model",
905
- provider: "empty",
906
- id: "",
907
- name: "",
908
- path: null,
909
- supported_tasks: []
910
- },
911
- title: "Model",
912
- description: "The language model to use for SVG generation."
913
- })
914
- ], SVGGeneratorNode.prototype, "model", void 0);
915
- __decorate([
916
- prop({
917
- type: "str",
918
- default: "",
919
- title: "Prompt",
920
- description: "The user prompt for SVG generation"
921
- })
922
- ], SVGGeneratorNode.prototype, "prompt", void 0);
923
- __decorate([
924
- prop({
925
- type: "image",
926
- default: {
927
- type: "image",
928
- uri: "",
929
- asset_id: null,
930
- data: null,
931
- metadata: null
932
- },
933
- title: "Image",
934
- description: "Image to use for generation"
935
- })
936
- ], SVGGeneratorNode.prototype, "image", void 0);
937
- __decorate([
938
- prop({
939
- type: "audio",
940
- default: {
941
- type: "audio",
942
- uri: "",
943
- asset_id: null,
944
- data: null,
945
- metadata: null
946
- },
947
- title: "Audio",
948
- description: "Audio to use for generation"
949
- })
950
- ], SVGGeneratorNode.prototype, "audio", void 0);
951
- __decorate([
952
- prop({
953
- type: "int",
954
- default: 8192,
955
- title: "Max Tokens",
956
- description: "The maximum number of tokens to generate.",
957
- min: 1,
958
- max: 100000
959
- })
960
- ], SVGGeneratorNode.prototype, "max_tokens", void 0);
961
- export const GENERATOR_NODES = [
962
- StructuredOutputGeneratorNode,
963
- DataGeneratorNode,
964
- ListGeneratorNode,
965
- ChartGeneratorNode,
966
- SVGGeneratorNode
967
- ];
968
- //# sourceMappingURL=generators.js.map