Interface service construction method and device based on multiple Agents, equipment and medium

By automatically parsing business requirements and generating high-precision script code through multi-agent collaboration technology, the problem of slow construction speed of backend interface services of low-code platforms is solved, adapting to the rapid iteration of digital needs in the industry and significantly reducing development threshold and labor costs.

CN120803417APending Publication Date: 2025-10-17QINGDAO HISENSE TRANS TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510695919.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

Low-code development platforms are slow and inefficient in building backend interface services. Traditional requirement parsing cannot dynamically capture unstructured requirements, resulting in a high requirement deviation rate and a large workload for secondary development of projects.

Method used

Employing multi-agent collaboration technology, the system extracts business requirements through a demand-connecting agent, generates task flowcharts, calls SQL-based agents and script-based agents, automatically parses business requirements, and generates high-precision script code. It also supports syntax conversion and exception handling for multiple database types.

Benefits of technology

It enables the rapid and accurate construction of interface services, reduces the technical threshold and human resource costs for enterprise digital transformation, and improves system reusability and business response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803417A_ABST
    Figure CN120803417A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, in particular to an interface service construction method and device based on multiple Agents, equipment and a medium. The method comprises the following steps: receiving a construction request of an interface service, and calling a demand docking Agent to extract a service demand in the construction request to obtain a demand document; the demand document comprises business logic, a data source table and a field mapping relation; the task planning Agent is called to generate a task flow chart according to the business logic and the field mapping relation, and the task flow chart is sent to the SQL writing Agent and the script writing Agent; calling an SQL compiling Agent to generate an SQL statement corresponding to the interface service according to the data source table and the field mapping relation; constructing a syntax tree corresponding to the SQL statement according to the SQL statement and the task flow chart; and calling a script writing Agent to perform script writing according to the SQL statement, the syntax tree corresponding to the SQL statement and the task flow chart to obtain an interface script corresponding to the interface service.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, and in particular to a multi-Agent-based interface service construction method and device, equipment and medium. BACKGROUND

[0002] In recent years, low-code development platforms have become the core tool for enterprise digital transformation, and the core goal is to reduce the development threshold through visual configuration and code generation technology. However, the current development efficiency is limited, and the mainstream platform requires developers to manually configure data models and interface logic, and auxiliary code still needs to be written for complex business scenarios; traditional requirement analysis relies on fixed templates or rule libraries, and cannot dynamically capture unstructured requirements, resulting in a high requirement deviation rate.

[0003] Although the low-code field can quickly and efficiently build front-end pages through drag-and-drop, in the construction of background interface services, only simple query logic can be generated through rules at present, and most interface logic can only be completed by technical personnel through hard coding to achieve business implementation. And after the development of the business product is completed, with the changes in the business market, the workload of secondary development of the project is huge, and a large amount of manpower needs to be invested to modify the business system. This makes the speed of constructing background interface services slow and the efficiency low. SUMMARY

[0004] The embodiments of the present application provide a multi-Agent-based interface service construction method, device, equipment and medium to solve the problem of slow speed and low efficiency of constructing background interface services.

[0005] In a first aspect, the present application provides a multi-Agent-based interface service construction method, which comprises:

[0006] receiving a construction request of an interface service, calling a requirement docking Agent to extract business requirements in the construction request, and obtaining a requirement document; the requirement document includes business logic, a data source table and a field mapping relationship;

[0007] calling a task planning Agent to generate a task flowchart according to the business logic and the field mapping relationship, and sending the task flowchart to a SQL writing Agent and a script writing Agent;

[0008] calling the SQL writing Agent to generate a SQL statement corresponding to the interface service according to the data source table and the field mapping relationship; and constructing a syntax tree corresponding to the SQL statement according to the SQL statement and the task flowchart;

[0009] The script writing agent is invoked to perform script writing according to the SQL statement, the syntax tree corresponding to the SQL statement, and the task flowchart, to obtain an interface script corresponding to the interface service.

[0010] In a possible implementation, after the interface script corresponding to the interface service is obtained, the method further includes:

[0011] A replacement request of a database is received, a target database in the replacement request and a target database type of the target database are determined;

[0012] A data source management agent is invoked to convert the syntax tree into a target syntax tree corresponding to the target database type;

[0013] The script writing agent is invoked to perform script writing according to the target syntax tree and the task flowchart, to obtain an updated interface script corresponding to the interface service.

[0014] In a possible implementation, the conversion of the syntax tree into the target syntax tree corresponding to the target database type includes:

[0015] Based on the syntax tree, data information of an initial database type corresponding to the syntax tree is obtained;

[0016] Based on a preset corresponding relationship between data information of the initial database type and data information of the target database type, and the data information of the initial database type, data information of the target database type is determined;

[0017] The data information in the syntax tree is replaced with the data information of the target database type, to obtain a target syntax tree corresponding to the target database type.

[0018] In a possible implementation, the conversion of the syntax tree into the target syntax tree corresponding to the target database type includes:

