Search

CN-122021614-A - Interface calling method and device, electronic equipment and storage medium

CN122021614ACN 122021614 ACN122021614 ACN 122021614ACN-122021614-A

Abstract

The application provides an interface calling method, an interface calling device, electronic equipment and a storage medium, wherein definition information is obtained by analyzing an interface specification document, the definition information comprises interface information, a data mode and parameter information, a map node and a map relation edge are established according to the interface information, the data mode and the parameter information, further an interface knowledge map is obtained, a target task is received, the target task is analyzed into a calling intention of a target interface based on a large language model, the target interface is used as an end point, reverse traversal is performed on the interface knowledge map to obtain an interface calling plan, and the interface calling is performed according to the interface calling plan.

Inventors

  • DENG BOWEN
  • JIANG MINGJIANG
  • YANG MINGJIN
  • LIU MING
  • CHEN JUNRUN

Assignees

  • 中冶赛迪信息技术(重庆)有限公司

Dates

Publication Date
20260512
Application Date
20260319

Claims (10)

  1. 1. An interface calling method, comprising: Analyzing the interface specification document to obtain definition information, wherein the definition information comprises interface information, data mode and parameter information; establishing a graph node and a graph relation edge according to the interface information, the data mode and the parameter information, so as to obtain an interface knowledge graph; receiving a target task, and analyzing the target task into a calling intention of a target interface based on a large language model; And performing reverse traversal on the interface knowledge graph by taking the target interface as an end point to obtain an interface calling plan, and performing interface calling according to the interface calling plan.
  2. 2. The interface calling method according to claim 1, wherein establishing a graph node and a graph relationship edge according to the interface information, the data pattern and the parameter information, and further obtaining an interface knowledge graph, comprises: creating interface nodes, mode nodes and parameter nodes based on a preset data model, the interface information, the data mode and the parameter information, wherein the map nodes comprise the interface nodes, the mode nodes and the parameter nodes; For each interface node, establishing a first relation edge between the interface node and a corresponding mode node and a second relation edge between the interface node and a corresponding parameter node; And determining parameter dependence among different interface nodes based on a preset equivalence rule and a heuristic algorithm, and establishing a core relation edge representing calling sequence and data dependence according to the parameter dependence to further obtain the interface knowledge graph, wherein the interface knowledge graph comprises the first relation edge, the second relation edge and the core relation edge.
  3. 3. The interface invocation method of claim 2, wherein determining parameter dependencies between different interface nodes based on preset equivalence rules and heuristics comprises at least one of: Determining an equivalent interface node with an equivalent relation with a target interface node based on the preset equivalent rule, and determining parameter dependence between the target interface node and the equivalent interface node; and calculating the target similarity of the target interface node and other interface nodes under the preset equivalent condition based on a heuristic algorithm, and determining the parameter dependence between the target interface node and the other interface nodes if the target similarity is larger than the preset similarity, wherein the preset equivalent condition comprises at least one of a parameter name, a data type and business semantics.
  4. 4. The interface calling method according to any one of claims 1 to 3, wherein performing reverse traversal on the interface knowledge graph with the target interface as an endpoint to obtain an interface calling plan includes: Performing reverse traversal on the interface knowledge graph by taking the target interface as an end point to obtain at least one effective path; Calculating the number of map nodes of each effective path, and determining the effective path with the minimum number of map nodes as an optimal path; And determining the interface calling plan according to the optimal path.
  5. 5. An interface call method according to any one of claims 1 to 3, characterized in that making an interface call according to the interface call plan comprises: Inquiring the interface knowledge graph to obtain a dependency relationship and a context; determining a previous interface of a current interface according to the dependency relationship, extracting a calling result of the previous interface from the context, and constructing a request parameter for the current interface; And carrying out interface calling on the current interface based on the request parameters, and updating the context according to the calling result of the current interface.
  6. 6. The interface call method of claim 5, wherein after making an interface call to the current interface based on the request parameters, the method further comprises: determining a status code from the calling result of the current interface, and determining the status code type of the status code; Determining the calling state of the calling result of the current interface according to the type of the state code; if the calling state is successful, updating the context according to the calling result of the current interface; and if the calling state is the calling failure, determining a target processing strategy according to the state code.
  7. 7. The interface invocation method of any of claims 1-3, wherein prior to parsing the interface specification document, the method further comprises: Acquiring an interface specification document, and carrying out grammar check and semantic check on the interface specification document; If the interface specification document passes the grammar check and the semantic check, analyzing the interface specification document; And if the interface specification document does not pass the grammar check and the semantic check, re-acquiring the interface specification document.
  8. 8. An interface calling device, comprising: The first analysis module is used for analyzing the interface specification document to obtain definition information, wherein the definition information comprises interface information, data mode and parameter information; The map establishing module is used for establishing map nodes and map relation edges according to the interface information, the data mode and the parameter information so as to obtain an interface knowledge map; the second analysis module is used for receiving a target task and analyzing the target task into a calling intention of a target interface based on a large language model; And the interface calling module is used for carrying out reverse traversal on the interface knowledge graph by taking the target interface as an end point to obtain an interface calling plan, and carrying out interface calling according to the interface calling plan.
  9. 9. An electronic device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the interface invocation method of any of claims 1-7 when the computer program is executed.
  10. 10. A computer readable storage medium storing a computer program, wherein the computer program when executed by a processor implements the interface invocation method of any of claims 1 to 7.

