🔥Star 6.2k 支撑 AI 无代码工作流引擎 FlowLong 1.2.3 宣布

开源地址:https://gitee.com/aizuda/flowlong 开源地址:https://github.com/aizuda/flowlong 官网文档:https://flowlong.aizuda.com 更新日志: opt: Spring SPEL 兼容错误配置 opt: 优化支持删除存在的流程定...

应用介绍

  • 开源地址:https://gitee.com/aizuda/flowlong

  • 开源地址:https://github.com/aizuda/flowlong

  • 官网文档:https://flowlong.aizuda.com

更新日记:

  • opt: Spring SPEL 兼容缺点设备

  • opt: 优化支撑删除存在的流程定义及汗青版本相关数据

  • opt: 优化认领义务创建人时光修改为认领人认领时光

  • opt: 优化驳回策略应用列举清除魔法值

  • opt: 优化履行完义务数据传输对象线程变量释放

  • opt: 优化完美的AI审批逻辑

  • opt: 优化完美获取下一步履行节点逻辑

  • @Slf4jpublic class TestAiHandler implements FlowAiHandler {    // 创建一个 AI 智能体处理用户    public static final FlowCreator aiUser = new FlowCreator("1", "AI 智能体");    @Override    public AiResponse execute(FlowLongContext flowLongContext, Execution execution, NodeModel nodeModel) {        AiConfig aiConfig = nodeModel.getAiConfig();        // 1. 构建 Prompt 提示词        if (null != aiConfig) {            System.out.println("AI Prompt Template: " + aiConfig.getPromptTemplate());        }        System.out.println("handle 根据 callAi 辨认处理具体逻辑:" + nodeModel.getCallAi());        // 2. 调用 AI 办事(此处为示例实现,实际需对接真实 AI API)        try {            // TODO: 对接实际的 AI 办事,如 OpenAI、Claude、文心一言等            // AiServiceResponse response = aiService.chat(prompt, aiConfig.getModelParams());            // 返回一个模仿的成功响应,包含决定计划、建议、置信度和指标            return AiResponse.builder()                    .status(AiStatus.SUCCESS)                    .decision("flk17631709068381")                    .advice("AI 审批建议:经分析,该申请相符相干规定,建议经由过程。")                    .confidence(0.95)                    .metrics(AiResponse.AiMetrics.builder()                            .modelName("default-model")                            .promptTokens(100L)                            .completionTokens(50L)                            .totalTimeMs(500L)                            .build())                    .build();        } catch (Exception e) {            log.error("AI processing failed: {}", e.getMessage(), e);            return AiResponse.failure("AI 办事调用掉败: " + e.getMessage());        }    }    /**     * 处理 AI 响应成果     */    @Override    public boolean processAiResponse(FlowLongContext flowLongContext, Execution execution, NodeModel nodeModel, AiResponse aiResponse) {        if (null == aiResponse) {            return this.handleAiFallback(execution, nodeModel, "AI 处理器返回空响应");        }        AiStatus status = aiResponse.getStatus();        // 1. 处理异步情况        if (aiResponse.isAsync()) {            // 异步模式:流程挂起,等待回调            return true;        }        // 获取 AI 设备        AiConfig aiConfig = nodeModel.getAiConfig();        // 2. 归并 AI 提取的变量到履行参数        this.mergeAiVariables(execution, aiResponse, aiConfig);        // 3. 检查置信度        double confidenceThreshold = 0.8;        if (null != aiConfig) {            confidenceThreshold = aiConfig.getConfidenceThresholdOrDefault();        }        if (aiResponse.getConfidenceOrDefault() < confidenceThreshold> flwTasks = execution.getFlwTasks();        for (FlwTask ft : flwTasks) {            // 记录 AI 审批看法相干数据到义务变量(用于汗青记录)            Map args = execution.getArgs();            if (null != args) {                // 审批看法                if (null != aiResponse.getAdvice()) {                    args.put("_ai_advice", aiResponse.getAdvice());                    args.put("_ai_decision", aiResponse.getDecision());                    args.put("_ai_confidence", aiResponse.getConfidenceOrDefault());                }                // 记录指标数据                if (null != aiResponse.getMetrics()) {                    AiResponse.AiMetrics metrics = aiResponse.getMetrics();                    args.put("_ai_model", metrics.getModelName());                    args.put("_ai_tokens", metrics.getTotalTokens());                    args.put("_ai_time_ms", metrics.getTotalTimeMs());                }            }            // AI 建议经由过程,主动完成义务            if (aiResponse.isPass()) {                execution.getEngine().autoCompleteTask(ft.getId(), args, aiUser);            }            // AI 建议拒绝,主动拒绝义务            if (aiResponse.isReject()) {                execution.getEngine().autoRejectTask(ft, args, aiUser);            }        }        // 其他决定计划成果,不主动处理,等待人工介入        return true;    }    /**     * AI 降级处理     */    protected boolean handleAiFallback(Execution execution, NodeModel nodeModel, String reason) {        AiConfig aiConfig = nodeModel.getAiConfig();        if (null == aiConfig) {            return true;        }        String fallbackStrategy = aiConfig.getFallbackStrategyOrDefault();        if (AiFallbackStrategy.MANUAL.eq(fallbackStrategy)) {            return true;        }        // 记录降级原因        Map args = execution.getArgs();        if (null != args) {            args.put("_ai_fallback", true);            args.put("_ai_fallback_reason", reason);        }        List flwTasks = execution.getFlwTasks();        for (FlwTask ft : flwTasks) {            if (AiFallbackStrategy.DEFAULT_PASS.eq(fallbackStrategy)) {                // 默认经由过程                execution.getEngine().autoCompleteTask(ft.getId(), args, aiUser);            } else if (AiFallbackStrategy.DEFAULT_REJECT.eq(fallbackStrategy)) {                // 默认拒绝                execution.getEngine().autoRejectTask(ft, args, aiUser);            }        }        return true;    }    @Override    public String decideRoute(FlowLongContext flowLongContext, Execution execution, NodeModel nodeModel, Map args) {        // 默认实现:返回 null,表示不由 AI 决定路由        System.out.println("AI Decision: " + args.get("content"));        // 这里模仿决定计划返回 审批 A 地点分支        return "flk17631709068381";    }    @Override    public List decideInclusiveRoutes(FlowLongContext flowLongContext, Execution execution, NodeModel nodeModel, Map args) {        // 默认实现:返回 null,表示不由 AI 决定包涵分支        return null;    }    @Override    public boolean onAsyncComplete(FlowLongContext flowLongContext, String asyncToken, AiResponse aiResponse) {        // 异步回调剂理        log.info("AI async complete, token={}, status={}", asyncToken, aiResponse.getStatus());        // TODO: 根据 asyncToken 找到对应的义务,并恢复流程履行        // 1. 根据 asyncToken 查询挂起的义务        // 2. 根据 aiResponse 成果决定是主动完成照样转人工        // 3. 恢复流程履行        return true;    }}

    fixed: 修复 maven 模块名冲突

  • fixed: 修复用户多角色或签认领其它介入者未处理问题

  • fixed: 修复撤回到提议人唤醒义务未创建问题

AI审批

AI智能体根据参数设备等信息,智能路由决定计划,智能帮助审批。

核心思惟:从“规矩驱动”到“语义懂得驱动”

  • 传统工作流引擎:依附于预定义的、构造化的规矩。例如:“假如报销金额 < 1000>
  • 智能审批(结合大年夜模型):引入大年夜模型的天然说话懂得、高低文分析、常识推理和内容生成才能。它可以懂得审批内容(如合同条目、报销事由、项目申报)的语义,而不仅仅是构造化的数据字段。

点赞(0) 打赏

立即下载

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部