[0019] The syntax tree and the target database type are input into a pre-trained LLM large model, to obtain a target syntax tree corresponding to the target database type; the pre-trained LLM large model is trained based on multiple database types and a syntax tree corresponding to each database type.

[0020] In a possible implementation, the script writing according to the target syntax tree and the task flowchart, to obtain the updated interface script corresponding to the interface service, includes:

[0021] A SQL statement is reconstructed according to the target syntax tree, to generate a target SQL statement corresponding to the target syntax tree.

[0022] According to the target SQL statement, the target syntax tree and the task flowchart, script writing is performed to obtain an interface script corresponding to the interface service.

[0023] In a possible implementation, the method further includes:

[0024] If an SQL statement exception occurs when the interface script is run, the SQL writing Agent is invoked to perform exception checking on the SQL statement in the interface script according to a syntax tree corresponding to the SQL statement and to correct the SQL statement according to a correction result, to obtain a corrected SQL statement.

[0025] In a possible implementation, the method further includes:

[0026] After the interface script corresponding to the interface service is obtained, a hash fingerprint is generated based on a blockchain to obtain an association relationship between the interface script and the hash fingerprint.

[0027] According to the association relationship between the interface script and the hash fingerprint, the interface script is traced.

[0028] In a second aspect, the application provides an interface service construction device based on multiple Agents, the device including:

[0029] A demand generation module is configured to receive a construction request of an interface service, invoke a demand docking Agent to extract a business demand in the construction request, and obtain a demand document; the demand document includes a business logic, a data source table and a field mapping relationship.

[0030] A planning module is configured to invoke a task planning Agent to generate a task flowchart according to the business logic and the field mapping relationship, and send the task flowchart to a SQL writing Agent and a script writing Agent.

[0031] A SQL writing module is configured to invoke the SQL writing Agent to generate an SQL statement corresponding to the interface service according to the data source table and the field mapping relationship, and construct a syntax tree corresponding to the SQL statement according to the SQL statement and the task flowchart.

[0032] A script writing module is configured to invoke the script writing Agent to perform script writing according to the SQL statement, the syntax tree corresponding to the SQL statement and the task flowchart, to obtain an interface script corresponding to the interface service.

[0033] In a third aspect, the present application also provides an electronic device, comprising a processor configured to implement the steps of the method for constructing a multi-Agent-based interface service according to any one of the preceding aspects when executing a computer program stored in a memory.

[0034] In a fourth aspect, the present application also provides a computer-readable storage medium storing a computer program configured to implement the steps of the method for constructing a multi-Agent-based interface service according to any one of the preceding aspects when executed by a processor.

[0035] In a fifth aspect, the present application provides a computer program product comprising a computer program configured to implement the method for constructing a multi-Agent-based interface service according to the first aspect when executed by a processor.

[0036] The embodiments of the present application provide at least the following beneficial effects:

[0037] In the embodiments of the present application, the construction request of the interface service is received, the business requirement in the construction request is extracted by calling the requirement connection Agent, and a requirement document is obtained; the requirement document includes business logic, a data source table, and a field mapping relationship; a task flowchart is generated according to the business logic and the field mapping relationship by calling the task planning Agent, and the task flowchart is sent to the SQL writing Agent and the script writing Agent; the SQL writing Agent generates a SQL statement corresponding to the interface service according to the data source table and the field mapping relationship; and a syntax tree corresponding to the SQL statement is constructed according to the SQL statement and the task flowchart; the script writing Agent writes a script according to the SQL statement, the syntax tree corresponding to the SQL statement, and the task flowchart, and obtains an interface script corresponding to the interface service.

[0038] Therefore, by using the large model and the multi-Agent dynamic dialogue completion and modular template matching mechanism, the business requirement can be automatically analyzed and high-precision script code can be generated, so that the interface service can be quickly and accurately constructed, and the digitalization requirements of rapid iteration of the industry can be adapted; the technical threshold and the labor cost of digital transformation of an enterprise are significantly reduced, and the system reusability and the business response speed are greatly improved.

[0039] Other features and advantages of the present application will be set forth in the following description, and in part will become apparent to those skilled in the art from the description, or can be learned by practice of the present application. The objects and other advantages of the present application will be realized and attained by means of the instrumentalities particularly pointed out in the written description and claims hereof, as well as the appended drawings. BRIEF DESCRIPTION OF DRAWINGS

[0040] In order to more clearly illustrate the technical solutions of the present application, the drawings needed to be used in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description only represent some embodiments of the present application.

[0041] Figure 1 A structural framework of a multi-agent based interface service construction method provided by the embodiments of the present application;

[0042] Figure 2 A flowchart of a multi-agent based interface service construction method provided by the embodiments of the present application;

[0043] Figure 3 A flowchart of updating an interface script provided by the embodiments of the present application;

[0044] Figure 4 A flowchart of syntax tree conversion provided by the embodiments of the present application;

[0045] Figure 5 A flowchart of script writing provided by the embodiments of the present application;

[0046] Figure 6 A flowchart of interface service version tracing provided by the embodiments of the present application;

