fun-node-registry.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * fun 结点注册表:新增结点只需 1)在 actions/fun/ 新建脚本(只实现 executeXxx(input),入参由 in 规定、出参由 out 规定)2)在此添加一条配置。
  3. * 通用逻辑(解析 inVars、取值、写回 variableContext、logOutVars)由 fun-parser 统一处理,脚本不写 parseNode/runNode。
  4. * 配置项:type, category, in(入参名数组), inAlt?(字段别名), execute(脚本导出的函数名), script?(默认 type+'.js'), displayName?。出参由工作流 action.outVars[0] 指定。
  5. * 仅当需要完全自定义解析或执行时,才配 customParse/customRun 并在脚本中导出 parseNode、runNode。
  6. */
  7. module.exports = [
  8. {
  9. type: 'download',
  10. category: 'io',
  11. in: ['url', 'savePath'],
  12. inAlt: { savePath: 'save-path' },
  13. execute: 'executeDownload',
  14. script: 'download.js',
  15. },
  16. { type: 'text2text', category: 'io', in: ['prompt', 'model'], execute: 'executeText2text', script: 'ai/text2text.js', displayName: 'ai text2text' },
  17. { type: 'img2text', category: 'io', in: ['prompt', 'model', 'imageUrl'], execute: 'executeImg2text', script: 'ai/img2text.js', displayName: 'ai img2text' },
  18. { type: 'text2img', category: 'io', in: ['prompt', 'model', 'savePath'], execute: 'executeText2img', script: 'ai/text2img.js', displayName: 'ai text2img' },
  19. { type: 'img2img', category: 'io', in: ['prompt', 'model', 'imageUrl', 'savePath'], execute: 'executeImg2img', script: 'ai/img2img.js', displayName: 'ai img2img' },
  20. { type: 'json', category: 'io', in: ['jsonString'], execute: 'executeJsonToArr', script: 'json/json-to-arr.js', displayName: 'json to arr' },
  21. { type: 'download-img', category: 'io', in: ['prompt', 'savePath'], inAlt: { savePath: 'save-path' }, execute: 'executeDownloadImg', script: 'download-img.js', displayName: 'download img by prompt' },
  22. {
  23. type: 'img-scale',
  24. category: 'io',
  25. in: ['imagePath', 'savePath', 'scale'],
  26. inAlt: { savePath: 'save-path', imagePath: 'image-path', scale: 'scale-factor' },
  27. execute: 'executeImgScale',
  28. script: 'img/img-scale.js',
  29. displayName: 'img scale proportional',
  30. },
  31. {
  32. type: 'create-folder',
  33. category: 'io',
  34. in: ['path'],
  35. inAlt: { path: 'dirPath' },
  36. execute: 'executeCreateFolder',
  37. script: 'IO/create-forder.js',
  38. displayName: 'create folder',
  39. },
  40. {
  41. type: 'remove-folder',
  42. category: 'io',
  43. in: ['path'],
  44. inAlt: { path: 'dirPath' },
  45. execute: 'executeRemoveFolder',
  46. script: 'IO/remove-forder.js',
  47. displayName: 'remove folder',
  48. },
  49. ]