使用Kimi的一些体会

1、https://kimi.cn 这个回答问题还比较专业,感觉比以前chatgpt要好一些

2、Moonshot AI - 开放平台

可以通过注册账号,或微信扫描就可以登录进去

通过postman可以体会一下功能

2.1 POST https://api.moonshot.cn/v1/chat/completions

2.2 授权选择下面的方式bearer 加上自己建立的api-key

2.3 在下面的raw里输入下面需要的内容

{
  "model": "moonshot-v1-8k",
  "messages": [
    { "role": "user", "content": "flowable动态加入节点的代码" }
  ]
}

2.4 同时选择返回为json格式

2.5 提交后,等待一段时间后返回如下:

{
    "id": "cmpl-8cad609a093446fa9ae1284bd3af2c7f",
    "object": "chat.completion",
    "created": 2958582,
    "model": "moonshot-v1-8k",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "Flowable是一个开源的工作流和业务流程管理(BPM)平台,它基于BPMN 2.0规范。在Flowable中,动态添加节点通常涉及到修改正在运行的流程实例。这可以通过使用Flowable Java服务和API来实现。\n\n以下是使用Flowable Java服务动态添加一个排他网关(Exclusive Gateway)和一个用户任务的示例代码:\n\n```java\nimport org.flowable.engine.RuntimeService;\nimport org.flowable.engine.ProcessEngine;\nimport org.flowable.engine.ProcessEngines;\nimport org.flowable.engine.ProcessEngineConfiguration;\nimport org.flowable.bpmn.model.BpmnModel;\nimport org.flowable.bpmn.model.FlowElement;\nimport org.flowable.bpmn.model.ExclusiveGateway;\nimport org.flowable.bpmn.model.UserTask;\nimport org.flowable.bpmn.model.Process;\nimport org.flowable.task.api.Task;\nimport org.flowable.task.api.TaskQuery;\nimport org.flowable.variable.api.persistence.entity.VariableInstance;\n\npublic class DynamicNodeAddition {\n    public static void main(String[] args) {\n        // 获取流程引擎\n        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();\n\n        // 获取运行时服务\n        RuntimeService runtimeService = processEngine.getRuntimeService();\n\n        // 获取流程模型\n        BpmnModel bpmnModel = runtimeService.getBpmnModel(\"流程定义的ID\");\n\n        // 获取正在运行的流程实例\n        String processInstanceId = \"流程实例的ID\";\n        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()\n                .processInstanceId(processInstanceId)\n                .singleResult();\n\n        // 获取流程模型的流程对象\n        Process process = bpmnModel.getMainProcess();\n\n        // 创建一个排他网关\n        ExclusiveGateway newGateway = new ExclusiveGateway();\n        newGateway.setId(\"newGateway\");\n        newGateway.setName(\"New Gateway\");\n\n        // 创建一个用户任务\n        UserTask newUserTask = new UserTask();\n        newUserTask.setId(\"newUserTask\");\n        newUserTask.setName(\"New User Task\");\n\n        // 将新网关和用户任务添加到流程模型中\n        process.addFlowElement(newGateway);\n        process.addFlowElement(newUserTask);\n\n        // 创建从旧网关到新网关的流\n        FlowElement oldGateway = processInstance.getProcessDefinition().getFlowElement(\"旧网关的ID\");\n        String newGatewayFlowId = \"flowFromOldGatewayToNewGateway\";\n        process.addFlowElement(oldGateway, new SequenceFlow(oldGateway.getId(), newGateway.getId(), newGatewayFlowId));\n\n        // 创建从新网关到新用户任务的流\n        String newGatewayToNewUserTaskFlowId = \"flowFromNewGatewayToNewUserTask\";\n        process.addFlowElement(newGateway, new SequenceFlow(newGateway.getId(), newUserTask.getId(), newGatewayToNewUserTaskFlowId));\n\n        // 重新部署流程定义\n        org.flowable.bpmn.model.ProcessInstance processInstanceModel = processEngine.getRuntimeService().createProcessInstanceModel(processInstance.getId());\n        processInstanceModel.getBpmnModel().getMainProcess().getFlowElements().remove(oldGateway);\n        processInstanceModel.getBpmnModel().getMainProcess().getFlowElements().add(newGateway);\n        processInstanceModel.getBpmnModel().getMainProcess().getFlowElements().add(newUserTask);\n        processEngine.getRepositoryService().createDeployment().addBpmnModel(\"dynamic-model.bpmn\", processInstanceModel.getBpmnModel()).deploy();\n\n        // 更新流程实例以使用新的BPMN模型\n        runtimeService.createProcessInstanceModifyHistoricInstanceBuilder()\n                .processInstanceId(processInstanceId)\n                .startBeforeActivity(\"新用户任务的ID\")\n                .cancelActivity(\"旧网关的ID\")\n                .execute();\n\n        // 检查新任务是否已创建\n        TaskQuery taskQuery = processEngine.getTaskService().createTaskQuery();\n        Task newTask = taskQuery.processInstanceId(processInstanceId).singleResult();\n        System.out.println(\"新任务的ID: \" + newTask.getId());\n    }\n}\n```\n\n请注意,这段代码只是一个示例,可能需要根据您的具体需求进行调整。在实际应用中,您需要确保正确处理所有相关的边界情况和异常。此外,动态修改流程实例可能会对业务流程的一致性和可维护性产生影响,因此请谨慎使用。"
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 14,
        "completion_tokens": 896,
        "total_tokens": 910
    }

3、结果差不多,不过好像速度要慢一些,要登上几秒

4、同时刚注册提供了15元的试用,不过刚才调用一次就扣了一点

5、下次有机会集成到我的开源项目里

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-04-27 02:54:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-27 02:54:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-27 02:54:01       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-27 02:54:01       20 阅读

热门阅读

  1. Redis的单线程模型解析与应用实践

    2024-04-27 02:54:01       12 阅读
  2. 基于nest框架的redis streams实现mq(bullmq)

    2024-04-27 02:54:01       15 阅读
  3. 面试经典150题——分发糖果

    2024-04-27 02:54:01       12 阅读
  4. 代采系统:电商领域的创新与实践

    2024-04-27 02:54:01       16 阅读
  5. Numpy

    Numpy

    2024-04-27 02:54:01      12 阅读
  6. sentinel整合nacos持久化

    2024-04-27 02:54:01       13 阅读
  7. vue3:组合式API和选项式API里分别如何使用store

    2024-04-27 02:54:01       14 阅读
  8. leetcode hot100_part25

    2024-04-27 02:54:01       15 阅读
  9. 选购AI智能电话机器人需要注意哪些事项

    2024-04-27 02:54:01       16 阅读
  10. leetcode刷题(python)——(七)

    2024-04-27 02:54:01       15 阅读
  11. AI Python 教程

    2024-04-27 02:54:01       16 阅读
  12. Python编程——常用的Python单行实现功能代码示例

    2024-04-27 02:54:01       15 阅读