[0047] Figure 7 A whole schematic diagram of a multi-agent based interface service construction method provided by the embodiments of the present application;

[0048] Figure 8 A structural schematic diagram of a multi-agent based interface service construction device provided by the embodiments of the present application;

[0049] Figure 9 A structural schematic diagram of an electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION

[0050] In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings. Obviously, the described embodiments only represent some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.

[0051] It should be noted that the terms "comprising" and "having" and their conjugations, as used in the specification and claims of this application, are intended to encompass the inclusion of one or more steps or units, but not exclude the inclusion of other steps or units. It should be noted that the terms "comprising" and "having" and their conjugations, as used in the specification and claims of this application, are intended to encompass the inclusion of one or more steps or units, but not exclude the inclusion of other steps or units.

[0052] The terms "first", "second", etc. are used only for the purpose of description and are not to be interpreted in a relative manner, nor to imply a relative importance or to implicitly indicate the number of the technical features indicated. Therefore, the features defined with "first", "second", etc. can explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, the meaning of "a plurality of" is two or more, unless otherwise specified.

[0053] The word "exemplary" is used herein to mean "serving as an example, instance, or illustration." Any implementation described as "exemplary" is not necessarily to be construed as preferred or advantageous over other implementations.

[0054] In recent years, low-code development platforms have become the core tool for enterprise digital transformation, and the core goal is to reduce the development threshold through visual configuration and code generation technology. However, the current development efficiency is limited, and the mainstream platform needs developers to manually configure data models and interface logic, and auxiliary code needs to be written for complex business scenarios; traditional requirement analysis relies on fixed templates or rule libraries, and cannot dynamically capture unstructured requirements, resulting in a high requirement deviation rate.

[0055] Although the low-code field can quickly and efficiently build front-end pages through drag-and-drop, in the construction of background interface services, only simple query logic can be generated through rules at present, and most interface logic can only be completed by technical personnel through hard coding to achieve business implementation. And after the development of the business product is completed, with the changes of the business market, the workload of secondary development of the project is huge, and a large amount of manpower needs to be invested to reform the business system. This makes the speed of constructing background interface services slow and the efficiency low.

[0056] Therefore, the present application provides a multi-Agent-based interface service construction method, device, equipment and medium, to solve the problem of slow speed and low efficiency of background interface service construction.

[0057] The inventive concept of the embodiments of the present application can be summarized as follows: a construction request of an interface service is received, a demand docking agent is called to extract business demands in the construction request, and a demand document is obtained; the demand document includes business logic, a data source table, and a field mapping relationship; a task planning agent is called to generate a task flowchart according to the business logic and the field mapping relationship, and the task flowchart is sent to a SQL writing agent and a script writing agent; the SQL writing agent is called to generate a SQL statement corresponding to the interface service according to the data source table and the field mapping relationship; and a syntax tree corresponding to the SQL statement is constructed according to the SQL statement and the task flowchart; the script writing agent is called to write a script according to the SQL statement, the syntax tree corresponding to the SQL statement, and the task flowchart, and an interface script corresponding to the interface service is obtained. Through the large model and the multi-agent dynamic dialogue completion and modular template matching mechanism, the business demand can be automatically analyzed and high-precision script code can be generated, so that the interface service can be quickly and accurately constructed to adapt to the digital needs of rapid iteration of the industry.

[0058] The multi-agent-based interface service construction method provided in the present application is applied to an electronic device, which can be a PC, a mobile terminal, a server, or the like. The multi-agent-based interface service construction method provided in the present application can be applied to a distributed software platform represented by a blockchain.

[0059] After introducing the main inventive idea of the embodiments of the present application, the main inventive idea of the embodiments of the present application will be described in detail. Figure 1 The structure framework of the multi-agent-based interface service construction method provided in the present application will be described.

[0060] The present application relies on advanced multi-agent collaboration technology and is committed to achieving full-process operation from user demand to automatic generation and debugging of interface services, especially for enterprise-level low-code background development scenarios. In the traditional development mode, from sorting out business demands to completing interface deployment, the developer needs to have deep technical foundation and go through multiple complex and time-consuming links. The multi-agent-based interface service construction method provided in the present application greatly simplifies this process. The user only needs to clearly state the business demand in natural language, and the powerful function architecture can automatically complete a series of key tasks such as data source docking, SQL logic generation, script compilation, and interface deployment, significantly reducing the threshold of development work, so that more non-professional developers can also participate in enterprise-level background development.

[0061] As shown in Figure 1 The multi-agent-based interface service construction method provided in the present application is applied to the following multiple agent (proxy) components and running containers:

[0062] Requirement Docking Agent: This component is built on the intent recognition framework of LLM (Large Language Model) and incorporates a context follow-up mechanism. In actual operation, it can accurately analyze the user's natural language requirements and obtain a structured requirement document. Through in-depth analysis of user descriptions, key business entities such as goods, orders, and users are extracted; interface parameters such as order numbers and user IDs are identified; and data source requirements such as MySQL or MongoDB databases are determined. This intelligent parsing method provides an accurate and critical information base for subsequent development processes.