Description

Interface calling method and device, electronic equipment and storage medium Technical Field The present application relates to the field of artificial intelligence technologies, and in particular, to an interface calling method, an interface calling device, an electronic device, and a storage medium. Background With the popularity of micro-service architecture, modern applications are typically composed of a large number of independent services that interact through APIs (Application Programming Interface, application programming interfaces). The rapid increase in the number of APIs makes call dependencies between services increasingly complex, presenting significant difficulties for development, testing, and maintenance. Currently, developers rely mainly on API document tools (e.g., swagger/OpenAPI) to manage interface specifications, but these tools can only provide static, defined-level descriptions, and cannot reveal the dependency of the dynamic call chain of the API at runtime and based on actual data. The underlying logic dependencies are combed, completely dependent on manual analysis and experience of the developer, inefficient and prone to error. On the other hand, the development of large language model (Large Language Model, LLM) technology has brought new possibilities for automated operating systems via natural language instructions. Theoretically, LLM can understand the user's intent and call the corresponding API to complete the task. However, in practice, the direct application of LLM to complex micro-service environments still faces the fundamental challenge that, firstly, LLM lacks knowledge of global dependencies between APIs within the target system and cannot autonomously program the correct call sequence that satisfies the precondition constraints. Secondly, in multi-step call, the LLM has difficulty in stably and accurately transferring parameters across APIs, i.e., accurately extracting required fields from complex responses of the preamble APIs, and accurately constructing subsequent requests. Thirdly, facing comprehensive tasks, LLMs are susceptible to "illusions" that may generate invalid, inefficient, or erroneous call plans, resulting in task failure. Therefore, the related technical scheme has the obvious defects that the traditional API management tool cannot realize dynamic dependency analysis and automatic arrangement, and the general LLM has natural language understanding capability but is limited by the lack of knowledge of a specific system and the defect of execution reliability. It is apparent that a new interface calling method is needed to solve at least one of the above problems. It should be noted that the foregoing merely provides background information related to the present application and does not necessarily constitute prior art. Disclosure of Invention The application provides an interface calling method, an interface calling device, electronic equipment and a storage medium, which are used for solving the technical problem that a large language model is difficult to autonomously and reliably plan and execute multi-step and complex API calling tasks due to lack of global understanding of API dependency. Other features and advantages of the application will be apparent from the following detailed description, or may be learned by the practice of the application. The interface calling method comprises the steps of analyzing an interface specification document to obtain definition information, establishing a graph node and a graph relation edge according to the interface information, the data mode and the parameter information to obtain an interface knowledge graph, receiving a target task, analyzing the target task into a calling intention of a target interface based on a large language model, and performing reverse traversal on the interface knowledge graph by taking the target interface as an end point to obtain an interface calling plan, and performing interface calling according to the interface calling plan. In an embodiment of the present application, based on the foregoing scheme, according to the interface information, the data pattern and the parameter information, a graph node and a graph relationship edge are established, so as to obtain an interface knowledge graph, including creating an interface node, a pattern node and a parameter node based on a preset data pattern, the interface information, the data pattern and the parameter information, where the graph node includes the interface node, the pattern node and the parameter node; and determining parameter dependence among different interface nodes based on a preset equivalence rule and a heuristic algorithm, and establishing a core relationship side representing calling sequence and data dependence according to the parameter dependence to further obtain the interface knowledge graph, wherein the interface knowledge graph comprises the first relationship side, the second relationship side and the