AI agent workflow implementation method and system, electronic equipment and storage medium
Through the AI agent workflow implementation method, the problem that traditional development methods are difficult to cope with complex business processes is solved, the workflow is automated and efficient execution is realized, and user experience and operational efficiency is improved.
Patent Information
- Application Number
- CN202510160327.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-06-13
AI Technical Summary
Traditional manual development methods are difficult to meet the needs of large-scale and complex business processes, especially in the context of the rapid development of artificial intelligence technology and the digital transformation of enterprises.
Through the AI agent workflow implementation method, the node topology order is determined based on the node relationship of the target workflow, and the execution scheduling is performed in combination with the node configuration information to generate the final execution result. This method supports drag-and-drop node orchestration, allowing users to design complex workflows in low-code or zero-code ways.
It realizes the standardization and automation of complex workflows, improves workflow execution efficiency and accuracy, reduces operational costs, and improves user experience and satisfaction.
Smart Images

Figure CN120146545A_ABST
Abstract
Description
Background Art
[0002] With the rapid development of artificial intelligence technology and the urgent need for enterprise digital transformation, enterprises need to efficiently develop and deploy complex AI applications, and optimize business processes through automation and intelligent means to improve operational efficiency and reduce costs. The traditional manual development method can no longer meet the needs of large-scale and complex business processes.
[0003] Therefore, there is an urgent need to provide a technical solution to solve the above problems. Summary of the Invention
[0004] To solve the above technical problems, the present invention provides an AI agent workflow implementation method, system, electronic device and storage medium.
[0005] In a first aspect, the present invention provides an AI agent workflow implementation method, which is applied to an AI agent. The technical solution of this method is as follows:
[0006] Based on the node relationship of the target workflow, determine the node topological order of the target workflow;
[0007] According to the node topological order and in combination with the configuration information of each node of the target workflow, perform execution scheduling on each node of the target workflow to generate the final execution result of the target workflow.
[0008] The beneficial effects of an AI agent workflow implementation method of the present invention are as follows:
[0009] The method of the present invention realizes the standardization and automation of complex workflows by using agents, improves the execution efficiency and accuracy of workflows, reduces operating costs and improves user experience and satisfaction.
[0010] On the basis of the above solution, an AI agent workflow implementation method of the present invention can also be improved as follows.
[0011] In an optional manner, it further includes:
[0012] Parse the workflow message corresponding to the target workflow to obtain the node relationship of the target workflow and the configuration information of each node.
[0013] In an optional manner, it further includes:
[0014] Receive each node selected by the user from a preset node library according to the requirements and by means of dragging, and receive the node relationship configured by the user for each selected node to generate the workflow message corresponding to the target workflow.
[0015] In the above optional manner, drag-and-drop node orchestration is further adopted to support users in designing complex workflows in a low-code or zero-code manner, improving development efficiency.
[0016] In an optional manner, the preset node library includes: a start node, a large model node, a selector node, a custom tool node, a question classification node, and an end node; the nodes in the target workflow at least include: the start node and the end node.
[0017] In an optional manner, the step of determining the node topological order of the target workflow based on the node relationships of the target workflow includes:
[0018] Based on the node relationships of the target workflow, generate a node topological structure diagram of the target workflow, and determine the node topological order of the target workflow according to the node topological structure diagram.
[0019] In an optional manner, the step of performing execution scheduling on each node of the target workflow according to the node topological order and in combination with the configuration information of each node of the target workflow to generate the final execution result of the target workflow includes:
[0020] Perform execution scheduling on each node of the target workflow according to the node topological order and in combination with the configuration information of each node of the target workflow to generate the output result of each node of the target workflow;
[0021] Perform data aggregation on the output results of each node of the target workflow to obtain the final execution result of the target workflow.
[0022] In an optional manner, the configuration information includes: input fields, output fields, node descriptions, coordinate positions, node relationships, and node type parameters.
[0023] In a second aspect, the present invention provides an AI intelligent agent workflow implementation system, and the technical solution of this system is as follows:
[0024] An AI intelligent agent workflow implementation system, applied to an intelligent agent, includes: a determination module and a running module;
[0025] The determination module is used to: determine the node topological order of the target workflow based on the node relationships of the target workflow;
[0026] The running module is used to: perform execution scheduling on each node of the target workflow according to the node topological order and in combination with the configuration information of each node of the target workflow to generate the final execution result of the target workflow.
[0027] The beneficial effects of an AI agent workflow implementation system of the present invention are as follows:
[0028] The system of the present invention utilizes agents to standardize and automate complex workflows, improving task execution efficiency and accuracy, and enhancing user experience and satisfaction.
[0029] In a third aspect, the technical solution of an electronic device of the present invention is as follows:
[0030] It includes a memory, a processor, and a program stored on the memory and running on the processor. When the processor executes the program, it implements the steps of the AI agent workflow implementation method of the present invention.
[0031] In a fourth aspect, the technical solution of a computer-readable storage medium provided by the present invention is as follows:
[0032] Instructions are stored in the computer-readable storage medium. When the computer-readable storage medium reads the instructions, it causes the computer-readable storage medium to execute the steps of the AI agent workflow implementation method of the present invention.
[0033] The above description is only an overview of the technical solution of the present invention. In order to be able to more clearly understand the technical means of the present invention, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features, and advantages of the present invention more obvious and understandable, the specific embodiments of the present invention are hereinafter specifically exemplified. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The drawings are only used to illustrate the embodiments and are not considered to limit the present invention. Moreover, throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:
[0035] Figure 1 is a schematic flowchart of an embodiment of an AI agent workflow implementation method of the present invention;
[0036] Figure 2 is a design schematic diagram of a start node;
[0037] Figure 3 is a design schematic diagram of an end node;
[0038] Figure 4 is a design schematic diagram of a large model node;
[0039] Figure 5 is a design schematic diagram of a selector node;
[0040] Figure 6 is a design schematic diagram of a custom tool node;
[0041] Figure 7One of the design diagrams of the problem classification node;
[0042] Figure 8 Another design diagram of the problem classification node;
[0043] Figure 9 Structural diagram of an embodiment of an AI intelligent agent workflow implementation system of the present invention;
[0044] Figure 10 Structural diagram of an embodiment of an electronic device of the present invention. Detailed implementation manners
[0045] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein.
[0046] Figure 1 The flowchart of an embodiment of an AI intelligent agent workflow implementation method provided by the present invention is shown. This AI intelligent agent workflow implementation method is executed by an AI intelligent agent. As Figure 1 shown, the method includes the following steps:
[0047] S1. Based on the node relationships of the target workflow, determine the node topological order of the target workflow.
[0048] Among them, the target workflow is the workflow that needs to be executed (implemented) in this embodiment. A workflow refers to a process in a computer application environment that automates a series of interrelated activities or tasks according to predefined rules and sequences to achieve specific business goals or work tasks. The target workflow includes multiple nodes and node relationships. The node topological order represents the linear sequence relationship between the nodes in the workflow, usually represented in the form of a directed acyclic graph.
[0049] S2. According to the node topological order and in combination with the configuration information of each node of the target workflow, perform execution scheduling on each node of the target workflow to generate the final execution result of the target workflow.
[0050] Among them, the configuration information includes: input fields, output fields, node descriptions, coordinate positions, node relationships, and node type parameters. Parameters such as input fields, output fields, node descriptions, and coordinate positions are common parameters for node configuration. The node type parameters are determined according to the node type, and the node types include but are not limited to: start node, large model node, selector node, custom tool node, question classification node, and end node. For example, when the node type is a large model node, the node type parameters are the model address and the temperature value; when the node type is a selector node, the node type parameters are conditional logic, etc.
[0051] Among them, for each node, the corresponding execution function or method is called according to the node type. During the execution scheduling process, it is judged whether to skip certain branches or execute a specific path according to the conditional logic of the node. The final execution result refers to the execution result of the target workflow output in a preset output manner. The preset output manners include but are not limited to: tree structure, list structure, and other appropriate formats.
[0052] ① The common parameters in the configuration information are shown in Table 1:
[0053] Table 1:
[0054]
[0055]
[0056] ② The design schematic diagram of the start node is as Figure 2 shown, and the message design of the start node is as follows: {"inputs": [{
[0057] "type": "string",
[0058] "name": "query",
[0059] "required": true,
[0060] "description": "User question",
[0061] "content": "",
[0062] "blockID": "",
[0063] "relName": ""},
[0064] {"type": "string",
[0065] "name": "input",
[0066] "required": false,
[0067] "description": "User question",
[0068] "content": "",
[0069] "blockID": "",
[0070] "relName": ""}],
[0071] "nodeMeta": {
[0072] "title": "Start node",
[0073] "description": "The starting node of the workflow, used to set the information required to start the workflow."},
[0074] "position": {"x": 717.6301700064726, "y": 3.7407545510225155}, "type": 0,
[0075] "id": "14F3B189EE584E649D8E8AD2C966560C"}
[0076] ③ The design schematic diagram of the end node is as Figure 3 shown, and the message design of the end node is as follows:
[0077] {"inputs": [{
[0078] "name": "llm_content",
[0079] "type": "ref",
[0080] "blockID": "3879C4144C1D47B29A8251049CA88AE0",
[0081] "relName": "llm_content",
[0082] "content": "",
[0083] "required": false,
[0084] "description": ""},
[0085] {"name": "question",
[0086] "type":"ref",
[0087] "blockID":"D46378038F4E4E7BAACC2475177508E2",
[0088] "relName":"question",
[0089] "content":"",
[0090] "required":false,
[0091] "description":""}],
[0092] "outputs":{
[0093] "type":"string",
[0094] "name":"",
[0095] "content":"Please answer the user's question simply and professionally based only on the known information. If the answer cannot be obtained from the known information, say 'According to the known information, the question cannot be answered', and absolutely no other fabricated content is allowed in the answer. The answer should be in Chinese.\nKnown information: {llm_content}]\nUser's question: {question}"},
[0096] "nodeMeta":{
[0097] "title":"End Node",
[0098] "description":"The final node of the workflow, used to return the result information after the workflow runs."},
[0099] "terminatePlan":"summarize",
[0100] "position":{"x":717.6301700064726,"y":3.7407545510225155},"type":9,
[0101] "id":"4D6E47DB470C4BE5905B21BC6AFE1B3B"}
[0102] ④The design schematic diagram of the large model node is as Figure 4 shown, and the message design of the large model node is as follows:
[0103] {"inputs":{
[0104] "inputParameters":
[0105] {"name":"input",
[0106] "type":"ref",
[0107] "blockID":"14F3B189EE584E649D8E8AD2C966560C",
[0108] "relName":"query",
[0109] "content":"",
[0110] "description":""}],
[0111] "llmParam":
[0112] {"name":"prompt",
[0113] "type":"string",
[0114] "content":"User question: {input}\nYou are now an expert in question generation. Please only expand the question based on the user's question and only output one.\n\nPlease output in the following strict format:\n{\"question\":\"xxxxx\"}"}]},
[0115] "outputs":
[0116] {"type":"string",
[0117] "name":"question"}],
[0118] "nodeMeta":{
[0119] "title":"LLM",
[0120] "description":"Call the large language model and use variables and prompts to generate responses."},
[0121] "position":{"x":717.6301700064726,"y":3.7407545510225155},"interfaceAddress":"ws: / / 10.86.0.22:14254 / ws / origin_stream",
[0122] "temperature":0.1,
[0123] "type":1,
[0124] "id":"D46378038F4E4E7BAACC2475177508E2"}
[0125] ⑤ The design schematic diagram of the selector node is as Figure 5 shown, and the message design of the selector node is as follows:
[0126] {"inputs":{
[0127] "condition":
[0128] {"logic":"",
[0129] "conditions":
[0130] {"operator":11,
[0131] "left":{
[0132] "type":"ref",
[0133] "blockID":"D46378038F4E4E7BAACC2475177508E2",
[0134] "relName":"question",
[0135] "name":"",
[0136] "content":"",
[0137] "description":""},
[0138] "right":{
[0139] "type":"string",
[0140] "blockID":"",
[0141] "relName":"",
[0142] "name":"",
[0143] "content":"AAA",
[0144] "description":""}}]}]},
[0145] "nodeMeta":{
[0146] "title":"Judge",
[0147] "description":"Connects two downstream branches and runs only the 'if' branch if the set condition is met, or only the 'else' branch if not."},
[0148] "position":{"x":717.6301700064726,"y":3.7407545510225155},"type":2,
[0149] "id":"D086938F0E89466B9F18A86A5A938429"}
[0150] ⑥ The design schematic diagram of the custom tool node is as Figure 6 shown, and the message design of the custom tool node is as follows:
[0151] {"id":"3879C4144C1D47B29A8251049CA88AE0",
[0152] "inputs":[{"blockID":"D46378038F4E4E7BAACC2475177508E2",
[0153] "relName":"question",
[0154] "name":"keywords",
[0155] "description":"Search keywords or phrases","type":"ref","content":"","required":true},
[0156] {"blockID":"",
[0157] "relName":"",
[0158] "name":"ct_id",
[0159] "description": "Knowledge classification ID", "type": "string",
[0160] "content": "{ct_id}",
[0161] "required": false},
[0162] {"blockID": "",
[0163] "relName": "",
[0164] "name": "ep_id",
[0165] "description": "Tenant ID",
[0166] "type": "string",
[0167] "content": "{ep_id}",
[0168] "required": false},
[0169] {"blockID": "",
[0170] "relName": "",
[0171] "name": "crt_userid",
[0172] "description": "Current logged-in user ID", "type": "string",
[0173] "content": "",
[0174] "required": false},
[0175] {"blockID": "",
[0176] "relName": "",
[0177] "name": "search_id",
[0178] "description": "Search ID",
[0179] "type": "string",
[0180] "content": "{search_id}",
[0181] "required": false},
[0182] {"blockID": "",
[0183] "relName": "",
[0184] "name": "needPrompt",
[0185] "description": "",
[0186] "type": "string",
[0187] "content": "false",
[0188] "required": false}],
[0189] "nodeMeta": {
[0190] "code": "search_vector",
[0191] "description": "Vector retrieval is a general search engine for knowledge bases, which can be used to access knowledge bases, query knowledge, etc.", "title": "Vector Search"},
[0192] "outputs": [{"name": "klg_quote",
[0193] "type": "string"},
[0194] {"name": "is_llm",
[0195] "type": "string"},
[0196] {"name": "llm_content",
[0197] "type": "string"}],
[0198] "postion": {"x": "0", "y": "0"}, "type": 3,
[0199] "url": "http: / / 172.18.234.167:8401 / km / search - api / tools / vectorSearch"}
[0200] ⑦Schematic diagram of the design of the problem classification node is as Figure 7 and Figure 8As shown below, the message design of the problem classification node is as follows:
[0201] {"classifys":[{"
[0202] "name":"type1",
[0203] "content":"AAApdf",
[0204] "sourcePort":2},
[0205] {"name":"type2",
[0206] "content":"AAAfaq",
[0207] "sourcePort":3}],
[0208] "inputs":[{"blockID":"e3cc8a2b-a807-46d6-bfcd-3902b021cf49",
[0209] "relName":"data",
[0210] "name":"keywords",
[0211] "description":"Search keywords or phrases",
[0212] "type":"ref",
[0213] "required":true,
[0214] "content":""}],
[0215] "nodeMeta":{"description":"Define the classification conditions of the user's problem. The LLM can define the progress of the conversation according to the classification description.","title":"Problem Classification Node"},
[0216] "interfaceAddress":"ws: / / 10.86.0.22:14254 / ws / origin_stream",
[0217] "temperature":0.1,
[0218] "prompt": "You are now a question classification analysis assistant. Please analyze which category the following question belongs to among the known categories, and there must be one result. Just output the classification result without any other processes or descriptions. Known categories: {classify}\nMy question: {question}",
[0219] "id": "AD49C36620DB449B8BA5ECEE59D0871D",
[0220] "position": {"x": 0, "y": 0}, "type": 4}
[0221] ⑧ The message design for node relationships is as follows:
[0222] [{"startId": "3879C4144C1D47B29A8251049CA88AE0",
[0223] "endId": "4D6E47DB470C4BE5905B21BC6AFE1B3B"},
[0224] {"startId": "D46378038F4E4E7BAACC2475177508E2",
[0225] "endId": "D086938F0E89466B9F18A86A5A938429"},
[0226] {"startId": "14F3B189EE584E649D8E8AD2C966560C",
[0227] "endId": "D46378038F4E4E7BAACC2475177508E2"},
[0228] {"startId": "D086938F0E89466B9F18A86A5A938429",
[0229] "endId": "4D6E47DB470C4BE5905B21BC6AFE1B3B",
[0230] "sourcePort": 0},
[0231] {"startId": "D086938F0E89466B9F18A86A5A938429",
[0232] "endId":"3879C4144C1D47B29A8251049CA88AE0",
[0233] "sourcePort":1}]
[0234] In an optional manner, it further includes:
[0235] Parse the workflow message corresponding to the target workflow to obtain the node relationship of the target workflow and the configuration information of each node.
[0236] Among them, the message parsing process is specifically as follows: Perform format verification on the message to ensure that it conforms to the predefined message structure. Extract the configuration information of the nodes and the node relationship data in the message, and store them in corresponding data structures respectively, such as node entities and edge entities. Perform preliminary processing and conversion on the extracted data, for example, convert the node type in string form to an enumeration value, and convert the coordinate position string to a floating point number, etc.
[0237] It should be noted that the code for the message parsing process is as follows:
[0238] Map<Integer, String> nodeList = new HashMap<>();
[0239] nodeList.put(0, "Start Node");
[0240] nodeList.put(1, "Large Model Node");
[0241] nodeList.put(2, "Selector Node");
[0242] nodeList.put(3, "Custom Tool Node");
[0243] nodeList.put(4, "Question Classification Node");
[0244] nodeList.put(5, "End Node");
[0245] HashSet <object>set = new HashSet<>();
[0246] int sum = 0;
[0247] boolean duplicate = false;
[0248] String duplicateName = "";
[0249] List <aiworkflownode>
[0250] aiWorkflowNodes=aiWorkflowNodeMapper.selectByFlowId(workFlowId);
[0251] for(AiWorkflowNode aiWorkflowNode:aiWorkflowNodes){
[0252] JSONObject jsonObjectItem=JSONObject.parseObject(aiWorkflowNode.getNodeContent());
[0253] if(jsonObjectItem.get("type")==null||jsonObjectItem.get("id")==null){
[0254] return new ResBean<>(false,MessageCode.ERROR,"节点类型和ID不能为空");}
[0255] if(jsonObjectItem.get("type").equals(0)){
[0256] AiFlowNode.NodeZero
[0257] nodeZero=JSONObject.parseObject(JSONObject.toJSONString(jsonObjectItem),AiFlowNode.NodeZero.class);
[0258] if(nodeZero.getInputs()==null||nodeZero.getInputs().size()==0){
[0259] return new ResBean<>(false,MessageCode.ERROR,nodeList.get(0)+"的输入参数不能为空");}
[0260] / / 校验inputs
[0261] if(jsonObjectItem.get("type").equals(1)){
[0262] JSONObject inputs=jsonObjectItem.getJSONObject("inputs");
[0263] if (inputs == null) {
[0264] return new ResBean<>(false,MessageCode.ERROR,nodeList.get(12)+"The input field is required");}
[0265] if(StringUtil.isEmpty(inputs.getString("name"))){
[0266] return new ResBean<>(false,MessageCode.ERROR,nodeList.get(12)+"The name of the input field cannot be empty");}
[0267] if(StringUtil.isEmpty(inputs.getString("value"))){
[0268] return new ResBean<>(false,MessageCode.ERROR,nodeList.get(12)+"The variable name of the input field cannot be empty");}
[0269] JSONObject outputs=jsonObjectItem.getJSONObject("outputs");
[0270] if (outputs == null) {
[0271] return new ResBean<>(false,MessageCode.ERROR,nodeList.get(12)+"Output field cannot be empty");}
[0272] if(StringUtil.isEmpty(outputs.getString("name"))){
[0273] return new ResBean<>(false,MessageCode.ERROR,nodeList.get(12)+"The name of the output field cannot be empty");}
[0274] if (StringUtil.isEmpty(outputs.getString("type"))) {
[0275] return new ResBean<>(false, MessageCode.ERROR, nodeList.get(12) + " output field type cannot be empty");}
[0276] JSONObject nodeMeta = jsonObjectItem.getJSONObject("nodeMeta");
[0277] if (StringUtil.isEmpty(nodeMeta.getString("title")) || StringUtil.isEmpty(nodeMeta.getString("description"))) {
[0278] return new ResBean<>(false, MessageCode.ERROR, nodeList.get(12) + " name and description cannot be empty");}}
[0279] if (jsonObjectItem.get("type").equals(2)) {}}}
[0280] In an alternative approach, it further includes:
[0281] Receiving each node selected by the user from a preset node library according to the requirements and in a drag-and-drop manner, and receiving the node relationships configured by the user for each selected node, to generate the workflow message corresponding to the target workflow.
[0282] Among them, the preset node library stores the configuration information of different nodes. To ensure the integrity of the workflow, the nodes in the target workflow at least include: a start node and an end node. The user can, according to the requirements and in a drag-and-drop manner in the client (front-end), call the nodes in the preset node library and configure the node relationships, thereby generating a workflow message.
[0283] The technical solution of this embodiment further adopts drag-and-drop node orchestration, supports the user to design complex workflows in a low-code or zero-code manner, and improves the development efficiency.
[0284] In an alternative approach, S1 includes:
[0285] Generate a node topology structure diagram of the target workflow based on the node relationships of the target workflow, and determine the node topology order of the target workflow according to the node topology structure diagram.
[0286] Among them, the node topology structure diagram includes the dependency relationships and execution order between nodes. According to the dependency relationships and execution order between nodes, determine the node topology order of the target workflow.
[0287] In an alternative approach, S2 includes:
[0288] S21. According to the node topology order and in combination with the configuration information of each node of the target workflow, perform execution scheduling on each node of the target workflow to generate the output result of each node of the target workflow.
[0289] Among them, the code design for node execution scheduling is as follows:
[0290] Async def excuteFlowByFlowId(data, flowId, flowName, userInput, outputs, agent_log, agent_executeList):
[0291] endContent = ”
[0292] nodeList = flow_db_util.queryNodeList(flowId)
[0293] edges = flow_db_util.queryEdgesList(flowId)
[0294] processParam = {}
[0295] actionsTool = flowName + ""
[0296] executeStr = []
[0297] if len(nodeList) > 0 and len(edges) > 0:
[0298] # Get the start node
[0299] sNode = [obj for obj in nodeList if obj.get('type') == 0]
[0300] eNode=[obj for obj in nodeList if obj.get('type')==9]
[0301] if sNode is None or len(sNode)! =1:
[0302] yield sendErrorMessage(data,'Start node not found','Process execution error (Z0001)',agent_log,agent_executeList)
[0303] if eNode is None or len(eNode)<1:
[0304] yield sendErrorMessage(data,'End node not found','Process execution error (Z0002)',agent_log,agent_executeList)
[0305] #Execute the start node
[0306] ResBean=startNode(sNode[0],edges,userInput,outputs,data['placeholder'],processParam,agent_log,agent_executeList,data)
[0307] #Get the next level node
[0308] if ResBean.status:
[0309] while True:
[0310] nextNode=[obj for obj in nodeList if obj.get('id')==ResBean.data]
[0311] if nextNode is None or len(nextNode)! =1:
[0312] yield sendErrorMessage(data,'Unable to find the next level node','Process execution error (Z0003)',agent_log,agent_executeList)
[0313] ResBean.status = None
[0314] ResBean.data=None
[0315] ResBean.code=None
[0316] ResBean.msg = None
[0317] executeStr.append(nextNode[0]['nodeMeta']['title'])
[0318] if(nextNode[0]['type'])==1:
[0319] async for value in llmNode(nodeList,data,nextNode[0],edges,outputs,processParam,agent_log,agent_executeList):
[0320] if isinstance(value,flowResBean):
[0321] ResBean=value
[0322] break
[0323] else:
[0324] yield value
[0325] except Exception as e:
[0326] traceback.print_exc()
[0327] processDataDu(nextNode[0]['nodeMeta']['title'],processParam,",str(e),nextNode[0]['type'],agent_log,agent_executeList,0)
[0328] yield sendErrorMessage(data,'Error in executing [large model node], please check the process (see agent log for details)','Process execution error (Z0005)',agent_log,agent_executeList)
[0329] break
[0330] if(ResBean.data == None or len(ResBean.data) == 0):
[0331] if ResBean.msg is not None and ResBean.msg != "":
[0332] yield sendErrorMessage(data,ResBean.msg,ResBean.code,agent_log,agent_executeList)
[0333] break
[0334] else:
[0335] yield sendErrorMessage(data,ResBean.msg,ResBean.code,agent_log,agent_executeList)
[0336] else:
[0337] yield sendErrorMessage(data,'No process node information was queried. Please confirm whether the process node configuration is correct.','Process execution error (Z0004)',agent_log,agent_executeList)
[0338] S22. Aggregate the output results of each node of the target workflow to obtain the final execution result of the target workflow.
[0339] Among them, after the target workflow is executed, traverse the output results of all nodes, and summarize and organize them in a preset format. For example, the output results of the nodes can be organized into a tree structure, a list structure, or other appropriate formats, so that users can clearly view and understand the execution results of the workflow. According to the user's needs or system configuration, select an appropriate way to output the final result. Perform necessary security and compliance checks on the output results to ensure the legality and availability of the results.
[0340] It should be noted that the code for designing the data aggregation and output function is as follows:
[0341] Async def endNode(data,node,outputs,actionsTool,proData,executeStr,agent_log,agent_executeList):
[0342] global res
[0343] start_time = time.time()
[0344] inputs = node['inputs']
[0345] outpPar = node['outputs']
[0346] endParam = commonParamHandle(inputs, outputs, data, node['id'])
[0347] prompt = outpPar['content']
[0348] terminatePlan = node['terminatePlan']
[0349] prompt = agent_excute.multi_level_node_res_workflow(tool_response = endParam, prompt_template = prompt, data = data, id = node['id'])
[0350] if 'klg_quote' in endParam and 'klg_type' in str(endParam['klg_quote']):
[0351] data['klg_quote'] = endParam['klg_quote']
[0352] messageStr = ”
[0353] messageCount = 1
[0354] messageNodeLists = findMessageNode(agent_executeList)
[0355] for item in messageNodeLists:
[0356] messageStr = messageStr + str(item.output) + ' <div class="el-divider el-divider--horizontal"> <div class="el-divider__text is-center"><iclass="el-icon-message"> '
[0357] messageCount = messageCount + 1
[0358] if 'useAnswerContent' == terminatePlan:
[0359] try: end_time = time.time()
[0360] hs = str(round((end_time - start_time), 2))
[0361] processDataDu('End node
[0362] ', proData, 'useAnswerContent', prompt, node['type'], agent_log, agent_executeList, hs)
[0363] except Exception as e:
[0364] print(e)
[0365] await asyncio.sleep(0.01)
[0366] getAgentOut(data, prompt)
[0367] yield
[0368] llm_util.OpenAPIJson(agent_executeList, agent_log, prompt, prompt, [], True, data, ”, [], ”, {}, {}, deltas = prompt)
[0369] if'summarize' == terminatePlan:
[0370] executeStr.append("Summarize")
[0371] flowStr = getExecuteStr(agent_log, agent_executeList, 'Execute workflow: ', actionsTool, executeStr, True)
[0372] yield sendMessage(data,flowStr,agent_log,agent_executeList)
[0373] history = []
[0374] if 'history' in node and node['history']:
[0375] history = data['history']
[0376] prompt_system = ""
[0377] if'startNodePromptSystem' in outputs and outputs['startNodePromptSystem']:
[0378] prompt_system = outputs['startNodePromptSystem']
[0379] dataInput = llm_util.ToolLLMJson(prompt, history, top_p, top_k, temperature, [], prompt_system, "")
[0380] ws = llm_util.getLLMResultStream(interface_address = data['interface_address'], wsHeads = data.get('wsHeads', ""), quesjson = json.loads(dataInput), data = data)
[0381] i = 0
[0382] while True:
[0383] i = i + 1
[0384] if 'http: / / ' in data['interface_address'] or 'https: / / ' in data['interface_address']:
[0385] recv_text = next(ws)
[0386] # Decode bytes data to string
[0387] recv_text = recv_text.decode('utf-8')
[0388] log.info(f'Workflow end node - Summarize the {i}th message, message = {recv_text}')
[0389] if recv_text:
[0390] # Remove possible line breaks and carriage returns
[0391] recv_text = recv_text.strip()
[0392] # Check if the line starts with 'data:', if so, remove the prefix
[0393] if recv_text.startswith('data:'):
[0394] recv_text = recv_text[5:].strip()
[0395] try:
[0396] recv_text = recv_text.replace('data:', '')
[0397] ans = json.loads(recv_text)["delta"]
[0398] result = json.loads(recv_text)
[0399] except Exception as e:
[0400] raise RuntimeError(f'[Error in the return parameter of the large model http interface] chunk = {recv_text}') from e
[0401] else: continue
[0402] else: continue
[0403] else:
[0404] recv_text = ws.recv()
[0405] ans = json.loads(recv_text)["delta"]
[0406] result = json.loads(recv_text)
[0407] await asyncio.sleep(0.01)
[0408] getAgentOut(data, result['response'])
[0409] if result["finished"] == True: # Stop after outputting the last character
[0410] response = result['response']
[0411] res = response
[0412] try:
[0413] end_time = time.time()
[0414] hs = str(round((end_time - start_time), 2))
[0415] processDataDu('End node
[0416] ', proData, dataInput, res, node['type'], agent_log, agent_executeList, hs, remarks = result.get('prompt_out', ”))
[0417] except Exception as e:
[0418] print(e)
[0419] yield
[0420] llm_util.OpenAPIJson(agent_executeList, agent_log, '[DONE]', messageStr + response, [], True, data, ”, [], ”, {}, {}, deltas = result['deltas'])
[0421] yield res
[0422] else: yield llm_util.OpenAPIJson(agent_executeList, agent_log, ans, result['response'], [], False, data, "", [], "", {}, {}, deltas=result['deltas'])
[0423] In an alternative approach, before node execution scheduling, the required input data is obtained from a preset node library according to the configuration information of the node. For reference-type data, the actual data value is obtained by parsing the reference relationship, and data conversion and adaptation are performed to meet the requirements of node input. The output data generated during the node execution process is stored in the database, and data transfer and sharing are carried out according to the input configuration of subsequent nodes. For intermediate data, a reasonable storage method (such as in-memory caching, database persistence, etc.) is selected to ensure data reliability and access efficiency. During data transfer, data formatting, cleaning, filtering, and other processing operations are performed as needed to ensure data quality and consistency.
[0424] It should be noted that the design of the data processing process is as follows:
[0425] Def commonParamHandle(inputs, outputs, data: Optional[dict] = None, id: Optional[str] = None):
[0426] param = {}
[0427] if data and id:
[0428] # If there is data, it proves that the Chinese conversion function is required
[0429] workflow_toolNode_schema = data['workflow_toolNode_schema']
[0430] workflow_toolNode_mapper = data['workflow_toolNode_mapper']
[0431] mapper = {}
[0432] workflow_toolNode_mapper[id] = mapper
[0433] for item in inputs:
[0434] if item['type'] =='ref'
[0435] and len(outputs) > 0
[0436] and item['blockID'] in outputs
[0437] and len(outputs[item['blockID']]) > 0):
[0438] real_name = item['relName']
[0439] if data and id and item['blockID'] in workflow_toolNode_schema:
[0440] # Prove that the reference is to the output parameter node of the tool, and the mapping to Chinese function is required
[0441] mapper[item['name']] = {}
[0442] mapper[item['name']]['real_name'] = item['relName']
[0443] mapper[item['name']]['node_id'] = item['blockID']
[0444] if '.' in real_name:
[0445] # Multi-level node
[0446] real_name_split = real_name.split('.')
[0447] var_dict = outputs[item['blockID']]
[0448] for split in real_name_split:
[0449] var_dict = agent_excute.find_key_in_dict(split, var_dict, -1)
[0450] if (type(var_dict) is not dict and type(var_dict) is not list):
[0451] break
[0452] param[item['name']] = var_dict
[0453] else: param[item['name']] = outputs[item['blockID']][item['relName']]
[0454] else: param[item['name']] = item['content']
[0455] return param
[0456] # Generate a hierarchical structure from the node information in the schema
[0457] def commonParamHandleV2(inputs, outputs, father_node):
[0458] for item in inputs:
[0459] name = item['name']
[0460] sechema = item.get('sechema', [])
[0461] type = item.get('type', "")
[0462] if (type == 'array' or type == 'object'):
[0463] if type == 'array':
[0464] curr_node = []
[0465] else: curr_node = {}
[0466] if isinstance(father_node, dict):
[0467] father_node[name] = curr_node
[0468] if isinstance(father_node, list):
[0469] father_node.append(curr_node)
[0470] commonParamHandleV2(sechema, outputs, curr_node)
[0471] else: value = commonParamHandle(inputs, outputs)
[0472] if isinstance(father_node, dict):
[0473] father_node[name] = value[name]
[0474] if isinstance(father_node, list):
[0475] father_node.append(value[name])
[0476] In an optional manner, record the detailed information during the execution scheduling of the target workflow, including node execution time, input and output data, error information, etc., to facilitate problem troubleshooting and process optimization.
[0477] Among them, if an exception or error occurs during node execution, perform error handling and rollback operations in a timely manner. The log record message is designed as follows:
[0478] [{"output":"","input":"","node_name":"Client input parameter","icon":"start","remark":"","hs":"","nodelist":[],"remarks":"","is_top":false},
[0479] {"output":"","input":"","node_name":"First iteration","icon":"","remark":"","hs":"","nodelist":[{"output":"","input":","node_name":"Tool execution: Knowledge search","icon":"plugin","remark":"","hs":"1.09","nodelist":[],"remarks":"","is_top":false},
[0480] {"output":"","node_name":"Answer","icon":"summarizing","remark":"Summary - search_vector - Knowledge Search","hs":"0.32","nodelist":[],"remarks":"","is_top":false},
[0481] {"output":"","input":"","node_name":"Thought Process","icon":"thinkprocess","remark":"","hs":"","nodelist":[],"remarks":"","is_top":false}],"remarks":"","is_top":true}]
[0482] To better illustrate the technical solution of this embodiment, the following examples are used for illustration:
[0483] The target workflow includes: a start node, a question classification node, a large model node, a selector node, a custom tool node, and an end node. Among them, the start node is used to: set parameters such as the user's question, user name, and user ID. The question classification node is used to: set the classification of the user's question, including knowledge consultation questions, personal traffic query questions, etc. The large model node is used to: extract the parameters in the question. Such as: mobile phone number, date, etc. The selector node is used to: if the date is within the last 1 year, query the detailed traffic data from the formal library; if the date is more than 1 year ago, query the detailed traffic data from the historical library. The custom tool node is used to: execute tools based on the data extracted by the large model parameter extraction node and return the results. The tools include a knowledge retrieval tool and a traffic information query tool. The end node is used to: summarize the data based on the results returned by the tool and return it to the user.
[0484] Example 1 of the implementation process of the target workflow:
[0485] ① Receive the user's question. The user asks: "I want to apply for a new mobile phone number. How can I apply for it?"
[0486] ② Execute the start node to obtain the user's question, name, ID, and other information.
[0487] ③ Execute the question classification node: Determine that the user's question belongs to a knowledge consultation question through the large model.
[0488] ④ Execute the knowledge base retrieval tool (custom tool node): Retrieve knowledge from the knowledge base that matches the user's question.
[0489] ⑤ Execution end node: Summarize the knowledge retrieved by the knowledge base retrieval tool to generate the answer to the question of how to handle mobile phone numbers.
[0490] Example two of the implementation process of the target workflow:
[0491] ① Receive the user's question. The user asks: "My mobile phone number is xxxxxxxxxx. Please help me query the traffic usage from December 1, 2024 to December 31, 2024?"
[0492] ② Execute the start node to obtain the user's question, name, ID and other information.
[0493] ③ Execute the question classification node: Determine that the user's question belongs to the traffic query type through the large model.
[0494] ④ Execute the large model node: Extract parameters such as mobile phone number, query start date, and query end date from the question.
[0495] ⑤ Execute the selector node: Determine whether the query date range is within the last year. Query traffic data from the formal library within one year, and query traffic data from the historical library if it exceeds one year.
[0496] ⑥ Execute the traffic query node (custom tool node): Pass in the query start date, query end date, and mobile phone number parameters, execute the traffic query tool, and return the traffic details.
[0497] ⑦ Execute the end node: Summarize the data returned by the traffic query tool to generate the answer.
[0498] The technical solution of this embodiment significantly improves the execution efficiency of the business process through automated task processing and intelligent scheduling; the automated process reduces the dependence on human resources and lowers the operating cost of the enterprise; at the same time, through intelligent decision-making and optimized resource allocation, the resource utilization efficiency is further improved. The technical solution of this embodiment supports dynamic adjustment of the process, can quickly adapt to market changes according to real-time data and business requirements; can analyze data in real time to provide accurate decision-making support for management; can quickly respond to user needs and provide personalized services, significantly improving user satisfaction.
[0499] Figure 9 Shows the structural schematic diagram of an embodiment of an AI intelligent agent workflow implementation system 200 provided by the present invention. As Figure 9 shown, the system 200 includes: a determination module 210 and an operation module 220;
[0500] The determination module 210 is used to: Determine the node topological order of the target workflow based on the node relationship of the target workflow;
[0501] The operating module 220 is configured to: perform execution scheduling on each node of the target workflow according to the node topological order and in combination with the configuration information of each node of the target workflow, and generate the final execution result of the target workflow.
[0502] In an alternative embodiment, it further includes: a parsing module;
[0503] The parsing module is configured to: parse the workflow message corresponding to the target workflow to obtain the node relationships of the target workflow and the configuration information of each node.
[0504] In an alternative embodiment, it further includes: a generating module;
[0505] The generating module is configured to: receive each node selected by the user from a preset node library according to the requirements and in a drag-and-drop manner, and receive the node relationships configured by the user for each selected node, and generate the workflow message corresponding to the target workflow.
[0506] In an alternative embodiment, the preset node library includes: a start node, a large model node, a selector node, a custom tool node, a question classification node, and an end node; the nodes in the target workflow at least include: the start node and the end node.
[0507] In an alternative embodiment, the determining module 210 is specifically configured to:
[0508] Generate a node topological structure diagram of the target workflow based on the node relationships of the target workflow, and determine the node topological order of the target workflow according to the node topological structure diagram.
[0509] In an alternative embodiment, the operating module 220 is specifically configured to:
[0510] Perform execution scheduling on each node of the target workflow according to the node topological order and in combination with the configuration information of each node of the target workflow, and generate the output result of each node of the target workflow;
[0511] Perform data aggregation on the output results of each node of the target workflow to obtain the final execution result of the target workflow.
[0512] In an alternative embodiment, the configuration information includes: input fields, output fields, node descriptions, coordinate positions, node relationships, and node type parameters.
[0513] For the parameters and the steps for each module in the above-mentioned AI agent workflow implementation system 200 of this embodiment to implement corresponding functions, reference may be made to the parameters and steps in the embodiment of the AI agent workflow implementation method in the foregoing text, which will not be elaborated herein.
[0514] As Figure 10 shown, an electronic device 300 according to an embodiment of the present invention includes a processor 320, the processor 320 is coupled to a memory 310, and at least one computer program 330 is stored in the memory 310. The at least one computer program 330 is loaded and executed by the processor 320 so that the electronic device 300 implements any one of the above-mentioned AI agent workflow implementation methods. Specifically:
[0515] The electronic device 300 may have relatively large differences due to different configurations or performances, and may include one or more processors 320 (Central Processing Units, CPUs) and one or more memories 310. Among them, at least one computer program 330 is stored in the one or more memories 310, and the at least one computer program 330 is loaded and executed by the one or more processors 320 so that the electronic device 300 implements any one of the AI agent workflow implementation methods provided in the above embodiments. Of course, the electronic device 300 may also have components such as a wired or wireless network interface, a keyboard, and an input / output interface for input and output. The electronic device 300 may also include other components for implementing device functions, which will not be elaborated herein.
[0516] A computer-readable storage medium according to an embodiment of the present invention stores at least one computer program, and the at least one computer program is loaded and executed by a processor so that the computer implements any one of the above-mentioned AI agent workflow implementation methods.
[0517] Optionally, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0518] In an exemplary embodiment, there is also provided a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions so that the electronic device executes any one of the above-mentioned AI agent workflow implementation methods.
[0519] It should be noted that the terms "first", "second", etc. in the description and claims of this application are used to distinguish similar objects, rather than to limit a specific order or sequence. In appropriate cases, the order of use of similar objects can be interchanged so that the embodiments of the present application described herein can be implemented in an order other than the order shown or described.
[0520] Those skilled in the art know that the present invention can be implemented as a system, method, or computer program product. Therefore, the present disclosure can be specifically implemented in the following forms, that is: it can be entirely hardware, can also be entirely software (including firmware, resident software, microcode, etc.), or can also be a combination of hardware and software, which is generally referred to as "circuit", "module", or "system" in this article. In addition, in some embodiments, the present invention can also be implemented in the form of a computer program product in one or more computer-readable media, which contains computer-readable program code.
[0521] Any combination of one or more computer-readable media can be adopted. The computer-readable media can be computer-readable signal media or computer-readable storage media. The computer-readable storage media can be, for example, but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples (non-exhaustive list) of the computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this application, the computer-readable storage media can be any tangible medium that contains or stores a program, which can be used by or in combination with an instruction execution system, device, or component.
[0522] Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.< / aiworkflownode> < / object>
Claims
1. A method for implementing an AI agent workflow, applied to an AI agent, characterized in that: include: Based on the node relationship of the target workflow, determining the node topological order of the target workflow; According to the node topology order and in combination with the configuration information of each node of the target workflow, each node of the target workflow is scheduled for execution to generate a final execution result of the target workflow.
2. The AI agent workflow implementation method according to claim 1, characterized in that: Also includes: The workflow message corresponding to the target workflow is parsed to obtain the node relationship of the target workflow and the configuration information of each node.
3. The AI agent workflow implementation method according to claim 2, characterized in that: Also includes: Receive each node selected by the user from the preset node library by dragging according to the demand, receive the node relationship configured by the user for each selected node according to the demand, and generate the workflow message corresponding to the target workflow.
4. The AI agent workflow implementation method according to claim 3, characterized in that: The preset node library includes: a start node, a large model node, a selector node, a custom tool node, a problem classification node and an end node; the nodes in the target workflow include at least: the start node and the end node.
5. The AI agent workflow implementation method according to claim 1, characterized in that: The step of determining the node topological order of the target workflow based on the node relationship of the target workflow includes: Based on the node relationship of the target workflow, a node topology structure diagram of the target workflow is generated, and according to the node topology structure diagram, a node topology order of the target workflow is determined.
6. The AI agent workflow implementation method according to claim 1, characterized in that: The step of performing execution scheduling on each node of the target workflow according to the node topology order and in combination with the configuration information of each node of the target workflow to generate the final execution result of the target workflow includes: According to the node topology order and in combination with the configuration information of each node of the target workflow, each node of the target workflow is scheduled for execution to generate an output result of each node of the target workflow; The output results of each node of the target workflow are aggregated to obtain the final execution result of the target workflow.
7. The AI agent workflow implementation method according to any one of claims 1 to 6, characterized in that: Configuration information includes: input fields, output fields, node descriptions, coordinate positions, node relationships, and node type parameters.
8. An AI agent workflow implementation system, applied to an agent, characterized in that: include: Identify modules and run modules; The determination module is used to: determine the node topology order of the target workflow based on the node relationship of the target workflow; The running module is used to: perform execution scheduling on each node of the target workflow according to the node topology order and in combination with the configuration information of each node of the target workflow, and generate a final execution result of the target workflow.
9. An electronic device, characterized in that: The electronic device includes a processor, the processor is coupled to a memory, at least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the processor so that the electronic device implements the AI agent workflow implementation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the at least one computer program is loaded and executed by the processor so that the computer-readable storage medium implements the AI agent workflow implementation method as described in any one of claims 1 to 7.
Citation Information
Cited By
Intelligent agent configuration method and device based on front-end interaction and medium
CN121029245A
AI programming-oriented declarative workflow generation method and system, and AI programming-oriented declarative workflow execution method and system
CN122111395A