[0063] Task Planning Agent: This component has multi-round self-correction capability, which can generate a task flowchart (DAG, Directed Acyclic Graph) based on the structured requirement document extracted by the Requirement Docking Agent. During the generation of the task flowchart, the logical integrity is strictly checked. For example, in a business requirement involving multiple sub-task processes, it ensures the correct sequence between sub-tasks, reasonable data transmission logic, and avoids logical loopholes or conflicts, thus ensuring the smooth progress of the entire business process.

[0064] SQL Writing Agent: The SQL generator based on AST (Abstract Syntax Tree) is its core technology. It can support multiple database dialects such as MySQL, Oracle, and PostgreSQL. During work, the Agent will generate optimized SQL statements based on data table structures. For example, when faced with a complex data table association query requirement, it can automatically generate efficient SQL statements based on table relationships and query conditions, improving data query efficiency and accuracy, and can also generate a syntax tree corresponding to the SQL statement.

[0065] Script Writing Agent: The code generation engine based on Domain Specific Language (DSL) is its key. It focuses on generating RESTful API service code, quickly generates code frameworks that meet RESTful specifications based on business logic and business requirements for building interface services, including route settings, request processing functions, etc., to obtain script code, reducing the workload of developers in writing basic code.

[0066] Data source management Agent: with the ability to dynamically connect databases / APIs, the permissions will be verified during the connection process to ensure that only users or programs with corresponding permissions can access the data source. The corresponding data source is provided for the demand docking Agent, and the script writing Agent also calls the data of the data source management Agent. At the same time, the table structure is checked to ensure the correct reading and writing of data. In addition, the adapter supports JDBC / GraphQL / OpenAPI protocols, which can flexibly adapt to different types of data sources to meet the diversified data access needs of enterprises.

[0067] Running container: deploy the interface script corresponding to the running interface service, and debug the generated interface service, support the lightweight sandbox environment of Docker, and support hot updates.

[0068] To further illustrate the technical solutions provided by the embodiments of the present application, the following will be described in detail in conjunction with the drawings and specific embodiments. Although the embodiments of the present application provide the method operation steps as described in the following embodiments or drawings, more or fewer operation steps can be included in the method based on conventional or non-creative labor. The execution order of these steps is not limited to the execution order provided by the embodiments of the present application in the logical sense.

[0069] Referring to Figure 2 , a flowchart of a method for constructing an interface service based on multiple agents is provided, which can be executed as Figure 2 as shown in the following steps:

[0070] In step S201, the construction request of the interface service is received, and the demand docking Agent extracts the business demand in the construction request to obtain a demand document; the demand document includes business logic, data source table, and field mapping relationship.

[0071] In specific implementation, the demand docking Agent extracts the business demand from the construction request of the interface service input by the user through natural language interaction, for example, "get the list of users with age greater than 30", and associates the data source table structure, such as the age field of the users table, to generate a structured demand document containing business logic, data source table, and field mapping relationship.

[0072] In addition to natural language interaction, the present application also supports voice command recognition to generate a structured demand document. A voice recognition engine or a graphical interface component library can be integrated, and users can generate a construction request including business demand through voice description or field dragging. In this way, the user threshold can be reduced, different operation habits can be adapted, and the flexibility of human-computer interaction can be improved.

[0073] In step S202, the task planning agent generates a task flowchart according to the business logic and the field mapping relationship, and sends the task flowchart to the SQL writing agent and the script writing agent.

[0074] In implementation, in a business requirement involving multiple sub-task flows, the task planning agent generates a task flowchart according to the sequence of each sub-task and the mapping relationship between the fields corresponding to each sub-task, and sends the task flowchart to the SQL writing agent and the script writing agent.

[0075] In step S203, the SQL writing agent generates an SQL statement corresponding to the interface service according to the data source table and the field mapping relationship, and constructs a syntax tree corresponding to the SQL statement according to the SQL statement and the task flowchart.

[0076] In implementation, after obtaining the data source table and the field mapping relationship, the SQL writing agent can generate an SQL statement corresponding to the interface service according to the SQL statement generation specification, for example, the data source table is the users table, the field is the age field, and the SQL statement SELECT * FROM users WHERE age>30 can be generated according to the mapping relationship. Then, the syntax unit is split, and a syntax tree corresponding to the SQL statement is constructed according to the syntax unit and the task flowchart.

[0077] For example, a syntax tree corresponding to the SQL statement SELECT * FROM users WHERE age>30 is constructed. First, the SQL statement SELECT * FROM users WHERE age>30 is split into syntax units such as a table node (users) and a condition node (age>30), and then a syntax tree with a root node of a SELECT operation and a child node containing a table name (users), a field, and a filtering condition (age>30) is generated.

[0078] Thus, the semantic structured expression of the SQL statement can be realized, which is convenient for subsequent syntax conversion.

[0079] In step S204, the script writing agent performs script writing according to the SQL statement, the syntax tree corresponding to the SQL statement, and the task flowchart, and obtains an interface script corresponding to the interface service.

