ai运算卡:-AI工作流结合低代码实现卡片渲染 - }#mermaid-svg-A3uJq5xJZdQySZh1
目标实现类似core绑定自定义卡片渲染的效果。
从0到1开发低代码平台相对耗时间。于是考虑实现阿里的低代码引擎。
低代码引擎 | LowCodeEngine
整体的实现流程:
#mermaid-svg-A3uJq5xJZdQySZh1 {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-A3uJq5xJZdQySZh1 .error-icon{fill:#552222;}#mermaid-svg-A3uJq5xJZdQySZh1 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-A3uJq5xJZdQySZh1 .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-A3uJq5xJZdQySZh1 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-A3uJq5xJZdQySZh1 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-A3uJq5xJZdQySZh1 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-A3uJq5xJZdQySZh1 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-A3uJq5xJZdQySZh1 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-A3uJq5xJZdQySZh1 .marker.cross{stroke:#333333;}#mermaid-svg-A3uJq5xJZdQySZh1 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-A3uJq5xJZdQySZh1 .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-A3uJq5xJZdQySZh1 text.actor>tspan{fill:black;stroke:none;}#mermaid-svg-A3uJq5xJZdQySZh1 .actor-line{stroke:grey;}#mermaid-svg-A3uJq5xJZdQySZh1 .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg-A3uJq5xJZdQySZh1 .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg-A3uJq5xJZdQySZh1 #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg-A3uJq5xJZdQySZh1 .sequenceNumber{fill:white;}#mermaid-svg-A3uJq5xJZdQySZh1 #sequencenumber{fill:#333;}#mermaid-svg-A3uJq5xJZdQySZh1 #crosshead path{fill:#333;stroke:#333;}#mermaid-svg-A3uJq5xJZdQySZh1 .messageText{fill:#333;stroke:#333;}#mermaid-svg-A3uJq5xJZdQySZh1 .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-A3uJq5xJZdQySZh1 .labelText,#mermaid-svg-A3uJq5xJZdQySZh1 .labelText>tspan{fill:black;stroke:none;}#mermaid-svg-A3uJq5xJZdQySZh1 .loopText,#mermaid-svg-A3uJq5xJZdQySZh1 .loopText>tspan{fill:black;stroke:none;}#mermaid-svg-A3uJq5xJZdQySZh1 .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-A3uJq5xJZdQySZh1 .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-A3uJq5xJZdQySZh1 .noteText,#mermaid-svg-A3uJq5xJZdQySZh1 .noteText>tspan{fill:black;stroke:none;}#mermaid-svg-A3uJq5xJZdQySZh1 .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg-A3uJq5xJZdQySZh1 .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg-A3uJq5xJZdQySZh1 .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg-A3uJq5xJZdQySZh1 .actorPopupMenu{position:absolute;}#mermaid-svg-A3uJq5xJZdQySZh1 .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg-A3uJq5xJZdQySZh1 .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-A3uJq5xJZdQySZh1 .actor-man circle,#mermaid-svg-A3uJq5xJZdQySZh1 line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg-A3uJq5xJZdQySZh1 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}
用户
低代码平台
服务端
AI 工作流
低代码渲染层
创建自定义模板
保存模板文件
返回 temp_id
保存 AI 数据结果(包含 temp_id)
返回保存成功 & 绑定关系确认
访问低代码渲染页面
获取模板内容 (temp_id)
返回模板定义 + 组件配置
请求 AI 数据接口
返回 AI 数据
将数据绑定模板渲染
请求获取已关联 AI 数据 (通过 temp_id)
返回 AI 数据 拼多多帮助力入口
修改 state 注入模板渲染
alt
[模式1:模板内请求数据]
[模式2:渲染层注入数据]
展示 AI + 低代码模板渲染结果
用户
低代码平台
服务端
AI 工作流
低代码渲染层
事实证明是可行。
一些问题
react 版本问题:需要webpack + react17.0.2 编译打包。当然也可以直接使用官方的demo(问题就不会那么多了),做二次修改。代码编辑器插件异常:官方的 @alilc/lowcode-plugin-code-editor 插件使用babel/core 在webpack 5 是存在问题的,所以造轮子基于 recast 、@babel/standalone 实现代码编辑插件。
ai-flow-show/front/src/views/editor/plugins/plugin-code-editor at main · WtecHtec/ai-flow-show
渲染图表的出现报错:
BizCharts something went wrong:
A cross-origin error was thrown. React doesn't have access to the actual error object in development. See https://fb.me/react-crossorigin-error for more information.
这是因为react 使用开发版本的原因,修改:
使用自己编译lowcode-renderer 组件时,通过 npm 安装的方式会产生react 版本不兼容的问题。
ai-flow-show/packages/lowcode-renderer at main · WtecHtec/ai-flow-show
使用方式:
// 通过 umd.js 引用
// 渲染组件
const { LowcodeRenderer, React, ReactDOM } = window.LowcodeRenderer;
ReactDOM.render(
React.createElement(LowcodeRenderer, {
projectSchema: {}
}),
document.getElementById('root')
);