Function calling method, related method, device, equipment and storage medium
By analyzing historical call records to match and select historical functions with high similarity as objective functions, the problem that the agent needs to re-execute the function call process when processing new requirements is solved, and the agent's learning ability and execution efficiency are improved.
Patent Information
- Application Number
- CN202411602139.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-03-07
AI Technical Summary
Existing agents must re-run the function call process when processing new requirements, resulting in low learning ability and execution efficiency.
By obtaining the historical call record, matching the current requirement description to obtain the preset function as the current function, and calculating the function similarity between the current function and the historical function, selecting a historical function with high similarity as the objective function to handle the current requirement.
By referring to function calls that refer to historical requirements, the agent can reuse past experience in similar tasks, avoid re-planning tool call strategies, thereby improving the agent's dynamic adaptability to new tools and new needs, and improving learning ability and execution efficiency.
Smart Images

Figure CN119577109A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a function calling method and related methods, devices, equipment and storage media. Background Art
[0002] Tool calling (i.e. function calling) is one of the core functions of the intelligent agent, which gives the intelligent agent the ability to perform external tasks in specific scenarios. Compared with the text generation function of simply using a large language model, by calling tools such as APIs, the intelligent agent is able to have actual operation capabilities.
[0003] At present, the existing intelligent agents must re-call the function process every time they process new requirements, resulting in low learning ability and execution efficiency of the intelligent agents. In view of this, how to call functions when processing new requirements to improve the learning ability and execution efficiency of the intelligent agents has become an urgent problem to be solved. Summary of the invention
[0004] The main technical problem solved by the present application is to provide a function calling method and related methods, devices, equipment and storage media, which can refer to the function calls of historical requirements when processing new requirements, which helps to improve the learning ability and execution efficiency of the intelligent body.
[0005] In order to solve the above technical problems, the first aspect of the present application provides a function calling method, including: obtaining historical call records, and obtaining a preset function that matches the current demand description as the current function; wherein the current demand description is the user demand description currently processed by the intelligent agent, and the historical call records contain the historical functions finally called by the intelligent agent when processing the historical demand description; obtaining the function similarity between the current function and each historical function respectively; based on the historical functions selected by the function similarity, obtaining the target function finally called to process the current demand description.
[0006] In order to solve the above-mentioned technical problems, the second aspect of the present application provides an intelligent dialogue method, including: obtaining a target function that is finally called to process the current demand description; wherein the current demand description is a user demand description currently processed by the intelligent agent, and the target function is determined based on the function calling method in the above-mentioned first aspect; calling the target function to obtain a return result of the target function; processing the current demand description and the return result based on a large language model to obtain the intelligent agent's response to the current demand description.
[0007] In order to solve the above technical problems, the third aspect of the present application provides a function calling device, including: an acquisition module, a measurement module and a determination module, the acquisition module is used to obtain historical call records, and obtain a preset function matching the current demand description as the current function; wherein the current demand description is the user demand description currently processed by the intelligent agent, and the historical call records contain the historical functions finally called by the intelligent agent when processing the historical demand description; the measurement module is used to obtain the function similarity between the current function and each historical function respectively; the determination module is used to obtain the target function finally called to process the current demand description based on the historical function selected by the function similarity.
[0008] In order to solve the above technical problems, the fourth aspect of the present application provides an intelligent dialogue device, including: an acquisition module, a calling module and a reply module, the acquisition module is used to obtain the target function finally called to process the current demand description; wherein the current demand description is the user demand description currently processed by the intelligent agent, and the target function is determined based on the function calling device in the above third aspect; the calling module is used to call the target function and obtain the return result of the target function; the reply module is used to process the current demand description and return the result based on the large language model to obtain the intelligent agent's reply to the current demand description.
[0009] In order to solve the above-mentioned technical problems, the fifth aspect of the present application provides an electronic device, which at least includes a memory and a processor coupled to each other, wherein the memory at least stores program instructions, and the processor is used to execute the program instructions to implement the function calling method in the above-mentioned first aspect, or to implement the intelligent dialogue method in the above-mentioned second aspect.
[0010] In order to solve the above technical problems, the sixth aspect of the present application provides a computer-readable storage medium, which stores program instructions that can be executed by a processor, and the program instructions are used to implement the function calling method of the above first aspect, or to implement the intelligent dialogue method in the above second aspect.
[0011] The above scheme obtains historical call records, and obtains a preset function that matches the current demand description as the current function, and the current demand description is the user demand description currently processed by the intelligent agent. The historical call record contains the historical function that the intelligent agent finally calls when processing the historical demand description, and then obtains the function similarity between the current function and each historical function, and based on the historical function selected by the function similarity, obtains the target function that is finally called when processing the current demand description. Therefore, through the similarity analysis of historical call records, it is possible to refer to historical functions in similar tasks to determine the target function that is finally called when processing the current demand description, which helps to reuse past experience based on similar tasks, avoid re-planning tool call strategies as much as possible, and improve the dynamic adaptability of the intelligent agent to new tools and new requirements. Therefore, by referring to the function calls of historical requirements when processing new requirements, it helps to improve the learning ability and execution efficiency of the intelligent agent. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 This is a flow chart of an embodiment of a function calling method of the present application; Figure 2 This is a process diagram of an embodiment of a function calling method of the present application; Figure 3 This is a flow chart of an embodiment of the intelligent dialogue method of the present application; Figure 4 A schematic diagram of a framework of an embodiment of a function calling device of this application; Figure 5 It is a schematic diagram of the framework of an embodiment of the intelligent dialogue device of the present application; Figure 6 It is a schematic diagram of the framework of an embodiment of the electronic device of the present application; Figure 7 It is a schematic diagram of a framework of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0013] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.
[0014] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.
[0015] The terms "system" and "network" are often used interchangeably in this article. The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the fragment " / " in this article generally indicates that the associated objects before and after are in an "or" relationship. In addition, "many" in this article means two or more than two.
[0016] See also Figure 1 , Figure 1 This is a flow chart of an embodiment of the function calling method of the present application. Specifically, it may include the following steps: Step S11: Obtain historical call records, and obtain a preset function that matches the current requirement description as the current function.
[0017] In the disclosed embodiment, the current demand description refers to the user demand description currently processed by the agent. Exemplarily, the agent can be customized according to the specific usage scenario. For example, the office OA agent can be used to assist in applying for leave, business trip, reimbursement, etc.; or, the travel agent can be used to assist in booking hotels, booking air tickets, checking guides, etc. It should be noted that the above-mentioned agents are only several possible examples in the actual application process, and the specific use of the agent is not limited here. In addition, the user demand description can be input into the agent for processing in the form of text input, voice input, etc. Exemplarily, the user demand description may include but is not limited to the following specific content: "Help me check whether it will be sunny, rainy or cloudy in City A tomorrow", "Help me book a ticket to City B tomorrow, and require a window seat", etc. It should be noted that the above examples are only several possible examples of user demand descriptions, and the specific content of the user demand description is not limited here.
[0018] In the disclosed embodiment, the historical call record may include the historical function finally called by the agent to process the historical demand description. Taking the historical demand description "help me check whether it will be sunny or rainy tomorrow in City C" as an example, the historical function finally called can be recorded as ,in, Represents the input parameter "location", Represents the input parameter "time", Indicates the output parameter "sunny day", Indicates the output parameter "Rainy Day". In this example, the parameter value of the input parameter "Location" is "City C", the parameter value of the input parameter "Time" is "Tomorrow", the parameter value of the output parameter "Sunny Day" is 0, which means "Not Sunny Day", and 1, which means "Sunny Day". The parameter value of the output parameter "Rainy Day" is 0, which means "Not Rainy Day", and 1, which means "Rainy Day". Of course, the above historical function is only a possible example in the actual application process, and does not limit the specific content of the historical call, so it will not be given one by one here.
[0019] In an implementation scenario, each historical call record may correspond to a historical task. It should be noted that if a historical requirement description contains multiple historical tasks, each historical task may correspond to a historical call record. For example, taking the historical requirement description "Please help me check whether it will be sunny or rainy tomorrow in City C, and then help me book a ticket to City C tomorrow" as an example, it includes two historical tasks, "Check the weather" and "Book a ticket". Among them, the historical call record corresponding to the historical task "Check the weather" may include the historical function that is finally called to process the historical requirement description "Please help me check whether it will be sunny or rainy tomorrow in City C" The historical call record corresponding to the historical task "book a ticket" can include the historical function that was finally called to process the historical requirement description "book me a ticket to City C tomorrow" ,in, For the specific meanings of the two, please refer to the above related descriptions. Indicates the output parameter "result". In this example, the parameter value of the output parameter "result" can include but is not limited to: "success", "failure", etc. It should be noted that the above examples are only examples of the correspondence between the historical demand description and the historical call record when the historical demand description contains multiple historical tasks. Other possible situations will not be given one by one here.
[0020] In an implementation scenario, in addition to including historical functions (i.e., their function names, function parameters, etc.), historical call records may also include, but are not limited to: call time, call results (e.g., call success, call failure), demand description, etc. The specific content of the historical call records is not limited here. It should be noted that the demand description in the historical call record may specifically be the part of the demand description of the historical task corresponding to the historical call record. Still taking the historical demand description "Please help me check whether it will be sunny or rainy tomorrow in City C, and then help me book a ticket to City C tomorrow" as an example, for the historical function For the historical call records, the requirement description can be "Help me check whether it will be sunny or rainy in City C tomorrow", and for the historical function For the historical call records of , the demand description can be "help me book a ticket to City C tomorrow." Of course, the above example is only one possible example in the actual application process, and other possible situations will not be given one by one here.
[0021] In an implementation scenario, after obtaining the current demand description, an artificial intelligence model such as a large language model or an intent recognition model can be used to identify the intent of the current demand description to obtain the target intent of the current demand description. On this basis, the target intent can be matched with each preset function in the function set to select the preset function as the current function. It should be noted that the preset functions in the function set may include but are not limited to APIs, etc., and the specific types of preset functions are not limited here. Exemplarily, the function set may include but is not limited to the following preset functions: , Etc. Taking the current demand description "Help me check whether it will be sunny, rainy or cloudy in City A tomorrow" as an example, its target intent is "check the weather", then you can select the preset function in the function set As the current function. Of course, the above examples are only possible examples of preset functions and current functions, and the specific contents of the preset functions and current functions are not limited here. In addition, for the convenience of description, each current function can be recorded as .
[0022] In an implementation scenario, for ease of processing, both the current function and the historical call records can be stored in structured data such as JSON. In addition, for the historical call records, the function name can be used as the key of the historical call record, and the function parameters, call time, call result, requirement description, etc. can be used as the value of the historical call record. Of course, the above example is only a possible example of data storage, and the specific format of data storage is not limited here.
[0023] Step S12: Obtain the function similarity between the current function and each historical function.
[0024] In one implementation scenario, as a possible implementation method, the feature vector of the current function can be extracted based on the attribute information of the current function, and the feature vector of the historical function can be extracted based on the attribute information of the historical function. On this basis, the semantic similarity between the current function and the historical function can be calculated based on the feature vector of the current function and the feature vector of the historical function, as the function similarity between the current function and the historical function. It should be noted that the attribute information may include but is not limited to: function name, function description, call structure, etc., and the specific content of the attribute information is not limited here. In addition, the semantic similarity can be specifically measured using a similarity measurement method such as cosine similarity, which is also not limited here. For example, taking the cosine similarity measurement as an example, the function similarity between the current function and the i-th historical function is : …… (1) In the above formula (1), represents the eigenvector of the current function, represents the eigenvector of the i-th history function, Represents the magnitude of the eigenvector.
[0025] In another implementation scenario, different from the aforementioned implementation, as another possible implementation, the parameter similarity between the current function and the historical function can also be measured based on the function parameters of the current function and the function parameters of the historical function, as the function similarity between the current function and the historical function. Specifically, the similarity in the number of parameters between the current function and the historical function can be obtained based on the total number of parameters of each of the current function and the historical function. For example, the closer the total number of parameters of the two are, the higher the similarity in the number of parameters between the two. Conversely, the farther the total number of parameters of the two are, the lower the similarity in the number of parameters between the two. Exemplarily, if the total number of parameters of the two are equal, it can be determined that the similarity in the number of parameters between the two is 1. Conversely, if the total number of parameters of the two are not equal, it can be determined that the similarity in the number of parameters between the two is 0. Then the similarity in the number of parameters between the current function and the i-th historical function is 0. It can be expressed as: …… (2) In the above formula (2), Indicates the current function The total number of parameters, Represents the i-th history function At the same time, the parameter type similarity between the current function and the historical function can be obtained based on the number of parameters of the same type between the current function and the historical function. For example, the ratio between the number of parameters of the same type between the current function and the historical function and the total number of parameters of the current function can be taken as the parameter type similarity between the current function and the historical function, then the parameter type similarity between the current function and the i-th historical function is It can be expressed as: …… (3) In the above formula (3), Indicates the number of parameters of the same type between the current function and the i-th historical function. , and the i-th history function is For example, the number of parameters with the same type is 1, that is, the input parameter "location" . On this basis, the parameter similarity can be obtained based on the parameter quantity similarity and the parameter type similarity, which can be used as the function similarity between the current function and the historical function. It should be noted that the parameter similarity is positively correlated with the parameter quantity similarity and the parameter type similarity. Exemplarily, the parameter similarity can be obtained by multiplying the parameter quantity similarity and the parameter type similarity, that is, the function similarity between the current function and the historical function. Exemplarily, the function similarity between the current function and the i-th historical function It can be expressed as: …… (4) The above method obtains the similarity of the number of parameters between the current function and the historical function based on the total number of parameters of each of the current function and the historical function, and obtains the similarity of the parameter type between the current function and the historical function based on the number of parameters of the same type in the current function and the historical function. Then, based on the similarity of the number of parameters and the similarity of parameter types, the parameter similarity is obtained. The parameter similarity is positively correlated with the similarity of the number of parameters and the similarity of parameter types. Therefore, the similarity between the current function and the historical function can be measured from the two dimensions of the number of parameters and the parameter type, which helps to improve the accuracy of function similarity.
[0026] In another implementation scenario, different from the aforementioned implementation, as another possible implementation, the semantic similarity between the current function and the historical function can also be obtained, and the parameter similarity between the current function and the historical function can also be obtained. It should be noted that the specific measurement method of semantic similarity and parameter similarity can refer to the aforementioned related description, which will not be repeated here. On this basis, the function similarity can be obtained by weighting based on the semantic similarity and parameter similarity. Exemplarily, the function similarity between the current function and the i-th historical function It can be expressed as: …… (5) In the above formula (5), Represents the semantic similarity between the current function and the i-th historical function. For specific calculation, please refer to formula (1) and related descriptions. represents the parameter similarity between the current function and the i-th historical function. For specific calculations, please refer to formulas (2) to (4) and related descriptions. In addition, represents the weighting factor of semantic similarity, It is necessary to explain that the weighting factor of semantic similarity is Weighting factor for similarity to parameters The specific values of the two can be set according to the actual application needs, and the specific values of the two are not limited here. The above method obtains the semantic similarity between the current function and the historical function, and obtains the parameter similarity between the current function and the historical function, and then weights the function similarity based on the semantic similarity and parameter similarity. It can measure the similarity between the current function and the historical function from the two dimensions of semantics and parameters, which helps to improve the accuracy of the similarity measurement, and then can assist the intelligent agent to reuse the previously successful tool call strategy or plan to avoid re-planning the tool call process.
[0027] Step S13: Based on the historical functions selected by function similarity, the target function finally called to process the current demand description is obtained.
[0028] In an implementation scenario, the historical function with the maximum function similarity can be directly selected as the target function for processing the final call of the current requirement description.
[0029] In another implementation scenario, different from the aforementioned implementation, it is also possible to first detect whether there is a historical function whose function similarity is higher than the similarity threshold. On this basis, in response to the detection result being existence, a historical function whose function similarity is higher than the similarity threshold can be selected as the target function; and in response to the detection result being non-existent, a historical function with the highest similarity can be selected as a candidate function, and parameters can be adjusted based on the candidate function to obtain the target function. The above method treats the two situations of whether there is a historical function whose function similarity is higher than the similarity threshold differently. When it exists, the historical function is directly selected as the target function, and when it does not exist, the optimal historical function is selected and parameters are adjusted. Therefore, for both situations, the adaptability of the target function to the current demand description can be improved as much as possible.
[0030] In a specific implementation scenario, the specific value of the similarity threshold can be set according to the actual application needs. For example, when the accuracy of the function call is required to be high, the similarity threshold can be set to be larger, or when the accuracy of the function call is relatively loose, the similarity threshold can be set to be appropriately smaller. The specific value of the similarity threshold is not limited here, and no examples are given one by one.
[0031] In a specific implementation scenario, after selecting a candidate function, the parameter settings of the candidate function can be compared based on the current requirement description to determine the parameter items to be optimized in the candidate function, such as the parameter items that need to be deleted and the parameter items that need to be added in the candidate function. As a possible example, a first prompt can be constructed based on the current requirement description and the parameter settings of the candidate function, and the first prompt is used to instruct the large language model to distinguish the parameter items to be optimized in the parameter settings of the candidate function according to the current requirement description, and then the first prompt is input to the large language model, and the output parameters of the large language model are obtained to determine the parameter items to be optimized in the candidate function. Therefore, the general understanding ability of the large language model can be used to compare the current requirement description and the parameter configuration of the candidate function, which helps to improve the effectiveness and reliability of the target function. It should be noted that the large language model may include but is not limited to: open source large models such as LLAMA, Bloom, or trained based on a specific training set, or a custom large model. The specific source of the large language model is not limited here. Taking the current requirement description "Help me check whether it will be sunny, rainy or cloudy tomorrow in City C" as an example, you can choose a preset function As the current function, a historical function can be selected based on this As a candidate function, combined with the current demand description "help me check whether it will be sunny, rainy or cloudy in City C tomorrow", the parameter items to be optimized in the parameter configuration of the candidate function can be determined, that is, the parameter items to be added " On this basis, the parameter items to be optimized in the candidate function can be adjusted based on the current demand description to obtain the objective function. That is to say, in this example, based on the current demand description "help me check whether it will be sunny, rainy or cloudy in City C tomorrow", New parameter item in: Output parameter "cloudy", that is , we can get the objective function: Of course, the above example is only one possible example of adjusting the candidate function to obtain the objective function in the actual application process, and other possible situations will not be given one by one here. The above method compares the parameter settings of the candidate function based on the current demand description, determines the parameter items to be optimized in the candidate function, and then adjusts the parameter items to be optimized in the candidate function based on the current demand description to obtain the objective function, which helps to improve the effectiveness and reliability of the objective function.
[0032] In an implementation scenario, after obtaining the objective function, in order to further improve the effectiveness and reliability of the objective function, the verification code of the objective function can also be obtained, and the verification code simulates the task logic of the current requirement description. As a possible example, the code generation capability of the large language model can be used to generate the verification code. For example, a second prompt can be constructed based on the current requirement description and the objective function, and the second prompt is used to instruct the large language model to simulate the task logic to generate the verification code, and then the second prompt is input to the large language model, and the output code of the large language model is obtained as the verification code of the objective function. On this basis, the objective function can be tested based on the verification code to see whether it meets the task requirements, that is, whether it meets the task requirements described in the current requirement description. If it meets the task requirements, the objective function that is finally called can be obtained. If it does not meet the task requirements, the objective function can continue to be adjusted until it meets the task requirements. In the above method, after obtaining the objective function, the verification code of the objective function is obtained, and the verification code simulates the task logic of the current requirement description, and then based on the verification code, the objective function is tested to see whether it meets the task requirements, which can further improve the effectiveness and reliability of the objective function.
[0033] In one implementation scenario, after obtaining the target function of the final call, the historical mobilization record can also be updated based on the target function. As a possible example, the target function can be obtained by directly selecting a historical function. In this case, only the call time and requirement description in the historical call record where the selected historical function is located can be updated. As another possible example, the target function can also be obtained by adjusting parameters based on the selected historical function. In this case, a new historical call record can be added, and the historical function in the newly added historical call record is the target function of this time. The call time, call result, requirement description, etc. of the target function of this time can also be added to the newly added historical call record. In the above method, after obtaining the target function of the final call, the historical mobilization record is updated based on the target function, which can keep the historical call record dynamically updated, thereby ensuring that the intelligent agent can learn new tool call strategies in a timely manner.
[0034] In an implementation scenario, please refer to Figure 2 , Figure 2 This is a schematic diagram of the process of an embodiment of the function calling method of the present application. Figure 2As shown, when the agent processes the current demand description, it can first perform intent recognition, and select a preset function from the function set as the current function called when processing the current demand description, and then measure the similarity between the current function and the historical functions in each historical call record, so as to select the historical function according to the function similarity, and directly select the historical function as the target function for the final call when the function similarity meets the similarity threshold. On the contrary, when the function similarity does not meet the similarity threshold, the historical function with the highest function similarity can be selected as the candidate function, and then the candidate function is adjusted and optimized to obtain the target function. After determining the target function to be finally called, on the one hand, the target function can be called to obtain the feedback result, and the large language model can be used to generate the agent response to the current demand description, and on the other hand, the historical call record can be updated accordingly. Specifically, the function name and related parameters of the target function can be encapsulated as a dictionary, and the call time, call result and demand description of the target function can be obtained, and all information can be stored in the historical call record of the target function. For ease of processing, as mentioned above, the historical call record can be stored as formatted data such as JSON.
[0035] The above scheme obtains historical call records, and obtains a preset function that matches the current demand description as the current function, and the current demand description is the user demand description currently processed by the intelligent agent. The historical call record contains the historical function that the intelligent agent finally calls when processing the historical demand description, and then obtains the function similarity between the current function and each historical function, and based on the historical function selected by the function similarity, obtains the target function that is finally called when processing the current demand description. Therefore, through the similarity analysis of historical call records, it is possible to refer to historical functions in similar tasks to determine the target function that is finally called when processing the current demand description, which helps to reuse past experience based on similar tasks, avoid re-planning tool call strategies as much as possible, and improve the dynamic adaptability of the intelligent agent to new tools and new requirements. Therefore, by referring to the function calls of historical requirements when processing new requirements, it helps to improve the learning ability and execution efficiency of the intelligent agent.
[0036] See also Figure 3 , Figure 3 This is a flow chart of an embodiment of the intelligent dialogue method of the present application. Specifically, it may include the following steps: Step S31: Obtain the target function that is finally called to process the current requirement description.
[0037] In the disclosed embodiment, the current demand description is the user demand description currently processed by the agent, and the objective function is determined based on the steps in the above function call method embodiment. For details, please refer to the above function call method embodiment, which will not be repeated here. As a possible example, taking the current demand description "help me check whether it will be sunny, rainy or cloudy in City C tomorrow" as an example, through the above function call method, the objective function finally called to process the current demand description can be obtained: Of course, the above example is only one possible example in the actual application process, and other possible situations will not be given one by one here.
[0038] Step S32: Call the target function and obtain the return result of the target function.
[0039] Specifically, in the process of calling the objective function, the parameter values of the input parameters in the objective function can be extracted from the current demand description, and based on the parameter values of the input parameters in the objective function, the objective function is executed to obtain the parameter values of the output parameters in the objective function, which is the return result of the objective function. For example, still taking the current demand description "Help me check whether it will be sunny, rainy or cloudy in City C tomorrow" as an example, the input parameters of the objective function can be extracted from it. The parameter value "C City" and the input parameters The parameter value "tomorrow" is used, and the above objective function is executed based on the above two parameter values. During the execution process, we can specifically The data source defined in (e.g., the URL of a weather query website) is searched to obtain the output parameters The parameter value "1", output parameter The parameter value "0" and the output parameter The parameter value "0" is the return result of the objective function. Of course, the above example is only a possible example in the actual application process, and other possible situations will not be given one by one here.
[0040] Step S33: Process the current demand description and return results based on the large language model to obtain the intelligent agent response to the current demand description.
[0041] Specifically, a third prompt can be constructed based on the current demand description and the returned result, and the third prompt is used to instruct the large language model to reply to the current demand description with reference to the returned result, and then the third prompt is input into the large language model, and the output content of the large language model is obtained as the agent reply to the current demand description. Still taking the current demand description "Help me check whether it will be sunny, rainy or cloudy tomorrow in City C" as an example, the following third prompt can be constructed: Taking the user demand description "Help me check whether it will be sunny, rainy or cloudy in City C tomorrow" as an example, the query results are The following information: Output parameters The parameter value is "1", the output parameter The parameter value "0" and the input Output Parameters The parameter value is "0". "1" means true, and "0" means false. Please answer based on the above information. Description of user requirements.
[0042] It should be noted that the third prompt is only a possible example in the actual application process, and the specific content of the third prompt is not limited here. After the third prompt is input into the large language model, the output content of the large language model, such as "It will be sunny tomorrow in City C", can be used as the agent's reply for the current demand description. Of course, in other cases, the agent's reply can also be other content, and the specific content of the agent's reply is not limited here.
[0043] The above scheme obtains the target function that is finally called to process the current demand description, and the current demand description is the user demand description that the agent is currently processing. The target function is determined based on the steps in the above function call method embodiment, and then the target function is called to obtain the return result of the target function, and the current demand description and the return result are processed based on the large language model to obtain the agent's response to the current demand description. Therefore, through similarity analysis of historical call records, it is possible to refer to historical functions in similar tasks to determine the target function that is finally called to process the current demand description, which helps to reuse past experience based on similar tasks, avoid re-planning tool call strategies as much as possible, and improve the agent's dynamic adaptability to new tools and new demands. Therefore, by referring to function calls to historical demands when processing new demands, it helps to improve the learning ability and execution efficiency of the agent.
[0044] See also Figure 4 , Figure 4 It is a schematic diagram of the framework of an embodiment of the function calling device of the present application. The function calling device 40 includes: an acquisition module 41, a measurement module 42 and a determination module 43. The acquisition module 41 is used to obtain historical call records and obtain a preset function matching the current demand description as the current function; wherein the current demand description is the user demand description currently processed by the intelligent agent, and the historical call record contains the historical function finally called by the intelligent agent when processing the historical demand description; the measurement module 42 is used to obtain the function similarity between the current function and each historical function respectively; the determination module 43 is used to obtain the target function finally called by processing the current demand description based on the historical function selected by the function similarity.
[0045] In the above scheme, the function calling device 40 obtains the historical call record, and obtains the preset function matching the current demand description as the current function, and the current demand description is the user demand description currently processed by the intelligent agent, and the historical call record contains the historical function finally called by the intelligent agent to process the historical demand description, and then obtains the function similarity between the current function and each historical function, and based on the historical function selected by the function similarity, obtains the target function finally called to process the current demand description. Therefore, through the similarity analysis of the historical call record, it is possible to refer to the historical function in similar tasks to determine the target function finally called to process the current demand description, which helps to reuse past experience according to similar tasks, avoid re-planning the tool calling strategy as much as possible, and improve the dynamic adaptability of the intelligent agent to new tools and new requirements. Therefore, by referring to the function call of historical requirements when processing new requirements, it helps to improve the learning ability and execution efficiency of the intelligent agent.
[0046] In some disclosed embodiments, the determination module 43 includes a similarity detection submodule for detecting whether there is a historical function whose function similarity is higher than a similarity threshold; the determination module 43 includes a first selection submodule for selecting a historical function whose function similarity is higher than a similarity threshold as a target function in response to a detection result of existence; the determination module 43 includes a second selection submodule for selecting a historical function with the highest function similarity as a candidate function in response to a detection result of non-existence, and adjusting parameters based on the candidate function to obtain the target function.
[0047] In some disclosed embodiments, the second selection submodule includes a first construction unit, which is used to construct a first prompt based on the current requirement description and the parameter settings of the candidate function; wherein the first prompt is used to instruct the large language model to distinguish the parameter items to be optimized in the parameter settings of the candidate function according to the current requirement description; the second selection submodule includes a first acquisition unit, which is used to input the first prompt to the large language model, and obtain the output parameters of the large language model to determine as the parameter items to be optimized in the candidate function.
[0048] In some disclosed embodiments, the determination module 43 also includes a code acquisition submodule, which is used to obtain the verification code of the target function after obtaining the target function; wherein the verification code simulates the task logic described by the current requirement; the determination module 43 also includes a test verification submodule, which is used to test whether the target function meets the task requirements based on the verification code.
[0049] In some disclosed embodiments, the code acquisition submodule includes a second construction unit, which is used to construct a second prompt based on the current requirement description and the objective function; wherein the second prompt is used to instruct the large language model to simulate the task logic to generate a verification code; the code acquisition submodule includes a second acquisition unit, which is used to input the second prompt to the large language model, and obtain the output code of the large language model as the verification code of the objective function.
[0050] In some disclosed embodiments, the function calling device 40 includes an updating module for updating the historical calling record based on the target function.
[0051] In some disclosed embodiments, the measurement module 42 includes a first measurement submodule for obtaining the semantic similarity between the current function and the historical function; the measurement module 42 includes a second measurement submodule for obtaining the parameter similarity between the current function and the historical function; the measurement module 42 includes a similarity weighting submodule for obtaining the function similarity by weighting based on the semantic similarity and the parameter similarity.
[0052] In some disclosed embodiments, the second measurement submodule includes a quantity similarity measurement unit, which is used to obtain the parameter quantity similarity between the current function and the historical function based on the total number of parameters of each of the current function and the historical function; the second measurement submodule includes a type similarity measurement unit, which is used to obtain the parameter type similarity between the current function and the historical function based on the number of parameters of the same type between the current function and the historical function; the second measurement submodule includes a parameter similarity measurement unit, which is used to obtain parameter similarity based on parameter quantity similarity and parameter type similarity; wherein the parameter similarity is positively correlated with both the parameter quantity similarity and the parameter type similarity.
[0053] See also Figure 5 , Figure 5 It is a schematic diagram of the framework of an embodiment of the intelligent dialogue device of the present application. The intelligent dialogue device 50 includes: an acquisition module 51, a calling module 52 and a reply module 53. The acquisition module 51 is used to acquire the target function that is finally called by processing the current demand description; wherein the current demand description is the user demand description currently processed by the intelligent agent, and the target function is determined based on the function calling device in the above-mentioned function calling device embodiment; the calling module 52 is used to call the target function and obtain the return result of the target function; the reply module 53 is used to process the current demand description and return the result based on the large language model, and obtain the intelligent agent reply to the current demand description.
[0054] The above scheme obtains the target function that is finally called to process the current demand description, and the current demand description is the user demand description that the intelligent agent is currently processing. The target function is determined based on the function calling device in the above function calling device embodiment, and then the target function is called to obtain the return result of the target function, and the current demand description and the return result are processed based on the large language model to obtain the intelligent agent's response to the current demand description. Therefore, through similarity analysis of historical call records, it is possible to refer to historical functions in similar tasks to determine the target function that is finally called to process the current demand description, which helps to reuse past experience based on similar tasks, avoid re-planning tool calling strategies as much as possible, and improve the dynamic adaptability of the intelligent agent to new tools and new demands. Therefore, by referring to function calls to historical demands when processing new demands, it helps to improve the learning ability and execution efficiency of the intelligent agent.
[0055] See also Figure 6 , Figure 6 : is a schematic diagram of the framework of an embodiment of an electronic device of the present application. The electronic device 60 includes at least a memory 61 and a processor 62 coupled to each other, the memory 61 at least stores program instructions, and the processor 62 is used to execute the program instructions to implement the steps in any of the above-mentioned function call method embodiments, or to implement the steps in any of the above-mentioned intelligent dialogue method embodiments. For details, please refer to the aforementioned disclosed embodiments, which will not be repeated here. As a possible example, the electronic device 60 may include but is not limited to a server, etc., and the specific type of the electronic device 60 is not limited here.
[0056] Specifically, the processor 62 is used to control itself and the memory 61 to implement the steps in any of the above-mentioned function call method embodiments, or to implement the steps in any of the above-mentioned intelligent dialogue method embodiments. The processor 62 can also be called a CPU (Central Processing Unit). The processor 62 may be an integrated circuit chip with signal processing capabilities. The processor 62 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 62 can be implemented by an integrated circuit chip.
[0057] In the above scheme, the electronic device 60 obtains the historical call record, and obtains the preset function matching the current demand description as the current function, and the current demand description is the user demand description currently processed by the intelligent agent, and the historical call record contains the historical function finally called by the intelligent agent to process the historical demand description, and then obtains the function similarity between the current function and each historical function, and obtains the target function finally called to process the current demand description based on the historical function selected by the function similarity, and obtains the target function finally called to process the current demand description, and the current demand description is the user demand description currently processed by the intelligent agent, and the target function is determined based on the steps in the above function call method embodiment, and then calls the target function to obtain the return result of the target function, and processes the current demand description and the return result based on the large language model to obtain the intelligent agent response to the current demand description, so through the similarity analysis of the historical call record, it is possible to refer to the historical function in similar tasks to determine the target function finally called to process the current demand description, which helps to reuse past experience according to similar tasks, avoid re-planning tool call strategies as much as possible, and improve the dynamic adaptability of the intelligent agent to new tools and new needs. Therefore, by referring to the function call of historical needs when processing new needs, it helps to improve the learning ability and execution efficiency of the intelligent agent.
[0058] See also Figure 7 , Figure 7 1 is a schematic diagram of a computer-readable storage medium 70 of the present application. The computer-readable storage medium 70 stores program instructions 71 that can be executed by a processor, and the program instructions 71 are used to implement the steps in any of the above-mentioned function call method embodiments, or to implement the steps in any of the above-mentioned intelligent dialogue method embodiments.
[0059] In the above scheme, the computer-readable storage medium 70 obtains the historical call record, and obtains the preset function matching the current demand description as the current function, and the current demand description is the user demand description currently processed by the intelligent agent, and the historical call record contains the historical function finally called by the intelligent agent to process the historical demand description, and then obtains the function similarity between the current function and each historical function, and obtains the target function finally called to process the current demand description based on the historical function selected by the function similarity, and obtains the target function finally called to process the current demand description, and the current demand description is the user demand description currently processed by the intelligent agent, and the target function is determined based on the steps in the above function call method embodiment, and then calls the target function to obtain the return result of the target function, and processes the current demand description and the return result based on the large language model to obtain the intelligent agent response to the current demand description, so through the similarity analysis of the historical call record, it is possible to refer to the historical function in similar tasks to determine the target function finally called to process the current demand description, which helps to reuse past experience according to similar tasks, avoid re-planning tool call strategies as much as possible, and improve the dynamic adaptability of the intelligent agent to new tools and new requirements. Therefore, by referring to the function call of historical requirements when processing new requirements, it helps to improve the learning ability and execution efficiency of the intelligent agent.
[0060] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0061] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0062] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0063] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0064] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0065] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
[0066] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among them, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.
Claims
1. A function calling method, characterized in that: include: Obtaining historical call records, and obtaining a preset function matching the current demand description as the current function; wherein the current demand description is a user demand description currently processed by the agent, and the historical call records contain the historical functions finally called by the agent when processing the historical demand description; Obtaining function similarities between the current function and each of the historical functions; Based on the historical functions selected by the function similarity, a target function finally called to process the current demand description is obtained.
2. The method according to claim 1, characterized in that: The process of obtaining the target function finally called by processing the current demand description based on the historical function selected by the function similarity comprises: Detecting whether there is a historical function whose function similarity is higher than a similarity threshold; In response to the detection result being existence, selecting a historical function whose function similarity is higher than the similarity threshold as the target function; In response to the detection result being non-existent, a historical function with the highest function similarity is selected as a candidate function, and parameters are adjusted based on the candidate function to obtain the target function.
3. The method according to claim 2, characterized in that The step of adjusting parameters based on the candidate function to obtain the target function includes: Determine the parameter items to be optimized in the candidate function based on comparing the current requirement description with the parameter settings of the candidate function; The parameter items to be optimized in the candidate function are adjusted based on the current demand description to obtain the objective function.
4. The method according to claim 3, characterized in that The comparing the current requirement description with the parameter settings of the candidate function to determine the parameter items to be optimized in the candidate function includes: Based on the current requirement description and the parameter settings of the candidate function, construct a first prompt; wherein the first prompt is used to instruct the large language model to identify the parameter items to be optimized in the parameter settings of the candidate function according to the current requirement description; The first prompt is input into the large language model, and an output parameter of the large language model is obtained and determined as a parameter item to be optimized in the candidate function.
5. The method according to claim 2 or 3, characterized in that: After obtaining the objective function, the method further includes: Obtaining the verification code of the objective function; wherein the verification code simulates the task logic described by the current requirement; Based on the verification code, test whether the objective function meets the task requirements.
6. The method according to claim 5, characterized in that The obtaining of the verification code of the target function comprises: Based on the current requirement description and the objective function, construct a second prompt; wherein the second prompt is used to instruct the large language model to simulate the task logic to generate the verification code; The second prompt is input to the large language model, and an output code of the large language model is obtained as a verification code of the objective function.
7. The method according to claim 1, characterized in that After obtaining the target function finally called for processing the current requirement description based on the historical function selected by the function similarity, the method further includes: Based on the target function, the historical call record is updated.
8. The method according to claim 1, characterized in that The obtaining of the function similarity between the current function and each of the historical functions includes: Obtaining semantic similarity between the current function and the historical function, and obtaining parameter similarity between the current function and the historical function; The function similarity is obtained by weighting based on the semantic similarity and the parameter similarity.
9. The method according to claim 8, characterized in that The obtaining of the parameter similarity between the current function and the historical function includes: Based on the total number of parameters of the current function and the historical function, obtain the similarity of the number of parameters between the current function and the historical function, and based on the number of parameters of the same type between the current function and the historical function, obtain the similarity of the parameter type between the current function and the historical function; Based on the parameter quantity similarity and the parameter type similarity, the parameter similarity is obtained; wherein the parameter similarity is positively correlated with the parameter quantity similarity and the parameter type similarity.
10. An intelligent dialogue method, characterized in that: include: Obtaining the target function finally called for processing the current demand description; wherein the current demand description is the user demand description currently processed by the agent, and the target function is determined based on the function calling method according to any one of claims 1 to 9; Calling the objective function to obtain a return result of the objective function; The current demand description and the returned result are processed based on a large language model to obtain an intelligent agent response to the current demand description.
11. A function calling device, characterized in that: include: An acquisition module is used to acquire historical call records and acquire a preset function matching the current demand description as the current function; wherein the current demand description is a user demand description currently processed by the agent, and the historical call records contain the historical functions finally called by the agent when processing the historical demand description; A measurement module, used to obtain the function similarity between the current function and each of the historical functions; A determination module is used to obtain a target function that is finally called to process the current demand description based on the historical function selected by the function similarity.
12. An intelligent dialogue device, characterized in that: include: An acquisition module, used to acquire the target function finally called by processing the current demand description; wherein the current demand description is the user demand description currently processed by the agent, and the target function is determined based on the function calling device according to claim 11; A calling module, used for calling the target function to obtain a return result of the target function; A reply module is used to process the current demand description and the returned result based on a large language model to obtain an intelligent agent reply to the current demand description.
13. An electronic device, characterized in that: It at least comprises a memory and a processor coupled to each other, wherein the memory at least stores program instructions, and the processor is used to execute the program instructions to implement the function calling method described in any one of claims 1 to 9, or to implement the intelligent dialogue method described in claim 10.
14. A computer-readable storage medium, characterized in that: Program instructions that can be executed by a processor are stored, and the program instructions are used to implement the function calling method described in any one of claims 1 to 9, or to implement the intelligent dialogue method described in claim 10.
Citation Information
Cited By
Key function call feature acquisition method, knowledge retrieval method, equipment and medium
CN120257218A
Intelligent agent management method and system for low-code design
CN121029228A
Intelligent agent management methods and systems for low-code design
CN121029228B
Intelligent agent skill generation method and electronic equipment
CN121562660A