[0080] In a specific implementation, the script writing agent has a code generation engine based on a domain-specific language (DSL), which can generate Python / Node.js interface scripts conforming to the RESTful specification according to the SQL statements and the syntax trees corresponding to the SQL statements, and according to the business processes in the task flowchart, for example, REST API encapsulated as / getUsers.

[0081] Finally, the interface script corresponding to the interface service is loaded in the running container to provide an API debugging environment, and the interface service is obtained after debugging.

[0082] In this way, automatic conversion between AST and executable script code can be implemented.

[0083] Further, the script writing agent can be designed as a pluggable architecture to support flexible replacement of templates of multiple programming languages such as Python, Node.js, and Go. Third-party templates such as a GraphQL encapsulator can be obtained by customizing templates or through a plug-in market, which can break the limitation of the technology stack, meet the integration needs of heterogeneous systems, and improve interface reusability.

[0084] In a possible implementation, after the business product is developed, the same business may need to be developed with different databases as the business market changes, and therefore the same project needs to be developed again, which is a huge workload. Therefore, to avoid this situation, after the interface script corresponding to the interface service is obtained, the steps shown in Figure 3 may be performed.

[0085] In step S301, a database replacement request is received, and a target database in the replacement request and a target database type of the target database are determined.

[0086] In a specific implementation, in response to a user triggering a database replacement operation, a database replacement request is sent. The replacement request includes a target database of the interface service and a target database type of the target database. Specifically, the user can trigger the database replacement operation by inputting the target database type of the target database to determine the database replacement request, or trigger the database replacement operation by selecting the target database type from multiple database types to determine the database replacement request.

[0087] For example, if the initial database is MySQL, when the user inputs the target database as Oracle, the database replacement request is determined, and then according to the database replacement request, the target database that needs to be replaced is determined as Oracle.

[0088] In step S302, the data source management Agent is invoked to convert the syntax tree into a target syntax tree corresponding to the target database type.

[0089] In one possible implementation, converting the syntax tree into a target syntax tree corresponding to the target database type can be specifically implemented as shown in the steps of Figure 4

[0090] In step S401, based on the syntax tree, data information of an initial database type corresponding to the syntax tree is obtained.

[0091] In step S402, based on a preset correspondence between the data information of the initial database type and data information of the target database type, and the data information of the initial database type, the data information of the target database type is determined.

[0092] The data information includes, but is not limited to, functions and syntax structures.

[0093] In specific implementation, the preset correspondence between the data information of the initial database type and the data information of the target database type is pre-stored in the dialect rule library. After receiving the database replacement request, the target database in the replacement request and the target database type of the target database are determined, and then the data information of the target database type can be obtained according to the correspondence pre-stored in the dialect rule library.

[0094] For example, the initial database type corresponding to the syntax tree is a MySQL database, and the corresponding data information includes a function IFNULL(), a syntax structure LIMIT clause, etc. The dialect rule library includes a correspondence LIMIT→ROWNUM, and the syntax structure of the Oracle database can be determined as ROWNUM according to the syntax structure LIMIT clause of the MySQL database and the correspondence. The dialect rule library can also include a correspondence IFNULL()→COALESCE(), and the function of the Oracle database can be determined as COALESCE() according to the function IFNULL() of the MySQL database and the correspondence.

[0095] In step S403, the data information in the syntax tree is replaced with the data information of the target database type, to obtain a target syntax tree corresponding to the target database type.

[0096] In specific implementation, the function in the syntax tree is replaced with the function of the target database type, and the syntax structure in the syntax tree is replaced with the syntax structure of the target database type, to obtain a target syntax tree corresponding to the target database type.

[0097] ​For example, the function IFNULL() in the syntax tree of the MySQL database is replaced by the function COALESCE() of the Oracle database, and the syntax structure LIMIT clause in the syntax tree of the MySQL database is replaced by the syntax structure ROWNUM of the Oracle database, so that the syntax tree corresponding to the MySQL database is replaced by the target syntax tree corresponding to the Oracle database.

[0098] In another possible implementation, after converting the syntax tree into the target syntax tree corresponding to the target database type, the following steps are further performed:

[0099] The syntax tree and the target database type are input into the pre-trained LLM large model to obtain the target syntax tree corresponding to the target database type.

[0100] The pre-trained LLM large model is trained based on multiple database types and the syntax tree corresponding to each database type.

[0101] In specific implementation, the LLM model is introduced to replace the static rule library, and the large model is trained according to different SQL syntaxes to adapt to different databases.

[0102] Therefore, the limitation of the traditional rule library can be broken through, and the automatic recognition and conversion of the syntax differences between multiple databases such as MySQL, Oracle, ClickHouse, etc. can be realized, and the semantic analysis accuracy of complex nested queries can be improved.

[0103] In step S303, the script writing Agent writes scripts according to the target syntax tree and the task flowchart to obtain the interface script corresponding to the updated interface service.

