Function configuration method, task processing method, device, equipment, medium and product
By instantiating and constructing workflow instances of task nodes in the target workflow, the complex problem of proxy function expansion is solved, and flexible expansion and efficient configuration of functions are achieved.
Patent Information
- Application Number
- CN202411356473.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-01-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The functional extension of the agent is complex because each tool can only satisfy specific functions. To implement new functions, you must modify the tool or build a new tool.
By obtaining configuration instructions, instantiating the task node in the target workflow, constructing a first workflow instance of the target workflow, and adding it to the tool list, enabling the target agent to achieve the target function through the tool list.
It realizes flexible expansion of proxy functions, avoids the need to modify or build new tools, and improves the efficiency of functional configuration.
Smart Images

Figure CN119311309A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a function configuration method, a task processing method, an apparatus, a device, a medium and a product. Background Art
[0002] An agent is an intelligent entity that can autonomously perceive the environment and take actions to achieve its goals. Agents based on the Large Language Model (LLM) can interact with the outside world using tools. In related technologies, a large number of pre-set tools are provided for agents to achieve different functions. However, each tool can only meet specific functions. If new functions are to be achieved, the tool must be modified or a new tool must be built, which makes the expansion of the agent's functions complicated. Summary of the invention
[0003] In view of this, the present disclosure provides a function configuration method, a task processing method, an apparatus, a device, a medium and a product to solve the problem of complex function expansion of an agent.
[0004] In a first aspect, the present disclosure provides a function configuration method, the method comprising:
[0005] Obtaining a configuration instruction, wherein the configuration instruction is used to instantiate a task node in a target workflow to obtain a target node instance, and the target workflow is used to implement a target function;
[0006] Constructing a first workflow instance of the target workflow based on the target node instance;
[0007] The first workflow instance is added to a tool list, where the tool list is used to characterize workflow instances corresponding to functions of a target agent, and the target agent is constructed based on the tool list.
[0008] In a second aspect, the present disclosure provides a task processing method, the method comprising:
[0009] Get the target function corresponding to the target task;
[0010] Determine a first workflow instance in a tool list based on the target function, the tool list is used to characterize a workflow instance corresponding to a function of a target agent; the first workflow instance is constructed based on a node instance obtained by instantiating a task node in a target workflow for realizing the target function;
[0011] The first workflow instance is executed to obtain a task processing result of the target task.
[0012] In a third aspect, the present disclosure provides a function configuration device, the device comprising:
[0013] A data acquisition module is used to acquire configuration instructions, wherein the configuration instructions are used to instantiate task nodes in a target workflow to obtain a target node instance, and the target workflow is used to implement a target function;
[0014] A first processing module, configured to construct a first workflow instance of the target workflow based on the target node instance;
[0015] The second processing module is used to add the first workflow instance to a tool list, where the tool list is used to characterize workflow instances corresponding to functions of a target agent, and the target agent is constructed based on the tool list.
[0016] In a fourth aspect, the present disclosure provides a task processing device, the device comprising:
[0017] Function acquisition module, used to obtain the target function corresponding to the target task;
[0018] An instance determination module is used to determine a first workflow instance in a tool list based on the target function, wherein the tool list is used to characterize a workflow instance corresponding to a function of a target agent; the first workflow instance is constructed based on a node instance obtained by instantiating a task node in a target workflow for realizing the target function;
[0019] The task execution module is used to execute the first workflow instance to obtain the task processing result of the target task.
[0020] In a fifth aspect, the present disclosure provides an electronic device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the above-mentioned function configuration method or task processing method by executing the computer instructions.
[0021] In a sixth aspect, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the above-mentioned function configuration method or task processing method.
[0022] In a seventh aspect, the present disclosure provides a computer program product, including computer instructions, which are used to enable a computer to execute the above-mentioned function configuration method or task processing method.
[0023] The function configuration method provided by the embodiment of the present disclosure obtains a target node instance by instantiating a task node in a target workflow for realizing a target function. Then, a first workflow instance of the target workflow is constructed based on the target node instance. Therefore, the workflow for realizing the target function can be encapsulated into a workflow tool that can be used by a target agent. Furthermore, the first workflow instance is added to a tool list for constructing the target agent. Therefore, the target agent can realize the target function through the first workflow instance in the tool list. Compared with the related art, the present disclosure can expand the function of the agent by constructing a workflow without modifying the existing tools or building new tools. The function extension of the agent is simple, and the function configuration efficiency of the agent can be effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0025] Figure 1 is a flowchart of a function configuration method according to an embodiment of the present disclosure;
[0026] Figure 2 is a schematic diagram of building a workflow according to an embodiment of the present disclosure;
[0027] Figure 3 is a class diagram of a node instance and a workflow instance according to an embodiment of the present disclosure;
[0028] Figure 4 is a flowchart of a task processing method according to an embodiment of the present disclosure;
[0029] Figure 5 is a flowchart of another task processing method according to an embodiment of the present disclosure
[0030] Figure 6 is a structural block diagram of a function configuration device according to an embodiment of the present disclosure;
[0031] Figure 7 is a structural block diagram of a task processing device according to an embodiment of the present disclosure;
[0032] Figure 8 is a structural block diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0034] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0035] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0036] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0037] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0038] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0039] An agent is an intelligent entity that can autonomously perceive the environment and take actions to achieve its goals. Agents based on the Large Language Model (LLM) can interact with the outside world using tools. In related technologies, a large number of pre-set tools are provided for agents to achieve different functions, such as online search, scientific computing, or drawing pictures, thereby empowering and enhancing the ability of agents to connect to the outside world. However, each tool can only meet specific functions. If new functions are to be implemented, the tool must be modified or a new tool must be built, which makes the functional expansion of the agent complex.
[0040] In view of this, according to an embodiment of the present disclosure, a functional configuration method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0041] In this embodiment, a function configuration method is provided, which can be used for configuring a platform; wherein the configuration platform is used to build an agent and configure tools with different functions for the agent, Figure 1 is a flow chart of a function configuration method according to an embodiment of the present disclosure, such as Figure 1 As shown, the process includes the following steps:
[0042] Step S101, obtaining configuration instructions, the configuration instructions are used to instantiate the task nodes in the target workflow to obtain the target node instances, and the target workflow is used to realize the target function.
[0043] It should be noted that the target workflow is a directed acyclic graph (DAG for short).
[0044] Specifically, the language model application development framework provides an executable interface (also known as a Runnable interface), which is used to define an abstract interface of an executable component or unit, and can be used to modularize various processing logics so that they can be run serially in a chain. As a library, the language model application development framework is designed to help build and regulate the chain processing of language models. Therefore, the executable interface is one of its core components.
[0045] Specifically, in the function configuration method disclosed in the present invention, facing the existing preset tools (also called BaseTool) in the tool list for the target agent, an executable interface can be provided for the preset tools of different functions to encapsulate the preset tools of different functions into different function modules. The target workflow of the target function is constructed by selecting the function module. Figure 2As shown, the configuration platform displays a workflow creation page, and different functional modules are displayed in the workflow creation page, for example, a functional module corresponding to at least one of a language model, code, knowledge base (not shown in the figure), a selector, a plug-in, and a workflow. Among them, in the area where each functional module is located, the description information of the functional module is also displayed. For example, the description information of the language model is "calling the language model, using variables and prompt words to generate replies", the description information of the code is "writing code, processing input variables to generate return values", the description information of the knowledge base is "in the selected knowledge, according to the set number of recall segments and the required similarity setting value to recall the most matching segment information, and return it in the form of a list", the description information of the selector is "connecting multiple downstream branches, matching the running branches in a sequential search method according to the set conditions, if any preset condition is matched, only the branch corresponding to the condition is run, otherwise continue to match the next condition until the end", and the description information of the workflow is "by referencing the workflow type node to split the complex tasks or processes according to the sub-functions or sub-module capabilities, so that the process is refined and easy to control and maintain". The configuration platform responds to interactive operations such as selection, dragging, and connection operations on functional modules to build the target workflow of the target function. Figure 2 As shown, the task nodes in the target workflow correspond to the functional modules, and the attribute information of the task nodes is also displayed in the area where the task nodes are located. For example, the attribute information of task node 1, the attribute information of task node 2, and the attribute information of task node 3. Among them, the attribute information of the task nodes can be pre-configured or configured by the user according to actual conditions. For example, for the functional modules of the code, the user can construct the code to be executed by the task node according to actual needs.
[0046] Specifically, in response to the creation completion instruction of the target workflow, a configuration instruction is generated, wherein the configuration instruction carries the attribute information of each task node in the target workflow. The attributes of the task node are configured through the attribute information to instantiate the task node and obtain the target node instance of the task node.
[0047] Step S102: construct a first workflow instance of the target workflow based on the target node instance.
[0048] Specifically, the first workflow instance is constructed by building a call list for calling the target node instance.
[0049] Step S103: adding the first workflow instance to a tool list, the tool list is used to characterize workflow instances corresponding to functions of the target agent, and the target agent is constructed based on the tool list.
[0050] It is worth noting that the tool list includes workflow instances of different functions, including workflow instances of preset tools and workflow instances built by preset tools. It should be noted that the preset tool is the base class of the language model application development framework, and the workflow instance of the customized target function can be implemented by inheriting the preset tool.
[0051] The function configuration method provided by the present embodiment obtains a target node instance by instantiating a task node in a target workflow for realizing a target function. Then, a first workflow instance of the target workflow is constructed based on the target node instance. Therefore, the workflow for realizing the target function can be encapsulated into a workflow tool (i.e., the first workflow instance) that can be used by a target agent. Furthermore, the first workflow instance is added to a tool list for constructing the target agent. Therefore, the target agent can realize the target function through the first workflow instance in the tool list. Compared with the related art, the present disclosure can expand the function of the agent by constructing a workflow without modifying the existing tool or building a new tool. The function extension of the agent is simple, and the function configuration efficiency of the agent can be effectively improved.
[0052] In some optional implementations, the instantiation of the task node in the target workflow in the above step S101 to obtain the target node instance includes:
[0053] Step a1, obtaining attribute information of the task node.
[0054] Specifically, the attribute information of the task node includes at least one of node identification information, input configuration information, output configuration information, preceding node information, succeeding node information, preset parameter information, node type, and function configuration information corresponding to the node type.
[0055] Step a2: configure the attributes of the task node based on the attribute information to obtain the target node instance.
[0056] Specifically, based on the attribute information and a pre-configured attribute configuration template, the attribute configuration of the task node is performed. Alternatively, based on the attribute information and a pre-configured format conversion rule, the attribute configuration of the task node is performed. Alternatively, in response to an input operation based on the attribute information by a relevant person, the attribute configuration of the task node is performed.
[0057] The function configuration method provided in this embodiment configures the attributes of the task node based on the attribute information to instantiate the task node and obtain the target node instance. Therefore, the execution strategy and operation state of the target node instance can be flexibly adjusted through the attribute configuration, thereby improving the flexibility and configurability of the function configuration.
[0058] In some optional implementations, the attribute information includes input configuration information and output configuration information of the task node. Then, the step a2 of configuring the attributes of the task node based on the attribute information to obtain the target node instance includes: configuring the input of the task node based on the input configuration information, and configuring the output of the task node based on the output configuration information to obtain the target node instance.
[0059] Specifically, the input configuration information includes the input format and the variable reference definition of the input data. The variable reference definition is used to determine the source of the input data, for example, referenced from the previous node, or manually specified. The output configuration information includes the output format and output data. The output data includes runtime parameter information, and the runtime parameter information includes the running data reported to the caller by the task node during runtime, for example, at least one of the running time, running status, and running results.
[0060] The function configuration method provided in this embodiment configures the input and output of the task node based on the input and output configuration information to obtain the target node instance. Therefore, different functions can be realized by dynamically adjusting the input and output configuration information without changing the task processing logic of the task node, thereby improving the flexibility of the function configuration.
[0061] In some optional implementations, the attribute information also includes the predecessor node information of the task node. Then, the above step a2 configures the attribute of the task node based on the attribute information to obtain the target node instance, and further includes: configuring the execution condition of the task node based on the predecessor node information to obtain the target node instance, and the execution condition is used to characterize that the predecessor nodes of the task node are all executed.
[0062] Specifically, the predecessor node information includes information about the predecessor nodes that the task node depends on in the target workflow. Optionally, the predecessor node information includes the number of predecessor nodes that have not been executed.
[0063] The function configuration method provided in this embodiment configures the execution condition of the task node based on the information of the preceding node, so that the target node instance is executed only when the preceding nodes of the task node are all executed. Therefore, the correctness of the execution order of each target node instance can be ensured, so as to ensure the correctness of the data of the target node instance during the execution process.
[0064] In some optional implementations, the attribute information also includes the successor node information of the task node. Then, the above step a2 of configuring the attribute of the task node based on the attribute information to obtain the target node instance also includes: configuring the next task node triggered after the task node is executed based on the successor node information to obtain the target node instance.
[0065] Specifically, the successor node information includes the next task node of the task node in the target workflow.
[0066] The function configuration method provided in this embodiment configures the next task node triggered after the task node is executed based on the successor node information, so that the target node instance of the next task node is executed only when the current node instance is executed. Therefore, the correctness of the dependency relationship between each target node instance can be ensured to improve the accuracy of the function configuration.
[0067] In some optional implementations, the attribute information also includes the node type of the task node and the function configuration information corresponding to the node type. Then, the above step a2 of configuring the attributes of the task node based on the attribute information to obtain the target node instance also includes: configuring the type of the task node based on the node type, and configuring the function of the task node based on the function configuration information to obtain the target node instance.
[0068] Specifically, the node type includes one of a basic node, a conditional node, and a tool node. Among them, the basic node has basic node functions such as input and output format definition, input and output variable assignment, such as a start node and an end node. The conditional node is used to define the execution conditions to determine the running path of the workflow. The tool node is used to bind the workflow instance of the preset tool.
[0069] The function configuration method provided in this embodiment configures the type of the task node based on the node type, and configures the function of the task node based on the function configuration information to obtain a target node instance. Therefore, the accuracy of the function configuration can be further improved.
[0070] In some optional implementations, the attribute information also includes preset parameter information. Then, the above step a2 of configuring the attribute of the task node based on the attribute information to obtain the target node instance also includes: configuring the preset parameters of the task node based on the preset parameter information to obtain the target node instance.
[0071] Specifically, the preset parameter information is the parameter information preset by the user in the process of building the target workflow, and the preset parameter information can be represented in a dictionary format. During the operation of the target node instance, the preset parameter information and the runtime parameter information of the target node instance will be reported to the caller together.
[0072] In some optional implementations, the node type includes a conditional node, and the function configuration information includes a target condition corresponding to the conditional node. Then, configuring the function of the task node based on the function configuration information includes: configuring the condition for executing the task node based on the target condition.
[0073] The function configuration method provided in this embodiment configures the execution condition of the task node if the node type of the task node is a conditional node. Therefore, different conditions can be configured according to different functions and requirements to further improve the flexibility of function configuration.
[0074] In some optional implementations, the node type includes a tool node, and the function configuration information includes a second workflow instance in the tool list. Then, configuring the function of the task node based on the function configuration information includes: configuring the workflow instance called by the task node based on the second workflow instance.
[0075] The function configuration method provided in this embodiment configures the workflow instance called by the task node if the node type of the task node is a tool node. Therefore, the existing workflow instance can be reused to build a workflow instance with more complex functions to expand the function of the agent.
[0076] In some optional implementations, constructing the first workflow instance of the target workflow based on the target node instance in step S102 above includes:
[0077] Step b1, constructing a call list for calling the target node instance.
[0078] Specifically, a node instance representing a start node and a node instance representing an end node in the target node instance are determined to determine the start node and the end node of the first workflow instance. A node instance list is constructed based on other node instances in the target node instance. A call list is constructed based on the start node, the end node, and the node instance list.
[0079] Step b2: Generate a first workflow instance based on the call list.
[0080] Specifically, the call list is used as an attribute of the first workflow instance, and an operation method corresponding to the first workflow instance is configured to obtain the first workflow instance.
[0081] The function configuration method provided in this embodiment constructs a call list for calling a target node instance, and then generates a first workflow instance based on the call list, thereby ensuring that the generated first workflow instance can accurately call each target node instance.
[0082] It is worth mentioning that the task node is a sub-object of workflow management, and the node instance of the task node usually has the following common capabilities: 1. Input and output verification; 2. Input and output variable assignment; 3. Reporting of preset parameters; 4. Reporting of runtime parameters.
[0083] In order to facilitate the understanding of the property configuration process of the first workflow instance, Figure 3Take the class diagram shown as an example. In the preset tool of the tool list, the name, description, position parameter format and other properties of the preset tool are configured. For example, the name is in string format, the description is in string format, and the position parameter format is the type of preset tool that can be selected. At the same time, the preset tool is also configured with the operation method of the preset tool, for example, the run method (also known as the run method) is adopted, the first run method adopts input parameters and keyword parameters, and the output format of the first run method is a dictionary format. The second run method adopts position parameters and keyword parameters, and the output format of the second run method is any format. And build a tool node based on the preset tool. In the tool node, configure the tool called by the tool node and other properties, for example, the called tool is a preset tool. At the same time, the tool node is also configured with the operation method of the tool node, for example, the run method is adopted, the run method adopts input parameters and keyword parameters, and the output format of the run method is a dictionary format. And, configure the condition node. In the condition node, configure the execution conditions and other properties, for example, the execution conditions are a preset condition list. In addition, the start node and the end node can also be configured. Furthermore, the tool node, condition node, start node, and end node are used as subclasses of the node instance of the task node to configure the target node instance. The target node instance is configured with properties such as node identification, node type, input format, output format, variable reference definition, preset parameters, previous node information, and subsequent node information. For example, the node identification is in string format, the node type is in string format, the input format is in dictionary format, the output format is in dictionary format, the variable reference definition is in list format, the preset parameters are in dictionary format, the previous node information is a previous node list, and the subsequent node information is a subsequent node list. At the same time, the target node instance is also configured with the operation method of the target node instance, for example, the calling method (also known as the invoke method) and the next node instance triggered.
[0084] A first workflow instance is generated based on the target node instance, and the first workflow instance is configured with properties such as a start node, an end node, and a node instance list. At the same time, an operation method of the first workflow instance is configured in the first workflow instance, for example, a calling method is adopted. Furthermore, a workflow tool is configured based on the first workflow instance, and properties such as workflow, label, and JS key-value pair data (JavaScript Object Notation, referred to as JSON) format are configured in the workflow tool. For example, the workflow is the first workflow instance, the label is an optional label list, and the JS key-value pair data format is a dictionary format. At the same time, an operation method of the workflow tool is also configured in the workflow tool, for example, a running method is adopted, and the output format of the running method is a dictionary format. In addition, an executable interface of the target node instance and the first workflow instance is also configured to call the target node instance and the first workflow instance. Among them, the executable interface uses a calling method to output data.
[0085] In this embodiment, a task processing method is provided, which can be used for a target agent. Figure 4 is a flowchart of a task processing method according to an embodiment of the present disclosure, such as Figure 4 As shown, the process includes the following steps:
[0086] Step S401, obtaining the target function corresponding to the target task.
[0087] It should be noted that the target function is the function that the target agent needs to have in the process of processing the target task.
[0088] Step S402, based on the target function, a first workflow instance is determined in a tool list, where the tool list is used to characterize a workflow instance corresponding to a function of a target agent; the first workflow instance is an instantiation of a task node in a target workflow for realizing the target function, and is constructed based on the instantiated node instance.
[0089] It can be understood that the tool list includes workflow instances corresponding to different functions of the target agent, including workflow instances of preset tools and workflow instances of new functions obtained by reusing preset tools. In actual operation, the tool list can be matched according to the target function to determine the first workflow instance. If the first workflow instance of the target function does not exist in the tool list, the corresponding first workflow instance can be configured through the above-mentioned function configuration method to perform the target task.
[0090] It should be noted that the construction method of the node instance can refer to the construction method of the target node instance in the above function configuration method, and will not be described in detail here.
[0091] Step S403: execute the first workflow instance to obtain a task processing result of the target task.
[0092] Specifically, the target task may be executed by calling the first workflow instance to obtain the task processing result of the target task.
[0093] The task processing method provided in this embodiment constructs a target workflow of a target function to construct a first workflow instance for realizing the target function. Then, the first workflow instance is added to the tool list of the target agent. Furthermore, when the target agent faces a target task of the target function, it can call the first workflow instance in the tool list to realize the processing of the target task to obtain the task processing result. Therefore, in the face of new task requirements, tasks can also be completed by constructing workflows without re-modifying existing tools or building new codes, which can effectively improve the target agent's ability to handle different tasks.
[0094] In some optional implementations, executing the first workflow instance in step S403 to obtain a task processing result of the target task includes:
[0095] Step c1: for a node instance in the first workflow instance, obtain the execution status of the preceding node of the current node instance.
[0096] It should be noted that the node instance used to represent the start node does not have a preceding node. Therefore, the node instance used to represent the start node can be directly executed.
[0097] It should be noted that, in the initial state, the in-degree of the current node instance is the number of the previous order nodes. Each time a node instance of a previous order node is executed, the in-degree of the current node instance is reduced by one. If the in-degree of the current node instance is judged to be zero, it indicates that the previous order nodes (or the node instances of the previous order nodes) have all been executed. If the in-degree of the current node instance is judged to be non-zero, it indicates that there are previous order nodes that have not been executed.
[0098] Step c2: If all previous nodes have been executed, the current node instance is executed.
[0099] It should be noted that if there is a previous node that has not been executed, the current node instance will not be executed.
[0100] Step c3: if the current node instance is executed, the next node instance of the current node instance is triggered.
[0101] It should be noted that the next node instance is the node instance of the successor node corresponding to the current node instance.
[0102] Step c4: if the last node instance in the first workflow instance is executed, the output result of the last node instance is determined as the task processing result.
[0103] The task processing method provided in this embodiment executes the current node instance when all the previous nodes have been executed. And when the current node instance is executed, the next node instance of the current node instance is triggered. Therefore, the accuracy of the execution order of each node instance can be ensured, thereby improving the accuracy of the task processing result finally outputted.
[0104] In some optional implementations, if all previous nodes in step c2 are executed, then executing the current node instance includes:
[0105] Step c21: If all previous nodes have been executed, the current node instance is added to the queue to be executed.
[0106] It should be noted that, in the initial state, only the node instance representing the start node is in the queue to be executed.
[0107] It is understandable that there may be multiple parallel branches in the target workflow. Therefore, adding executable node instances to the queue to be executed can facilitate the regulation of computing resources of executable node instances. At the same time, since the queue adopts a first-in-first-out processing method, it can also ensure the sequential execution of each node instance, facilitate tracking of node instances that have been processed, and avoid repeated processing.
[0108] Step c22, executing the node instances in the queue to be executed.
[0109] Specifically, the node instances in the queue to be executed are traversed, and during the execution process, the node instances in the queue to be executed are dynamically updated until the node instance representing the end node is executed and the execution of the entire first workflow instance is completed.
[0110] The task processing method provided in this embodiment, if all the previous nodes are executed, then the current node instance is added to the queue to be executed. Then, the node instance in the queue to be executed is executed. Therefore, the sequential execution of each node instance can be ensured, and it is convenient to track the node instances that have been processed to avoid repeated processing.
[0111] As an example, the task processing method of the present disclosure is described below with a specific example. Figure 5 As shown, the execution process of the first workflow instance includes the following steps:
[0112] Step S501, execute the start node, after the start node is executed, execute step S502.
[0113] Step S502, triggering the node instance of the next task node, and then executing step S503.
[0114] Step S503, determine whether the current node instance can be executed, if yes, execute step S504, if no, return to step S503.
[0115] Step S504, execute the current node instance, and after the current node instance is executed, execute step S505.
[0116] Step S505, determine whether the next node instance is an end node, if so, execute step S506, if not, return to step S502.
[0117] Step S506, executing the end node, and after the end node is executed, executing step S507.
[0118] Step S507, output the task processing result, and the execution process ends.
[0119] As a specific application example, a target program is installed on the configuration platform, and the target program is used to execute the functional configuration method of the present disclosure. Relevant personnel can build a target workflow for realizing the target function through the page displayed by the configuration platform. Then, the configuration platform instantiates the target workflow through the functional configuration method of the present disclosure to obtain a first workflow instance. And add the first workflow instance to the tool list of the target agent, so that the target agent can realize the target function through the first workflow instance in the tool list.
[0120] It is worth noting that the present disclosure builds the target workflow of the target function based on the executable interface and preset tools of the language model application development framework. Therefore, complex tasks can be decomposed into smaller steps (i.e., task nodes) through the target workflow to reduce the complexity of task processing. At the same time, the preset tools can be added to the target workflow as tool nodes to build a more complex tool (i.e., the first workflow instance) for the target agent to use, without the need to re-modify the existing preset tools or build new code, and the function expansion of the target agent is simple.
[0121] In the present embodiment, a functional configuration device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0122] This embodiment provides a function configuration device, such as Figure 6 As shown, including:
[0123] The data acquisition module 601 is used to acquire configuration instructions, which are used to instantiate the task nodes in the target workflow to obtain the target node instance, and the target workflow is used to implement the target function;
[0124] A first processing module 602, configured to construct a first workflow instance of a target workflow based on a target node instance;
[0125] The second processing module 603 is used to add the first workflow instance to a tool list, where the tool list is used to represent workflow instances corresponding to functions of the target agent, and the target agent is constructed based on the tool list.
[0126] In some optional implementations, the data acquisition module 601 includes:
[0127] The attribute acquisition unit is used to obtain the attribute information of the task node.
[0128] The attribute configuration unit is used to configure the attributes of the task node based on the attribute information to obtain the target node instance.
[0129] In some optional implementations, the attribute information includes input configuration information and output configuration information of the task node. Then, the attribute configuration unit includes:
[0130] The input-output configuration subunit is used to configure the input of the task node based on the input configuration information, and to configure the output of the task node based on the output configuration information to obtain a target node instance.
[0131] In some optional implementations, the attribute information also includes the preceding node information of the task node. Then, the attribute configuration unit includes:
[0132] The execution condition configuration subunit is used to configure the execution condition of the task node based on the predecessor node information to obtain the target node instance. The execution condition is used to indicate that the predecessor nodes of the task node have all been executed.
[0133] In some optional implementations, the attribute information also includes the successor node information of the task node. Then, the attribute configuration unit includes:
[0134] The successor node configuration subunit is used to configure the next task node triggered after the task node is executed based on the successor node information to obtain a target node instance.
[0135] In some optional implementations, the attribute information also includes the node type of the task node and the function configuration information corresponding to the node type. Then, the attribute configuration unit includes:
[0136] The node function configuration subunit is used to configure the type of the task node based on the node type, and to configure the function of the task node based on the function configuration information to obtain a target node instance.
[0137] In some optional implementations, the node type includes a conditional node, and the function configuration information includes a target condition corresponding to the conditional node. Then, the node function configuration subunit is used to configure the function of the task node based on the function configuration information, including: configuring the condition for executing the task node based on the target condition.
[0138] In some optional implementations, the node type includes a tool node, and the function configuration information includes a second workflow instance in the tool list. Then, the node function configuration subunit is used to configure the function of the task node based on the function configuration information, including: configuring the workflow instance called by the task node based on the second workflow instance.
[0139] In some optional implementations, the first processing module 602 includes:
[0140] A list building unit, used for building a call list for calling a target node instance;
[0141] The instance generating unit is used to generate a first workflow instance based on the calling list.
[0142] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0143] The functional configuration device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0144] In this embodiment, a task processing device is also provided, which is used to implement the embodiments and preferred implementations of the above-mentioned task processing method, which have been described and will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceivable.
[0145] This embodiment provides a task processing device, which is applicable to a target agent, such as Figure 7 As shown, including:
[0146] The function acquisition module 701 is used to acquire the target function corresponding to the target task.
[0147] The instance determination module 702 is used to determine the first workflow instance in the tool list based on the target function. The tool list is used to characterize the workflow instance corresponding to the function of the target agent. The first workflow instance is to instantiate the task node in the target workflow used to implement the target function and is constructed based on the node instance obtained by instantiation.
[0148] The task execution module 703 is used to execute the first workflow instance to obtain a task processing result of the target task.
[0149] In some optional implementations, the task execution module 703 includes:
[0150] The first processing unit is used to obtain the execution status of the previous node of the current node instance for the node instance in the first workflow instance.
[0151] The second processing unit is used to execute the current node instance if all previous nodes have been executed.
[0152] The third processing unit is used to trigger the next node instance of the current node instance if the current node instance is executed.
[0153] The fourth processing unit is configured to determine the output result of the last node instance as the task processing result if the last node instance in the first workflow instance is executed completely.
[0154] In some optional implementations, the second processing unit includes:
[0155] The first processing sub-unit is used to add the current node instance to the queue to be executed if all the previous nodes have been executed.
[0156] The second processing subunit is used to execute the node instances in the queue to be executed.
[0157] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0158] The functional configuration device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0159] The present disclosure also provides an electronic device having the above Figure 6 The functional configuration device shown or Figure 7 The task processing device shown.
[0160] See also Figure 8 , Figure 8 is a structural block diagram of an electronic device provided by an optional embodiment of the present disclosure, such as Figure 8 As shown, the electronic device includes: one or more processors 801, memory 802, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 8A processor 801 is taken as an example.
[0161] The processor 801 may be a central processing unit, a network processor or a combination thereof. The processor 801 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable logic gate array, a general purpose array logic or any combination thereof.
[0162] The memory 802 stores instructions executable by at least one processor 801, so that the at least one processor 801 executes the method shown in the above embodiment.
[0163] The memory 802 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 802 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 802 may optionally include a memory remotely arranged relative to the processor 801, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0164] The memory 802 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 802 may also include a combination of the above types of memory.
[0165] The electronic device also includes an input device 803 and an output device 804. The processor 801, the memory 802, the input device 803 and the output device 804 may be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.
[0166] The input device 803 can receive input digital or character information, and generate key signal input related to the user settings and function control of the electronic device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick, etc. The output device 804 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0167] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0168] A part of the present disclosure may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present disclosure through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.
[0169] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A function configuration method, characterized in that: The method comprises: Obtaining a configuration instruction, wherein the configuration instruction is used to instantiate a task node in a target workflow to obtain a target node instance, wherein the target workflow is used to implement a target function; Constructing a first workflow instance of the target workflow based on the target node instance; The first workflow instance is added to a tool list, where the tool list is used to characterize workflow instances corresponding to functions of a target agent, and the target agent is constructed based on the tool list.
2. The function configuration method according to claim 1, characterized in that: The instantiation of the task node in the target workflow to obtain the target node instance includes: Obtaining attribute information of the task node; The task node is attribute-configured based on the attribute information to obtain the target node instance.
3. The function configuration method according to claim 2, characterized in that: The attribute information includes input configuration information and output configuration information of the task node; and the step of configuring the task node based on the attribute information to obtain the target node instance includes: The input of the task node is configured based on the input configuration information, and the output of the task node is configured based on the output configuration information to obtain the target node instance.
4. The function configuration method according to claim 2, characterized in that: The attribute information also includes the preceding node information of the task node; and the attribute configuration of the task node based on the attribute information to obtain the target node instance further includes: The execution condition of the task node is configured based on the predecessor node information to obtain the target node instance, and the execution condition is used to indicate that the predecessor nodes of the task node are all executed.
5. The function configuration method according to claim 2, characterized in that: The attribute information also includes the successor node information of the task node; and the attribute configuration of the task node based on the attribute information to obtain the target node instance also includes: The next task node triggered after the task node is executed is configured based on the successor node information to obtain the target node instance.
6. The function configuration method according to claim 2, characterized in that: The attribute information also includes the node type of the task node and the function configuration information corresponding to the node type; and the attribute configuration of the task node based on the attribute information to obtain the target node instance also includes: The type of the task node is configured based on the node type, and the function of the task node is configured based on the function configuration information to obtain the target node instance.
7. The function configuration method according to claim 6, characterized in that: The node type includes a conditional node, the function configuration information includes a target condition corresponding to the conditional node, and the configuring the function of the task node based on the function configuration information includes: The conditions for executing the task node are configured based on the target conditions.
8. The function configuration method according to claim 6, characterized in that: The node type includes a tool node, the function configuration information includes a second workflow instance in the tool list, and the configuring the function of the task node based on the function configuration information includes: The workflow instance called by the task node is configured based on the second workflow instance.
9. The function configuration method according to claim 1, characterized in that: The step of constructing the first workflow instance of the target workflow based on the target node instance includes: Constructing a call list for calling the target node instance; The first workflow instance is generated based on the call list.
10. A task processing method, characterized in that: The method comprises: Get the target function corresponding to the target task; Determine a first workflow instance in a tool list based on the target function, the tool list is used to characterize a workflow instance corresponding to a function of a target agent; the first workflow instance is constructed based on a node instance obtained by instantiating a task node in a target workflow for realizing the target function; The first workflow instance is executed to obtain a task processing result of the target task.
11. The task processing method according to claim 10, characterized in that: The executing the first workflow instance to obtain the task processing result of the target task includes: For a node instance in the first workflow instance, obtaining the execution status of a preceding node of the current node instance; If all the previous nodes are executed, the current node instance is executed; If the current node instance is executed, the next node instance of the current node instance is triggered; If the last node instance in the first workflow instance is executed completely, the output result of the last node instance is determined as the task processing result.
12. The task processing method according to claim 11, characterized in that: If the preceding nodes are all executed, then executing the current node instance includes: If all the previous nodes have been executed, the current node instance is added to the queue to be executed; Execute the node instances in the queue to be executed.
13. A function configuration device, characterized in that: The device comprises: A data acquisition module is used to acquire configuration instructions, wherein the configuration instructions are used to instantiate task nodes in a target workflow to obtain a target node instance, and the target workflow is used to implement a target function; A first processing module, configured to construct a first workflow instance of the target workflow based on the target node instance; The second processing module is used to add the first workflow instance to a tool list, where the tool list is used to characterize workflow instances corresponding to functions of a target agent, and the target agent is constructed based on the tool list.
14. A task processing device, characterized in that: The device comprises: Function acquisition module, used to obtain the target function corresponding to the target task; An instance determination module is used to determine a first workflow instance in a tool list based on the target function, wherein the tool list is used to characterize a workflow instance corresponding to a function of a target agent; the first workflow instance is constructed based on a node instance obtained by instantiating a task node in a target workflow for realizing the target function; The task execution module is used to execute the first workflow instance to obtain the task processing result of the target task.
15. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the function configuration method described in any one of claims 1 to 9, or the task processing method described in any one of claims 10 to 12 by executing the computer instructions.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the function configuration method described in any one of claims 1 to 9, or the task processing method described in any one of claims 10 to 12.
17. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the function configuration method according to any one of claims 1 to 9, or the task processing method according to any one of claims 10 to 12.
Citation Information
Patent Citations
Workflow engine and realization method thereof
CN106529761A
Operation method and device of workflow instance, electronic equipment and storage medium
CN114862368A
Task execution method and device
CN117574907A
Equipment deployment method and system of AI model and storage medium
CN117677930A
Workflow processing method, electronic device, and storage medium
US20240311179A1