[0104] In one possible implementation, after converting the syntax tree into the target syntax tree corresponding to the target database type, the following steps are further performed: Figure 5 as shown in the steps:

[0105] In step S501, the SQL statement is reconstructed according to the target syntax tree to generate the target SQL statement corresponding to the target syntax tree.

[0106] In step S502, scripts are written according to the target SQL statement, the target syntax tree, and the task flowchart to obtain the interface script corresponding to the updated interface service.

[0107] In specific implementation, the script writing Agent reconstructs the converted target syntax tree into an executable target SQL statement, and generates a new Python / Node.js interface script, such as a REST API encapsulated as / getUsers. Then the container loads the script and provides an API debugging environment.

[0108] In a possible implementation, the application also includes an exception handling and self-healing mechanism. The following two exceptions can occur:

[0109] SQL syntax error: if an SQL statement exception occurs when running the interface script, the SQL writing agent is called to perform exception checking on the SQL statement in the interface script according to the syntax tree corresponding to the SQL statement, and to correct the SQL statement according to the checking result to obtain a corrected SQL statement. Then, the script writing agent is called to perform script writing according to the corrected SQL statement, the syntax tree corresponding to the SQL statement, and the task flowchart to obtain a corrected interface script.

[0110] For example, if a WHERE condition is missing when running the interface script, the SQL writing agent is called to complete the missing WHERE condition according to the syntax tree corresponding to the SQL statement, thereby generating a corrected SQL statement.

[0111] Data source connection failure: if a data source connection failure occurs when running the interface script, the standby connection pool is dynamically switched and the user is notified.

[0112] In this way, the high availability of the interface service generation process can be ensured

[0113] In a possible implementation, the application captures the return result of the database in the running container, performs data format standardization such as timestamp conversion, and supports interface rollback through version snapshot to ensure that the application obtains compatible data output.

[0114] In a possible implementation, after obtaining the interface script corresponding to the interface service, the application can also perform the operations shown in Figure 6 .

[0115] In step S601, a hash fingerprint is generated based on a blockchain to obtain an association relationship between the interface script and the hash fingerprint.

[0116] In step S602, the interface script is traced according to the association relationship between the interface script and the hash fingerprint.

[0117] In this way, the blockchain technology is used to realize tamper-proof storage of interface version snapshots. Each time an interface is iterated, a hash fingerprint is generated and chained to support version tracing and distributed consistency verification, and the rollback mechanism is automatically triggered in combination with a smart contract. The version audit security is enhanced, and the method is suitable for high-compliance scenarios such as finance and government affairs.

[0118] For ease of understanding, the following describes the overall flow of the interface service construction method provided by the embodiments of the application with reference to Figure 7 The overall flow of the interface service construction method provided by the embodiments of the application is described.

[0119] Firstly, in the requirement input layer, after receiving the construction request of the interface service, the intention of the requirement docking Agent is parsed, the business requirement in the construction request is extracted, and a structured requirement document is obtained.

[0120] In the logic construction layer, the task planning Agent is first called to generate a task flowchart according to the business logic and the field mapping relationship, and the task flowchart is sent to the SQL writing Agent and the script writing Agent. Then three sub-tasks are started:

[0121] In the first sub-task, the SQL writing Agent is called to generate the SQL statement corresponding to the interface service according to the data source table and the field mapping relationship; the syntax tree corresponding to the SQL statement is constructed according to the SQL statement and the task flowchart; and the syntax units are split to obtain table nodes, condition nodes and other syntax units.

[0122] In the second sub-task, the AST is converted into a target AST corresponding to the target database type.

[0123] In the third sub-task, the script writing Agent is called to write a script to obtain the interface script corresponding to the interface service.

[0124] Among them, the above three sub-tasks are executed in parallel. However, the input of the second sub-task is the output of the first sub-task, and the input of the third sub-task is the output of the first sub-task or the output of the first sub-task and the output of the second sub-task.

[0125] In the adaptation execution layer, the data source management Agent is called to identify the database type, and then the interface script is deployed and run in the running container. Finally, in the output management layer, the data format is standardized and the version snapshot is managed, and the interface service construction is completed.

[0126] If an exception occurs when running the interface script in the running container, the exception handling layer is used for exception handling. For data source exceptions, the standby data source is switched; for SQL syntax errors, the AST node is backtracked and corrected.

[0127] Therefore, through the large model and the multi-Agent dynamic dialogue completion and modular template matching mechanism, the business requirement can be automatically parsed and high-precision script code can be generated, so that the interface service can be quickly and accurately constructed to adapt to the digital demand of rapid iteration of the industry; the technical threshold and labor cost of enterprise digital transformation are significantly reduced, and the system reusability and business response speed are greatly improved.

[0128] Based on the same inventive concept, the embodiment of the present application also provides an interface service construction device based on a multi-Agent, Figure 8A structure diagram of an interface service construction device based on a multi-agent is provided for an embodiment of the present application, and the device comprises:

[0129] A requirement generation module 801 is configured to receive a construction request of an interface service, call a requirement docking agent to extract a business requirement in the construction request, and obtain a requirement document; the requirement document comprises a business logic, a data source table, and a field mapping relationship;

[0130] A planning module 802 is configured to call a task planning agent to generate a task flowchart according to the business logic and the field mapping relationship, and send the task flowchart to a SQL writing agent and a script writing agent;

[0131] A SQL writing module 803 is configured to call the SQL writing agent to generate a SQL statement corresponding to the interface service according to the data source table and the field mapping relationship, and construct a syntax tree corresponding to the SQL statement according to the SQL statement and the task flowchart;

[0132] A script writing module 804 is configured to call the script writing agent to perform script writing according to the SQL statement, the syntax tree corresponding to the SQL statement, and the task flowchart, and obtain an interface script corresponding to the interface service.

[0133] In a possible implementation, the device further comprises:

[0134] A replacement module 805 is configured to receive a replacement request of a database, determine a target database in the replacement request and a target database type of the target database, call a data source management agent, and convert the syntax tree into a target syntax tree corresponding to the target database type;

[0135] The script writing module 804 is further configured to call the script writing agent to perform script writing according to the target syntax tree and the task flowchart, and obtain an updated interface script corresponding to the interface service.

[0136] In a possible implementation, the replacement module 805 is specifically configured to:

[0137] obtain data information of an initial database type corresponding to the syntax tree based on the syntax tree;

[0138] determine data information of the target database type based on a preset corresponding relationship between the data information of the initial database type and the data information of the target database type, and the data information of the initial database type;

[0139] Replace the data information in the syntax tree with data information of the target database type to obtain a target syntax tree corresponding to the target database type.

[0140] In a possible implementation, the replacement module 805 is specifically configured to:

[0141] input the syntax tree and the target database type into a pre-trained LLM large model to obtain a target syntax tree corresponding to the target database type; the pre-trained LLM large model is trained based on multiple database types and the syntax tree corresponding to each database type.

[0142] In a possible implementation, the script writing module 804 is specifically configured to:

[0143] reconstruct an SQL statement according to the target syntax tree to generate a target SQL statement corresponding to the target syntax tree;

[0144] write a script according to the target SQL statement, the target syntax tree, and the task flowchart to obtain an updated interface script corresponding to the interface service.

[0145] In a possible implementation, the apparatus further includes an exception processing module 806 configured to:

[0146] if an SQL statement exception occurs when the interface script is run, call the SQL writing Agent to perform exception checking on the SQL statement in the interface script according to the syntax tree corresponding to the SQL statement and correct the SQL statement according to a checking result to obtain a corrected SQL statement.

[0147] In a possible implementation, the apparatus further includes a traceability module 807 configured to:

[0148] after obtaining the interface script corresponding to the interface service, generate a hash fingerprint based on a blockchain to obtain an association between the interface script and the hash fingerprint;

[0149] trace the interface script according to the association between the interface script and the hash fingerprint.

[0150] Based on the same inventive concept, the embodiments of the present application also provide an electronic device, Figure 9 A structural schematic diagram of an electronic device provided by the embodiments of the present application is shown in Figure 9 As shown in the figure, the electronic device includes a processor 901, a communication interface 902, a memory 903, and a communication bus 904, wherein the processor 901, the communication interface 902, and the memory 903 complete communication with each other through the communication bus 904.

[0151] The computer program stored in the memory 903, when executed by the processor 901, causes the processor 901 to perform the steps of any of the multi-agent based interface service construction method provided by the embodiments of the present application.

[0152] Since the above electronic device solves the problem similar to the multi-agent based interface service construction method, the implementation of the above electronic device can refer to the implementation of the method, and the repeated parts will not be described again.

[0153] The communication bus mentioned in the above electronic device can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 1302 is used for communication between the above electronic device and other devices. The memory can include a random access memory (RAM) and can also include a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory can also be at least one storage device located away from the aforementioned processor.

[0154] The above processor can be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; can also be a digital signal processing (DSP) processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.

[0155] On the basis of the above embodiments, the embodiments of the present application further provide a computer readable storage medium, and the computer readable storage medium stores a computer program executable by a processor. When the program is run on the processor, the processor performs the steps of any of the multi-agent based interface service construction method provided by the embodiments of the present application.

[0156] Based on the same inventive concept, the embodiments of the present application provide a computer program product, including a computer program, which, when executed by a processor, implements the steps of any of the multi-agent based interface service construction method provided by the embodiments of the present application.

[0157] Since the principle of solving the problem by the above computer readable storage medium is similar to the method of constructing the interface service based on multi-agent, the implementation of the above computer readable storage medium can refer to the embodiment of the method, and the repeated parts will not be described.

[0158] Those skilled in the art will appreciate that embodiments of the application can be supplied as a method, a system, or a computer program product. Therefore, the application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage, etc.) containing computer usable program code.

[0159] The application is described with reference to flowcharts and / or block diagrams of the method, device (system), and computer program product according to the application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce a device that implements the flow Figure 1 The function specified in one flow or multiple flows and / or blocks. Figure 1 The function specified in one flow or multiple flows and / or blocks.

[0160] These computer program instructions can also be stored in a computer readable memory that can direct the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including instruction devices that implement the flow Figure 1 The function specified in one flow or multiple flows and / or blocks. Figure 1 The function specified in one flow or multiple flows and / or blocks.

[0161] These computer program instructions can also be loaded into a computer or other programmable data processing apparatus, so that a series of operation steps are performed on the computer or other programmable data processing apparatus to produce a computer implemented process, so that the instructions executed on the computer or other programmable data processing apparatus provide a process for implementing the flow Figure 1 The function specified in one flow or multiple flows and / or blocks. Figure 1 The function specified in one flow or multiple flows and / or blocks.

[0162] Obviously, many modifications and variations of the present application are possible in light of the above teachings. It is, therefore, to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.

Claims

1. A method for constructing an interface service based on multi-agent, characterized in that: The method comprises: Receive a construction request for the interface service, call the demand docking agent to extract the business requirements in the construction request, and obtain a demand document; the demand document includes business logic, data source table, and field mapping relationship; Calling the task planning agent to generate a task flow chart according to the business logic and the field mapping relationship, and sending the task flow chart to the SQL writing agent and the script writing agent; Calling the SQL writing agent to generate an SQL statement corresponding to the interface service according to the data source table and the field mapping relationship; and constructing a syntax tree corresponding to the SQL statement according to the SQL statement and the task flow chart; The script writing agent is called to write a script according to the SQL statement, the syntax tree corresponding to the SQL statement, and the task flow chart to obtain an interface script corresponding to the interface service.

2. The method according to claim 1, characterized in that After obtaining the interface script corresponding to the interface service, the method further includes: receiving a database replacement request, and determining a target database in the replacement request and a target database type of the target database; Invoke the data source management agent to convert the syntax tree into a target syntax tree corresponding to the target database type; The script writing agent is called to write a script according to the target syntax tree and the task flow chart to obtain an updated interface script corresponding to the interface service.

3. The method according to claim 2, characterized in that The converting the syntax tree into a target syntax tree corresponding to the target database type includes: Based on the syntax tree, obtaining data information of an initial database type corresponding to the syntax tree; Determining the data information of the target database type based on a preset correspondence between the data information of the initial database type and the data information of the target database type, and the data information of the initial database type; The data information in the syntax tree is replaced with the data information of the target database type to obtain a target syntax tree corresponding to the target database type.

4. The method according to claim 2, characterized in that The converting the syntax tree into a target syntax tree corresponding to the target database type includes: The syntax tree and the target database type are input into a pre-trained LLM large model to obtain a target syntax tree corresponding to the target database type; the pre-trained LLM large model is trained based on multiple database types and the syntax trees corresponding to each database type.

5. The method according to claim 2, characterized in that The scripting is performed according to the target syntax tree and the task flow chart to obtain an updated interface script corresponding to the interface service, including: Reconstructing the SQL statement according to the target syntax tree to generate a target SQL statement corresponding to the target syntax tree; Script writing is performed according to the target SQL statement, the target syntax tree and the task flow chart to obtain an updated interface script corresponding to the interface service.

6. The method according to claim 1, characterized in that The method further comprises: If an SQL statement exception occurs when running the interface script, the SQL writing agent is called to perform an exception check on the SQL statement in the interface script according to the syntax tree corresponding to the SQL statement and correct it according to the check result to obtain a corrected SQL statement.

7. The method according to claim 1, characterized in that The method further comprises: After obtaining the interface script corresponding to the interface service, a hash fingerprint is generated based on the blockchain to obtain an association between the interface script and the hash fingerprint; The interface script is traced according to the association relationship between the interface script and the hash fingerprint.

8. A device for constructing an interface service based on multiple agents, characterized in that: The device comprises: The demand generation module is used to receive the construction request of the interface service, call the demand docking agent to extract the business requirements in the construction request, and obtain the demand document; the demand document includes business logic, data source table and field mapping relationship; A planning module is used to call the task planning agent to generate a task flow chart according to the business logic and the field mapping relationship, and send the task flow chart to the SQL writing agent and the script writing agent; An SQL writing module is configured to call the SQL writing agent to generate an SQL statement corresponding to the interface service according to the data source table and the field mapping relationship; and to construct a syntax tree corresponding to the SQL statement according to the SQL statement and the task flow chart; The script writing module is used to call the script writing agent to write a script according to the SQL statement, the syntax tree corresponding to the SQL statement and the task flow chart to obtain the interface script corresponding to the interface service.

9. An electronic device, characterized in that: The electronic device includes a processor, and the processor is configured to implement the steps of the multi-agent-based interface service construction method according to any one of claims 1 to 7 when executing a computer program stored in a memory.

10. A computer-readable storage medium, characterized in that It stores a computer program, which, when executed by a processor, implements the steps of the multi-agent-based interface service construction method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Asynchronous stream data export implementation method, device and equipment based on low memory

    CN121301466A