Code generation method based on multiple agents and storage medium
By employing a multi-agent collaborative generation method, combined with a code knowledge base and target prompts, the problem of a single model struggling to accommodate the differentiated specifications of modules is solved. This achieves efficient and reliable code generation, with a high degree of matching between the generated code and the requirements, reducing human intervention.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-08
- Publication Date
- 2026-04-10
AI Technical Summary
Existing code generation methods based on a single large language model struggle to accommodate the differentiated specifications and constraints of different modules in complex business systems. This results in fragmented code generation modules, inconsistent quality, and difficulties in integration, requiring extensive manual intervention and thus limiting practicality and reliability.
A multi-agent code generation method is adopted, including a table design agent, a front-end code generation agent, and a back-end code generation agent. Through collaboration, system code is generated. By combining a code knowledge base and target prompts, business requirements are accurately matched, modular division of labor and collaboration are achieved, and complete system code with high matching and low defects is generated.
It significantly improves code generation efficiency, generates code with a high degree of matching with requirements, reduces manual intervention, ensures code integrity and deployability, and solves the problems of module fragmentation and integration difficulties.
Smart Images

Figure CN121832909A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of information processing, and in particular to a code generation method based on multiple agents and a storage medium. BACKGROUND
[0002] Under the wave of intelligent software development, software system development requirements are increasingly complex and diverse, business iteration speed is accelerated, and higher requirements are put forward for automatic and high-quality code generation capabilities.
[0003] In related technologies, a code generation method based on a single large language model directly inputs a business design document containing functional requirements into the model to generate complete code, which has limitations in multi-task understanding and field adaptation. When facing system requirements covering data structures, interface interaction and business logic, the model cannot take into account the differentiated specifications and constraints of different modules, often resulting in problems such as redundant table structures, mismatched front-end and back-end interfaces, etc.; and lacking professional division and result integration links, the generated code is poor in overall performance and low in maintainability, requiring a large amount of manual intervention to repair cross-module conflicts, which restricts the practicality and reliability in large target systems. SUMMARY
[0004] The present application provides a code generation method based on multiple agents and a storage medium to solve the problem of module fragmentation, quality inconsistency and integration difficulty in code generation of complex business systems in related technologies.
[0005] According to an aspect of the present application, a code generation method based on multiple agents is provided, comprising:
[0006] In response to a design request of a target system, a business design document corresponding to the design request is obtained, and a multiple-agent code generation system corresponding to the business design document is determined, wherein the business design document includes description information of functional requirements of the target system, the multiple-agent code generation system includes multiple code generation agents, and the multiple-agent code generation system includes at least two of a table design agent, a front-end code generation agent, a back-end code generation agent and a code integration agent.
[0007] The business design document and a target prompt word are provided to the multiple-agent code generation system to obtain generated code of the target system, wherein the target prompt word prompts the multiple-agent code generation system to output content consistent with the target prompt word.
[0008] According to another aspect of the present application, a code generation method based on multiple agents is provided, comprising:
[0009] An acquisition module is configured to, in response to a design request of a target system, acquire a service design document corresponding to the design request and determine a multi-agent code generation system corresponding to the service design document, wherein the service design document comprises description information of functional requirements of the target system, and the multi-agent code generation system comprises a plurality of code generation agents, and the code generation agents comprise at least two of a table design agent, a front-end code generation agent, a back-end code generation agent and a code integration agent;
[0010] A code generation module is configured to provide the service design document and a target prompt word to the multi-agent code generation system to obtain generated code of the target system, wherein the target prompt word prompts the multi-agent code generation system to output content conforming to the target prompt word.
[0011] According to another aspect of the present application, an electronic device is provided, which comprises:
[0012] at least one processor; and
[0013] a memory connected to the at least one processor in communication; wherein
[0014] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the multi-agent based code generation method according to any one of the embodiments of the present application.
[0015] According to another aspect of the present application, a computer readable storage medium is provided, which stores computer instructions for enabling a processor to execute the multi-agent based code generation method according to any one of the embodiments of the present application when executed by the processor.
[0016] The technical scheme of the embodiment of the present application is that, in response to a design request of a target system, a business design document corresponding to the design request is acquired, and a multi-agent code generation system corresponding to the business design document is determined, wherein the business design document comprises description information of functional requirements of the target system, the multi-agent code generation system comprises a plurality of code generation agents, the multi-agent code generation system comprises at least two of a table design agent, a front-end code generation agent, a back-end code generation agent and a code integration agent, the business requirement is accurately matched with the model division, the knowledge base data is reused, and the data preparation cost is reduced; the business design document and a target prompt word are provided to the multi-agent code generation system, and generated code of the target system is obtained, wherein the target prompt word prompts the multi-agent code generation system to output content conforming to the target prompt word, clearly generates a direction, constrains the output content, improves the code and requirement matching degree, solves the problems of module fragmentation, inconsistent quality and integration difficulty in code generation of a complex business system in the related art, realizes requirement-driven agent division and cooperation, accurately guides the generation of a high-matching, low-defect and deployable complete system code by fusing a business document and a prompt word, and the efficiency of code generation is significantly improved.
[0017] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0019] Figure 1 is a flowchart of a multi-agent-based code generation method according to an embodiment of the present application;
[0020] Figure 2 is a flowchart of a multi-agent-based code generation method according to an embodiment of the present application;
[0021] Figure 3 is a structural schematic diagram of a multi-agent-based code generation device according to an embodiment of the present application;
[0022] Figure 4 is a structural schematic diagram of an electronic device for implementing a multi-agent-based code generation method according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to make the person skilled in the art better understand the technical scheme of the present application, the technical scheme in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should belong to the scope of protection of the present application.
[0024] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0025] It should be noted that the modification of "one" or "multiple" mentioned in the present disclosure is illustrative but not restrictive, and those skilled in the art should understand that unless otherwise explicitly indicated in the context, it should be understood as "one or more".
[0026] The names of the messages or information exchanged between the plurality of devices in the embodiments of the present disclosure are only for illustrative purposes, and are not intended to limit the scope of the messages or information.
[0027] It can be understood that before using the technical solutions disclosed in the embodiments of the present disclosure, the type, scope of use, use scenario, etc. of the personal information involved in the present disclosure should be informed to the user and the authorization of the user should be obtained in accordance with relevant laws and regulations.
[0028] For example, in response to receiving the user's active request, the user is sent a prompt message to explicitly prompt the user that the operation requested to be performed will require the acquisition and use of the user's personal information. Thus, the user can voluntarily choose whether to provide personal information to the electronic device, application program, server or storage medium, etc. software or hardware that performs the operation of the technical solutions of the present disclosure.
[0029] As an optional but non-limiting implementation manner, in response to receiving the active request of the user, the manner of sending the prompt information to the user may be, for example, a pop-up window manner in which the prompt information may be presented in a text manner. In addition, the pop-up window may also carry a selection control for the user to select “agree” or “disagree” to provide the personal information to the electronic device.
[0030] It can be understood that the above notification and user authorization obtaining process is only illustrative and does not limit the implementation manners of the present disclosure, and other manners meeting relevant laws and regulations can also be applied to the implementation manners of the present disclosure.
[0031] It can be understood that the data (including but not limited to the data itself, the acquisition or use of the data) involved in the technical solution should comply with the requirements of relevant laws and regulations and related provisions.
[0032] Embodiment one
[0033] Figure 1 A flowchart of a code generation method based on multiple agents is provided for the first embodiment of the present application. The present embodiment can be applied to the case of quickly and high-quality generating a full-stack system business design driven software development. The method can be executed by a code generation device based on multiple agents. The code generation device based on multiple agents can be realized in the form of hardware and / or software. Optionally, the code generation device based on multiple agents is realized by an electronic device, which can be a mobile terminal, a PC terminal or a server, etc.
[0034] As shown in Figure 1 , the method specifically can include:
[0035] S110, in response to a design request of a target system, acquiring a business design document corresponding to the design request and determining a multiple-agent code generation system corresponding to the business design document, wherein the business design document includes description information of functional requirements of the target system, the multiple-agent code generation system includes a plurality of code generation agents, and the multiple-agent code generation system includes at least two of a table design agent, a front-end code generation agent, a back-end code generation agent and a code integration agent.
[0036] The target system can be understood as a specific software system or application system that the user wants to build through the design request, which is the core object of this code generation task. It is the final output of the multi-agent code generation system and its function is to meet the functional requirements defined in the business design document (such as user management, data query, process approval, etc.) to provide specific digital service capabilities for users or business scenarios. For example, the target system can be an e-commerce order management system or an enterprise OA system. The design request can be understood as the initial requirement input that triggers the target system design process, which can be initiated by the user (such as a product manager or developer) to express the intention to build a system with specific functions. As the starting point of the entire process, the design request drives subsequent operations such as obtaining the business design document and matching the multi-agent system to ensure that the code generation process is based on the user's real needs. The business design document can be understood as a structured document corresponding to the target system design request. Its core content is a specification document that describes the functional requirements, functional modules, user interactions, and data flow of the target system. It serves as a "requirement blueprint" for multi-agent code generation, providing clear semantic constraints and guidance for code generation agents to ensure that the generated code is consistent with the business goal and avoids deviating from the actual requirements. The multi-agent code generation system can be understood as a system composed of multiple code generation agents that work together. Each agent is responsible for a specific type of code generation task (such as database table structure, front-end interface, back-end logic, etc.) and collaborates to complete the complete code output of the target system. Through the modular division of labor of each agent in the multi-agent code generation system, the efficiency and professionalism of code generation are improved. Different agents focus on their own fields (such as table design, front-end and back-end development) to avoid the limitations of a single model handling complex tasks. The collaboration mechanism ensures that the various parts of the code (such as front-end calling back-end interfaces and back-end operating database tables) are compatible and unified, ultimately outputting the target system code that can be directly deployed. The table design agent can be understood as an agent responsible for generating the definition code (such as the SQL CREATE TABLE statement) of the database table structure based on the functional requirements (such as user management, data query, process approval, etc.) in the business design document. It plays the role of a "design engineer" with professional capabilities, solves the problem of structured data storage, ensures that the table structure (field type, primary key, foreign key, index, etc.) meets the business requirements (such as "the order table needs to be associated with the user ID"), and provides a reliable data storage foundation for the back-end code to avoid data redundancy or inefficient queries caused by unreasonable table design.The front-end code generation agent can be understood as an agent for generating front-end interface code (such as component code using React, Vue, etc.) according to the interface interaction requirements in the business design document (such as "the user login page needs to include an account input box and a password input box"), playing the role of a professional "front-end engineer", realizing the visual interaction between the user and the system, converting business requirements into user-operable interfaces (such as forms, lists, buttons, etc.), and ensuring that the interface logic (such as input validation, page jump, etc.) meets the design requirements. The back-end code generation agent can be understood as an agent for generating back-end service code (such as API interface, business logic processing class, database operation layer code) according to the logic rules in the business design document, processing the core business logic of the system (such as data calculation, permission verification, third-party service call), playing the role of a professional "back-end engineer", and providing services for the front-end or other systems through API, which is the intermediate hub connecting data storage (table design) and user interaction (front-end), ensuring the correct execution of business processes. The code integration agent can be understood as an agent for integrating scattered code fragments (such as SQL files, front-end components, back-end APIs) generated by table design, front-end, back-end, etc. into complete, compilable / runnable target system code (such as complete project directory structure, dependency configuration, startup script), solving the "fragmentation" problem of multi-agent code, ensuring that each part of the code (such as the API path called by the front-end and the actual exposed path of the back-end, the table name operated by the back-end and the table name generated by the table design agent) works together, and outputs complete system code that can be deployed without additional manual splicing.
[0037] S120, providing the business design document and the target prompt to the multi-agent code generation system to obtain the generated code of the target system, wherein the target prompt prompts the multi-agent code generation system to output content consistent with the target prompt.
[0038] The target prompt can be understood as a guiding instruction provided to the multi-agent code generation system, which is used to specify specific requirements or constraints of code generation, guide the multi-agent system to output content (such as technology stack selection, code style, additional functions) consistent with user preferences, avoid generating code inconsistent with expectations (such as incorrect selection of database type or omission of necessary functions), and improve the controllability and usability of the generated results. The prompt can be constructed through scene context, business-related knowledge, user demand description, output format requirement, and model prompt.
[0039] The technical scheme of the embodiment of the present application, in response to the design request of the target system, acquires the business design document corresponding to the design request, and determines the multi-agent code generation system corresponding to the business design document, wherein the business design document includes description information of the functional requirements of the target system, the multi-agent code generation system includes a plurality of code generation agents, the multi-agent code generation system includes at least two of table design agent, front-end code generation agent and back-end code generation agent and code integration agent, accurately matching business requirements and model division, reusing knowledge base data, reducing data preparation cost; the business design document and the target prompt word are provided to the multi-agent code generation system, and the generated code of the target system is obtained, wherein the target prompt word prompts the multi-agent code generation system to output the content conforming to the target prompt word, clearly generates the direction, constrains the output content, improves the matching degree of code and demand, solves the problems of module fragmentation, quality difference and integration difficulty in the related art of complex business system code generation, realizes the demand-driven agent division and cooperation, accurately guides the fusion of business documents and prompt words, generates a complete system code with high matching, low defects and deployability, and significantly improves the efficiency of code generation.
[0040] Embodiment two
[0041] Figure 2A flowchart of a code generation method based on multiple agents provided for the second embodiment of the application, this embodiment is based on the above embodiments, and provides the business design document and the target prompt word to the multi-agent code generation system to obtain the further refinement of the generated code of the target system. Optionally, the code generation agent is associated with a code knowledge base, and the code knowledge base stores engineering framework code and business logic code. The business design document is provided to the multi-agent code generation system to obtain the generated code of the target system, including: providing the business design document and the first prompt word to the table design agent to enable the table design agent to generate target database code according to the business design document, the first prompt word, and the code knowledge base associated with the table design agent; providing the target database code, the business design document, and the third prompt word to the backend code generation agent to enable the backend code generation agent to generate backend engineering code according to the target database code, the business design document, the third prompt word, and the code knowledge base associated with the backend code generation agent; providing the business design document, the target database code, and the fourth prompt word to the front-end code generation agent to enable the front-end code generation agent to generate front-end engineering code according to the business design document, the target database code, the fourth prompt word, and the code knowledge base associated with the front-end code generation agent; and providing the target database code, the backend engineering code, the front-end engineering code, and the fifth prompt word to the code integration agent to enable the code integration agent to generate the generated code of the target system according to the target database code, the backend engineering code, the front-end engineering code, the fifth prompt word, and the code knowledge base associated with the code integration agent. The specific implementation can be referred to the description of this embodiment. Wherein, the same or similar technical features as the foregoing embodiments are not described herein.
[0042] As shown in Figure 2 , the method can specifically include:
[0043] S210, in response to a design request of a target system, obtaining a business design document corresponding to the design request, and determining a multi-agent code generation system corresponding to the business design document, wherein the business design document includes description information of functional requirements of the target system, the multi-agent code generation system includes a plurality of code generation agents, the multi-agent code generation system includes at least two of a table design agent, a front-end code generation agent, a backend code generation agent, and a code integration agent, and the code generation agent is associated with a code knowledge base, and the code knowledge base stores engineering framework code and business logic code.
[0044] The code knowledge base can be understood as a structured code asset library associated with the code generation agent, serving as an associated database of the code generation agent to provide the agent with domain experience reuse capability. The code knowledge base stores, but is not limited to, engineering framework code and business logic code. For example, the code knowledge base can include design knowledge base, framework knowledge base, backend component API, frontend component API, platform knowledge base, and extension knowledge base, business knowledge base, and project knowledge base. The engineering framework code can be understood as a general basic software architecture code stored in the code knowledge base, which is a "skeleton" supporting the operation of the target system (such as the Vue CLI scaffolding of the front end, the Spring Initializr initial project of the back end, the Flyway migration framework of the database, etc.), providing a standardized engineering structure template for the code generation agent, ensuring that the generated code (such as the front-end component and the back-end interface) can be quickly embedded into a standardized engineering system, reducing the complexity of system deployment and maintenance. The business logic code can be understood as an implementation code of a specific business scenario stored in the code knowledge base (such as "user registration email verification logic", "order payment inventory update logic", "permission role menu filtering logic", etc.). The code generation agent reuses the verified business processing logic, avoids rederivation of simple / general business rules, ensures that the generated business logic code conforms to industry best practices, and reduces the risk of BUG.
[0045] S220, providing the table design agent with the business design document and the first prompt word, so that the table design agent generates target database code according to the business design document, the first prompt word, and the code knowledge base associated with the table design agent.
[0046] The first prompt word can be understood as a guiding instruction provided to the table design agent, which is used to specify the specific requirements and constraints of table design, constrain the generation logic of the table design agent, and align with the personalized needs of the user (such as database type, index strategy, naming specification), to avoid conflicts between the generated table structure and the user's expectations. The target database code can be understood as a database table structure definition code (such as SQL table creation statement, index creation statement, foreign key association statement, etc.) output by the table design agent, which serves as the input dependency of subsequent agents and provides the backend code generation agent with "object definition of data operation" (such as the backend needs to know that the primary key of the user table is user_id to write query logic), ensuring the consistency of data storage and business logic. The target database code contains the context information of the business design document.
[0047] On the basis of the above scheme, optionally, the table design agent comprises a library table generation unit, and the table design agent is provided with the business design document and the first prompt word, so that the table design agent generates target database code according to the business design document, the first prompt word and a code knowledge base associated with the table design agent, which comprises: providing the first prompt word and the business design document to the library table generation unit, so that the library table generation unit determines a table structure design document according to the first prompt word and the business design document, and determines target database code from the code knowledge base associated with the table design agent according to the table structure design document.
[0048] The library table generation unit can be understood as a sub-function module inside the table design agent, is a core execution unit for realizing the conversion from the business requirement to the table structure code, is used for receiving the first prompt word and the business design document, abstracts the logical design of the table structure (the table structure design document) first, and then generates specific database code in combination with the code knowledge base. The table structure design document can be understood as a structured logical design document abstracted by the library table generation unit according to the first prompt word and the business design document, is an “intermediate bridge” between the business requirement (the business design document) and the technical implementation (the database code), and converts the abstract business requirement into the definite table structure logic.
[0049] By using the technical scheme, the business design document and the first prompt word are converted into the structured table structure design document by the library table generation unit, and then the target database code is generated in combination with the code knowledge base, so that the accurate mapping from the requirement to the table structure can be realized, the consistency and the standardization of the database design are improved, the manual modeling omissions are reduced, the best storage scheme is automatically matched, the code reuse and the maintainability are enhanced, the design and implementation costs are significantly reduced, and the generation efficiency and the quality are improved.
[0050] On the basis of the above scheme, optionally, the table design agent comprises a library table generation unit, and the table design agent is provided with the business design document and the first prompt word, so that the table design agent generates target database code according to the business design document, the first prompt word and a code knowledge base associated with the table design agent, which comprises: providing the first prompt word and the business design document to the library table generation unit, so that the library table generation unit determines a table structure design document according to the first prompt word and the business design document, and determines target database code from the code knowledge base associated with the table design agent according to the table structure design document.
[0051] The initial database code can be understood as a preliminary database code generated by the table structure design document and the code knowledge base, which is a "coded preliminary draft" of the table structure design document, directly maps the logical design of the table structure, and is an intermediate product of code generation. The abstract logic of the table structure design document is checked. The syntax check can be understood as a syntax correctness check (such as SQL keyword spelling, bracket matching, data type legality, statement terminator, etc.) of the initial database code, which ensures that the initial database code conforms to the syntax specification (such as the difference between MySQL and PostgreSQL) of the database engine, avoids errors caused by syntax errors (such as table creation statement error), and is the basic guarantee of the "compilability" of the target database code. The inter-code logic check can be understood as a consistency check of the inter-table relationship and constraint logic in the initial database code. For example, check if the foreign key refers to an existing table and field, if the index matches the query requirement, and if the logical deletion field, ensure the logical rationality of the database code, avoid data storage or query anomalies caused by logical contradictions, and is the core guarantee of the "business adaptability" of the target database code.
[0052] By generating initial database code and then checking syntax and logic, the technical scheme can effectively capture and correct potential errors, ensure that the code is legal and the inter-table relationship is reasonable, and improve the accuracy and stability of the target database code.
[0053] S230, providing the target database code, the business design document and the third prompt word to the back-end code generation agent, so that the back-end code generation agent generates back-end engineering code according to the target database code, the business design document, the third prompt word and the code knowledge base associated with the back-end code generation agent.
[0054] The third prompt word can be understood as a guiding instruction provided to the back-end code generation agent, which is used to specify the technical constraints of back-end development (such as "use Spring Boot 3.x version", "API needs to comply with RESTful specification", "need to integrate Swagger to generate interface document", etc.), guide the back-end code generation agent to output content that meets the technical selection, and avoid generating code that is incompatible with existing technology stack. The back-end engineering code can be understood as the complete code of the back-end service output by the back-end code generation agent (such as Controller layer interface, Service layer business logic, Mapper layer database operation, etc.), which is responsible for processing the core business logic of the system (such as user authentication, order calculation, permission check), and providing data services for the front end through the API interface, which is the key hub connecting the "data storage layer" (target database code) and "user interaction layer" (front-end engineering code).
[0055] On the basis of the above scheme, optionally, the back-end code generation agent comprises a first function splitting unit and a first code generation unit, the target database code, the business design document and the third prompt word are provided to the back-end code generation agent, so that the back-end code generation agent generates back-end engineering code according to the target database code, the business design document, the third prompt word and the code knowledge base associated with the back-end code generation agent, comprising: providing the business design document to the first function splitting unit, so that the first function splitting unit splits the business design document into a plurality of function micro-service modules according to the functions of the business design document; providing the target database code, the micro-service module and the third prompt word to the first code generation unit, so that the first code generation unit generates initial back-end code according to the target database code, the micro-service module, the third prompt word and the code knowledge base associated with the back-end code generation agent, and determines the back-end engineering code according to the initial back-end code.
[0056] The first function splitting unit can be understood as a sub-unit inside the back-end code generation agent, responsible for receiving the business design document, splitting the document into a plurality of independent micro-service modules (such as user service, order service, payment service, etc.) according to the function description, and is a "requirement decomposer" of back-end code generation, which decomposes complex business requirements into loosely coupled micro-service modules, ensures that each module focuses on a single business function, and improves the maintainability and scalability of the back-end system (such as upgrading the payment service without affecting the user service). The micro-service module can be understood as an independent function module split by the first function splitting unit according to the function description of the business design document, each module focuses on a single business domain, and is a "functional boundary unit" of the back-end engineering, which improves the flexibility of the system through loose coupling design (such as order service failure does not affect user service), and reduces the complexity of inter-function dependency. The first code generation unit can be understood as a sub-unit inside the back-end code generation agent, responsible for receiving the target database code, the micro-service module and the third prompt word, generating the initial back-end code in combination with the associated code knowledge base, and finally determining the back-end engineering code. The initial back-end code can be understood as a preliminary back-end code (raw code without final verification or optimization, without API interface configuration, etc.) generated by the first code generation unit according to the target database code, the micro-service module, the third prompt word and the code knowledge base, which is a "coded preliminary draft" of the micro-service module, and provides an object to be arranged for subsequent determination of the final back-end engineering code.
[0057] According to the technical solution, the business design document is split into micro-service modules, and the initial backend code is generated in combination with the target database code and the third prompt word, so that a modular architecture with clear function boundaries and single responsibility can be realized, and the maintainability and scalability of the system are improved; the mature logic is reused by using the code knowledge base, the repeated development is reduced, and the consistency is ensured; the backend engineering code is automatically generated and optimized, the amount of manual coding and the error rate are reduced, the code, data and demand are highly matched, and the delivery speed of the high-quality backend system is significantly accelerated.
[0058] On the basis of the above scheme, optionally, the backend engineering code is determined according to the initial backend code, including: determining the interface code between the plurality of micro-service modules according to the initial backend code, the micro-service modules and the code knowledge base associated with the agent, and determining the backend engineering code according to the initial backend code and the interface code.
[0059] The interface code can be understood as the interaction code between the micro-service modules generated according to the initial backend code, the micro-service modules and the code knowledge base, and is used to define the calling rules (such as interface address, request method, parameter format, return value structure, authentication method, etc.) between the modules, and is the “cooperation bridge” of the micro-service modules, which solves the communication problem between the modules in the distributed system. The problem can be the interaction protocol (such as HTTP method, URL path) of the calling party and the called party, and the definition of the data transmission format (such as JSON parameter, response structure).
[0060] According to the technical solution, the interface code between the micro-service modules is generated, and the initial backend code is integrated, so that the module cooperation rules can be determined, the calling conflict can be avoided, the system loose coupling and scalability can be improved, the workload of manually defining the interface can be reduced, the consistency and maintainability of the backend engineering can be ensured, and the interface and the business logic can be matched.
[0061] S240, the business design document, the target database code and the fourth prompt word are provided to the front-end code generation agent, so that the front-end code generation agent generates front-end engineering code according to the business design document, the target database code, the fourth prompt word and the code knowledge base associated with the front-end code generation agent.
[0062] The fourth prompt word can be understood as a guiding instruction provided to the front-end code generation agent, which is used to clarify the requirements and constraints of front-end development, constrain the generation direction of the front-end code generation agent, and ensure that the interface meets the user experience and design specifications. The front-end engineering code can be understood as the complete code of the front-end interface output by the front-end code generation agent, which is the implementation carrier of the "user interaction layer" of the target system, converts business requirements into user-visible and operable interfaces (such as login pages and order list pages), and obtains data through API calls to backend services to realize the interactive closed loop of "user input to system feedback".
[0063] On the basis of the above scheme, optionally, the front-end code generation agent includes a function component determination unit and a second code generation unit, and the target database code, the back-end engineering code, the front-end engineering code and the fifth prompt word are provided to the code integration agent, so that the code integration agent generates the generation code of the target system according to the target database code, the back-end engineering code, the front-end engineering code, the fifth prompt word and the code knowledge base associated with the code integration agent, including; the business design document is provided to the function component determination unit, so that the function component determination unit splits the business design document into multiple function components according to the functions of the business design document; the function component, the target database code and the fourth prompt word are provided to the second code generation unit, so that the second code generation unit determines the initial front-end code according to the target database code, the function component, the fourth prompt word and the code knowledge base associated with the front-end code generation agent, and determines the front-end engineering code according to the initial front-end code and the fourth prompt word.
[0064] The function component determination unit can be understood as a subunit inside the front-end code generation agent, responsible for receiving a business design document, splitting the document into multiple independent function components (such as a login component, an order list component, and a payment popup component) according to the function description, and being a "requirement decomposer" of the front-end code generation, which decomposes complex business interaction requirements into function components that can be independently developed and reused, ensuring that each component focuses on a single interaction scenario. The function component can be understood as an independent front-end interaction unit split by the function component determination unit according to the function description of the business design document, each component focusing on a single interaction scenario, and being an "interaction boundary unit" of the front-end engineering. The second code generation unit can be understood as a subunit inside the front-end code generation agent, responsible for receiving function components, target database code, and fourth prompt words, generating initial front-end code in combination with an associated code knowledge base, and determining the final front-end engineering code according to the initial front-end code and the fourth prompt words, being an execution unit of the front-end code generation, generating initial code that meets technical constraints, and completing the determination of the final front-end engineering code. The initial front-end code can be understood as a preliminary front-end code generated by the second code generation unit according to the function components, the target database code, the fourth prompt words, and the code knowledge base, containing the internal implementation logic and data request logic of each function component, being an "interaction module prototype" of the front-end engineering, and only completing the internal interaction implementation of a single function component, but lacking global optimization.
[0065] By adopting the technical solution, the business interaction requirements can be accurately converted into high-cohesion components through function component splitting and data and prompt word driven code generation, ensuring that the front-end logic is consistent with the data structure and technical requirements; mature interfaces and interaction logic are reused by using the code knowledge base, reducing repeated development and improving interface standardization and consistency; the front-end engineering code is automatically output and optimized, reducing manual coding and debugging, enhancing component reusability and maintainability, and significantly improving front-end development efficiency and user experience matching degree.
[0066] On the basis of the above-mentioned solution, optionally, the determination of the front-end engineering code according to the initial front-end code and the fourth prompt words comprises: determining interface code between the multiple function components from a code knowledge base associated with the front-end code generation agent according to the initial front-end code and the function components, generating a configuration file according to the fourth prompt words, and determining the front-end engineering code according to the initial front-end code, the interface code, and the configuration file.
[0067] The interface code can be understood as an interaction code between functional components generated according to the initial front-end code, the functional components and the code knowledge base, and is used to define the calling rules between components and is a "cooperation bridge" of the functional components, and solves the interaction problem between components in the front-end engineering. The configuration file can be understood as a global running configuration code of the front-end engineering generated according to the fourth prompt word, and is used to define the running rules of the front-end system (such as route configuration, state management initialization, network request encapsulation, environment variable, build optimization rule, etc.).
[0068] By generating the interface code between the functional components, generating the configuration file according to the prompt word and integrating the initial front-end code, the component cooperation and the global running rules can be determined, the interaction conflicts can be avoided, the front-end modularity and maintainability can be improved, the interface logic and data, environment requirements can be matched, the manual configuration and debugging can be reduced, the code standardization and reusability can be enhanced, and the front-end engineering integrity and running stability can be improved.
[0069] S250, providing the target database code, the back-end engineering code, the front-end engineering code and a fifth prompt word to the code integration agent, so that the code integration agent generates the generated code of the target system according to the target database code, the back-end engineering code, the front-end engineering code, the fifth prompt word and the code knowledge base associated with the code integration agent.
[0070] The fifth prompt word can be understood as a guiding instruction provided to the code integration agent, which is used to determine the integration requirements and guide the code integration agent to output a complete code package meeting the deployment requirements, so as to avoid problems such as "missing dependencies", "version inconsistency", "path error", "fuzzy deployment steps" and the like in the integrated code, and ensure that the target system can be quickly put into operation.
[0071] Based on the above scheme, optionally, the target database code, the backend engineering code, the front-end engineering code and the fifth prompt word are provided to the code integration agent, so that the code integration agent generates the generated code of the target system according to the target database code, the backend engineering code, the front-end engineering code, the fifth prompt word and the code knowledge base associated with the code integration agent, comprising: providing the target database code, the backend engineering code, the front-end engineering code and the fifth prompt word to the code integration agent, so that the code integration agent verifies the data format of the target database code, the backend engineering code and the front-end engineering code, and determines the target database verification code, the backend engineering verification code and the front-end engineering verification code according to the verification result respectively; determining the configuration environment rule according to the fifth prompt word, and configuring the target database verification code, the backend engineering verification code and the front-end engineering verification code according to the configuration environment rule and the code knowledge base associated with the code integration agent, to obtain the target database configuration code, the backend engineering configuration code and the front-end engineering configuration code; generating executable deployment scripts of the target database configuration code, the backend engineering configuration code and the front-end engineering configuration code according to the configuration environment rule of the fifth prompt word and the code knowledge base associated with the code integration agent, and determining the generated code of the target system according to the executable deployment scripts, the target database configuration code, the backend engineering configuration code and the front-end engineering configuration code.
[0072] The data format verification can be understood as the format and structure correctness check of the target database code, backend engineering code, and frontend engineering code by the code integration agent, including but not limited to code syntax (such as SQL keyword spelling, Java annotation format), file structure (such as whether the src / main / java directory of the backend engineering exists), coding specification (such as whether the naming of the frontend component conforms to the camel case), to ensure the basic readability and syntax legality of the module code. The verification includes but is not limited to at least one of code verification (checking code syntax, logic errors (such as dead loop, null pointer risk)), interface compatibility verification (checking the consistency of the interfaces between modules (such as whether the API path called by the frontend is consistent with the actual exposed path of the backend, and whether the parameter types match)), and version verification (such as whether the Spring Boot 3.x used by the backend is compatible with the Vue3 used by the frontend, and whether the database MySQL 8.0 supports the JSON field type of the backend). The target database verification code, backend engineering verification code, and frontend engineering verification code can be understood as the qualified database code, backend code, and frontend code confirmed after data format verification. The verified code, as a trusted input, ensures that subsequent configuration (such as generating database configuration code) and deployment (such as executing table creation script) will not fail due to code problems (such as table creation interruption due to SQL syntax error), and ensures that subsequent configuration (such as generating backend service port, database connection pool configuration) and deployment (such as starting the backend service) will not fail due to code problems (such as 404 error caused by interface path error), and ensures that subsequent configuration (such as generating frontend routing proxy, API base address) and deployment (such as packaging frontend resources) will not fail due to code problems (such as backend parsing failure caused by request parameter type error). The configuration environment rule can be understood as the specific configuration requirements of the target deployment environment determined according to the fifth prompt word (such as enabling HTTPS in the production environment, the database address is prod-db.example.com, the backend service port is 8080; disabling SSL in the test environment, the database address is test-db.example.com, the backend port is 8081), which is the "environment constraint" of each module configuration, ensuring that the generated configuration code adapts to the target environment (such as the database address of the production environment is different from that of the test environment), avoiding environment adaptation problems caused by "one set of configuration for the world" (such as connecting the production database by mistake in the test environment). The target database configuration code, backend engineering configuration code, and frontend engineering configuration code can be understood as the database module configuration code, backend module configuration code, and frontend module configuration code generated according to the configuration environment rule and code knowledge base.The configured code ensures that the database module runs correctly in the target environment (e.g., setting the correct character set to avoid Chinese character encoding issues, configuring a suitable storage engine to improve performance) and is compatible with the data operation logic of the backend code (e.g., matching the database connection pool size with the backend concurrency). It also ensures that the backend module provides stable service in the target environment (e.g., adjusting the database connection pool size to handle high concurrency, configuring the API gateway to route and forward frontend requests) and is compatible with the calling logic of the frontend code (e.g., setting the correct API base address to avoid cross-domain issues). Furthermore, it ensures that the frontend module interacts efficiently in the target environment (e.g., setting the correct API base address to avoid cross-domain issues, configuring CDN to accelerate static resource loading) and is compatible with the interface definition of the backend code (e.g., carrying the correct Content-Type in the request header). The executable deployment script can be understood as an automated deployment script generated based on the configuration environment rules and code knowledge base (e.g., Shell scripts (starting the database, backend, and frontend services), Docker Compose files (defining multi-container orchestration), Kubernetes YAML files (defining Pods, Services, Ingresses), etc.), which can be directly executed to complete the deployment of the target system.
[0073] By adopting this technical solution, the code integration agent verifies the data format and compatibility of each module, configures according to environment rules, and generates executable deployment scripts. This eliminates cross-module conflicts and ensures reliable collaboration between database, backend, and frontend code. It automatically generates environment adaptation configuration and deployment schemes, significantly reducing manual integration and deployment costs, improving system stability and portability, and achieving one-stop high-quality delivery from code to a runnable system.
[0074] The technical solution of this invention involves each code generation agent relying on the engineering framework code and business logic code stored in the associated code knowledge base to generate domain code under the guidance of business design documents and corresponding prompts: the table design agent produces a database structure that fits the requirements, the backend agent generates logic layer code by combining the database and business rules, the frontend agent generates interaction layer code based on business and data, and the code integration agent coordinates the three and integrates them into the environment configuration and deployment scripts. The reuse of framework and logic code avoids redundant development and maintains consistency between the technology stack and business specifications. The prompts accurately guide the output requirements, reduce manual adaptation and debugging, effectively improve the development efficiency, generation quality and maintainability of the whole stack system, and achieve efficient integrated delivery from requirements to a runnable system.
[0075] Example 3
[0076] Figure 3 This is a schematic diagram of a code generation device based on multiple agents provided in Embodiment 3 of the present invention. Figure 3As shown, the apparatus comprises: an acquisition module 310 and a code generation module 320. Wherein,
[0077] The acquisition module 310 is configured to acquire a business design document corresponding to a design request of a target system in response to the design request, and determine a multi-agent code generation system corresponding to the business design document, wherein the business design document comprises description information of functional requirements of the target system, and the multi-agent code generation system comprises a plurality of code generation agents, and the multi-agent code generation system comprises at least two of a table design agent, a front-end code generation agent, a back-end code generation agent, and a code integration agent; and the code generation module 320 is configured to provide the business design document and a target prompt to the multi-agent code generation system, and obtain generated code of the target system, wherein the target prompt prompts the multi-agent code generation system to output content conforming to the target prompt.
[0078] The technical scheme of the embodiment of the present application, through the acquisition module, in response to the design request of the target system, acquires the business design document corresponding to the design request, and determines the multi-agent code generation system corresponding to the business design document, wherein the business design document comprises description information of functional requirements of the target system, and the multi-agent code generation system comprises a plurality of code generation agents, and the multi-agent code generation system comprises at least two of a table design agent, a front-end code generation agent, a back-end code generation agent, and a code integration agent, accurately matches business requirements and model division, reuses knowledge base data, and reduces data preparation cost; through the code generation module, the business design document and the target prompt are provided to the multi-agent code generation system, and the generated code of the target system is obtained, wherein the target prompt prompts the multi-agent code generation system to output content conforming to the target prompt, clearly defines the generation direction, constrains the output content, improves the code and requirement matching degree, solves the problems of module fragmentation, inconsistent quality and integration difficulty in code generation of complex business systems in related technologies, realizes demand-driven agent division and cooperation, accurately guides the fusion of business documents and prompts, generates complete system code with high matching, low defects and deployability, and significantly improves the code generation efficiency.
[0079] On the basis of the above scheme, optionally, the code generation agent is associated with a code knowledge base, and the code knowledge base stores engineering framework code and business logic code; the code generation module comprises a database code determination submodule, a backend engineering code generation submodule, a frontend engineering code generation submodule, and a code generation submodule. The database code determination submodule is configured to provide the table design agent with the business design document and a first prompt word, so that the table design agent generates target database code according to the business design document, the first prompt word, and the code knowledge base associated with the table design agent.
[0080] The backend engineering code generation submodule is configured to provide the backend code generation agent with the target database code, the business design document, and a third prompt word, so that the backend code generation agent generates backend engineering code according to the target database code, the business design document, the third prompt word, and the code knowledge base associated with the backend code generation agent. The frontend engineering code generation submodule is configured to provide the frontend code generation agent with the business design document, the target database code, and a fourth prompt word, so that the frontend code generation agent generates frontend engineering code according to the business design document, the target database code, the fourth prompt word, and the code knowledge base associated with the frontend code generation agent. The code generation submodule is configured to provide the code integration agent with the target database code, the backend engineering code, the frontend engineering code, and a fifth prompt word, so that the code integration agent generates the generated code of the target system according to the target database code, the backend engineering code, the frontend engineering code, the fifth prompt word, and the code knowledge base associated with the code integration agent.
[0081] On the basis of the above scheme, optionally, the table design agent comprises a library table generation unit, and the database code determination submodule comprises a database code determination unit. The database code determination unit is configured to provide the library table generation unit with the first prompt word and the business design document, so that the library table generation unit determines a table structure design document according to the first prompt word and the business design document, and determines target database code from the code knowledge base associated with the table design agent according to the table structure design document.
[0082] On the basis of the above scheme, optionally, the database code determination unit comprises a database code determination subunit. The database code determination subunit is configured to generate initial database code according to the table structure design document and the code knowledge base associated with the table design agent, and to determine target database code according to a verification result and the initial database code by verifying the syntax and inter-code logic of the initial database code.
[0083] On the basis of the above-mentioned scheme, optionally, the backend code generation agent comprises a first function splitting unit and a first code generation unit; the backend engineering code generation submodule comprises a first splitting unit and a backend engineering code determination unit. The first splitting unit is configured to provide the business design document to the first function splitting unit, so that the first function splitting unit splits the business design document into a plurality of function microservice modules according to the functions of the business design document; the backend engineering code determination unit is configured to provide the target database code, the microservice module and the third prompt word to the first code generation unit, so that the first code generation unit generates initial backend code according to the target database code, the microservice module, the third prompt word and the code knowledge base associated with the backend code generation agent, and determines the backend engineering code according to the initial backend code.
[0084] On the basis of the above-mentioned scheme, optionally, the backend engineering code determination unit comprises a backend engineering code determination subunit. The backend engineering code determination subunit is configured to determine the interface code between a plurality of microservice modules according to the initial backend code, the microservice module and the code knowledge base associated with the backend code generation agent, and determine the backend engineering code according to the initial backend code and the interface code.
[0085] On the basis of the above-mentioned scheme, optionally, the frontend code generation agent comprises a function component determination unit and a second code generation unit; the frontend engineering code generation submodule comprises a second splitting unit and a frontend engineering code determination unit; the second splitting unit is configured to provide the business design document to the function component determination unit, so that the function component determination unit splits the business design document into a plurality of function components according to the functions of the business design document; the frontend engineering code determination unit is configured to provide the function component, the target database code and the fourth prompt word to the second code generation unit, so that the second code generation unit determines the initial frontend code according to the target database code, the function component, the fourth prompt word and the code knowledge base associated with the frontend code generation agent, and determines the frontend engineering code according to the initial frontend code and the fourth prompt word.
[0086] Based on the above scheme, optionally, the front-end engineering code determination unit comprises a front-end engineering code determination subunit. The front-end engineering code determination subunit is configured to determine interface code between the plurality of functional components from the code knowledge base associated with the agent according to the initial front-end code and the functional components, generate a configuration file according to the fourth prompt word, and determine the front-end engineering code according to the initial front-end code, the interface code, and the configuration file.
[0087] Based on the above scheme, optionally, the code generation module is specifically configured to provide the target database code, the back-end engineering code, the front-end engineering code, and a fifth prompt word to the code integration agent, so that the code integration agent checks the data format of the target database code, the back-end engineering code, and the front-end engineering code, and determines target database check code, back-end engineering check code, and front-end engineering check code according to a check result, wherein the check includes at least one of code checking, interface compatibility checking, and version checking. The code generation module is specifically configured to determine a configuration environment rule according to the fifth prompt word, and configure the target database check code, the back-end engineering check code, and the front-end engineering check code according to the configuration environment rule and the code knowledge base associated with the code integration agent, to obtain target database configuration code, back-end engineering configuration code, and front-end engineering configuration code. The code generation module is specifically configured to generate executable deployment scripts of the target database configuration code, the back-end engineering configuration code, and the front-end engineering configuration code according to the configuration environment rule of the fifth prompt word and the code knowledge base associated with the code integration agent, and determine the generated code of the target system according to the executable deployment scripts, the target database configuration code, the back-end engineering configuration code, and the front-end engineering configuration code.
[0088] The code generation apparatus based on multiple agents provided in the embodiments of the present application can execute the code generation method based on multiple agents provided in any of the embodiments of the present application, and has the corresponding function modules and beneficial effects of the execution method.
[0089] Embodiment Four
[0090] Figure 4A structural diagram of an electronic device 10 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smart phones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present application described and / or claimed in this document.
[0091] As shown in Figure 4 The electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., connected to the at least one processor 11 in communication, where the memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer programs stored in the read-only memory (ROM) 12 or loaded into the random access memory (RAM) 13 from the storage unit 18. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0092] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc., an output unit 17, such as various types of displays, speakers, etc., a storage unit 18, such as a magnetic disk, an optical disk, etc., and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunications networks.
[0093] The processor 11 can be various general and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as a multi-agent based code generation method.
[0094] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to embodiments of the present application. For example, embodiments of the present application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via the communication unit 19, or installed from the storage unit 18, or installed from the ROM 12. When the computer program is executed by the processor 11, the above-described functions defined in the methods of embodiments of the present application are performed.
[0095] In some embodiments, a multi-agent based code generation method can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded onto the RAM 13 and executed by the processor 11, one or more steps of a multi-agent based code generation method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform a multi-agent based code generation method by any other suitable means, such as by means of firmware.
[0096] The various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a complex programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0097] Computer programs for implementing the methods of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer program, when executed, enables the functions / acts specified in the flowcharts and / or block diagrams to be implemented. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as a standalone software package and partially on a remote machine or entirely on a remote machine or server.
[0098] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0099] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0100] The systems and techniques described herein can be implemented in a computing system that includes a back end component, e.g., as a data server, or that includes a middleware component, e.g., an application server, or that includes a front end component, e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described herein, or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0101] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.
[0102] It should be understood that the various forms of flow shown above can be re-ordered, added to, or deleted from without departing from the scope of the present disclosure. For example, the steps recited in the present disclosure can be executed in parallel, executed in series, or executed in different orders, as long as the desired results of the technical solutions of the present disclosure can be achieved, and the present disclosure is not limited herein.
[0103] The above detailed description does not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements, and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A code generation method based on multi-agent systems, characterized in that, include: In response to a design request from a target system, a business design document corresponding to the design request is obtained, and a multi-agent code generation system corresponding to the business design document is determined. The business design document includes a description of the functional requirements of the target system, and the multi-agent code generation system includes multiple code generation agents, including at least two of the following: a table design agent, a front-end code generation agent, a back-end code generation agent, and a code integration agent. The business design document and target prompt words are provided to the multi-agent code generation system to obtain the generated code of the target system, wherein the target prompt words prompt the multi-agent code generation system to output content that conforms to the target prompt words.
2. The method according to claim 1, characterized in that, The code generation agent is associated with a code knowledge base, which stores engineering framework code and business logic code; The step of providing the business design document to the multi-agent code generation system to obtain the generated code for the target system includes: The business design document and the first prompt word are provided to the table design agent so that the table design agent can generate target database code based on the business design document, the first prompt word and the code knowledge base associated with the table design agent. The target database code, the business design document, and the third prompt word are provided to the backend code generation agent so that the backend code generation agent can generate backend project code based on the target database code, the business design document, the third prompt word, and the code knowledge base associated with the backend code generation agent. The business design document, the target database code, and the fourth prompt word are provided to the front-end code generation agent so that the front-end code generation agent can generate front-end project code based on the business design document, the target database code, the fourth prompt word, and the code knowledge base associated with the front-end code generation agent. The code integration agent is provided with the target database code, the backend project code, the frontend project code, and the fifth prompt word, so that the code integration agent can generate the generation code of the target system based on the target database code, the backend project code, the frontend project code, the fifth prompt word, and the code knowledge base associated with the code integration agent.
3. The method according to claim 2, characterized in that, The table design agent includes a database table generation unit. Providing the table design agent with the business design document and a first prompt word, so that the table design agent generates target database code based on the business design document, the first prompt word, and the code knowledge base associated with the table design agent, includes: The first prompt word and the business design document are provided to the database table generation unit so that the database table generation unit can determine the table structure design document based on the first prompt word and the business design document, and determine the target database code from the code knowledge base associated with the table design agent based on the table structure design document.
4. The method according to claim 3, characterized in that, The step of determining the target database code from the code knowledge base associated with the table design agent based on the table structure design document includes: Generate initial database code based on the table structure design document and the code knowledge base associated with the table design agent; The syntax and inter-code logic of the initial database code are validated, and the target database code is determined based on the validation results and the initial database code.
5. The method according to claim 2, characterized in that, The backend code generation agent includes a first functional decomposition unit and a first code generation unit. Providing the backend code generation agent with the target database code, the business design document, and a third prompt word, so that the backend code generation agent generates backend project code based on the target database code, the business design document, the third prompt word, and the code knowledge base associated with the backend code generation agent, includes: The business design document is provided to the first function splitting unit so that the first function splitting unit splits the business design document into multiple functional microservice modules according to the functions of the business design document. The first code generation unit is provided with the target database code, the microservice module, and the third prompt word, so that the first code generation unit generates initial backend code based on the target database code, the microservice module, the third prompt word, and the code knowledge base associated with the backend code, and determines the backend project code based on the initial backend code.
6. The method according to claim 5, characterized in that, The step of determining the backend project code based on the initial backend code includes: The interface code between multiple microservice modules is determined based on the initial backend code, the microservice modules, and the code knowledge base associated with the intelligent agent generated by the backend code; the backend engineering code is determined based on the initial backend code and the interface code.
7. The method according to claim 2, characterized in that, The front-end code generation agent includes a functional component determination unit and a second code generation unit, which provides the code integration agent with the target database code, the back-end project code, the front-end project code, and a fifth prompt word, so that the code integration agent generates the generation code of the target system based on the target database code, the back-end project code, the front-end project code, the fifth prompt word, and the code knowledge base associated with the code integration agent, including; The business design document is provided to the functional component determination unit so that the functional component determination unit can divide the business design document into multiple functional components according to the functions of the business design document. The second code generation unit is provided with the functional component, the target database code, and the fourth prompt word, so that the second code generation unit determines the initial front-end code based on the target database code, the functional component, the fourth prompt word, and the code knowledge base associated with the front-end code generation agent, and determines the front-end engineering code based on the initial front-end code and the fourth prompt word.
8. The method according to claim 7, characterized in that, The step of determining the front-end project code based on the initial front-end code and the fourth prompt word includes: Based on the initial front-end code and the functional components, the interface code between multiple functional components is determined from the code knowledge base associated with the intelligent agent generated from the front-end code. A configuration file is generated based on the fourth prompt word. The front-end project code is determined based on the initial front-end code, the interface code, and the configuration file.
9. The method according to claim 2, characterized in that, The step of providing the code integration agent with the target database code, the backend engineering code, the frontend engineering code, and the fifth prompt word, so that the code integration agent can generate the generated code of the target system based on the target database code, the backend engineering code, the frontend engineering code, the fifth prompt word, and the code knowledge base associated with the code integration agent, includes: The code integration agent is provided with the target database code, the backend project code, the frontend project code, and a fifth prompt word, so that the code integration agent can verify the data format of the target database code, the backend project code, and the frontend project code, and determine the target database verification code, the backend project verification code, and the frontend project verification code according to the verification results, wherein the verification includes at least one of code verification, interface compatibility verification, and version verification; The configuration environment rules are determined based on the fifth prompt word. The target database verification code, the backend engineering verification code, and the frontend engineering verification code are configured according to the configuration environment rules and the code knowledge base associated with the code integration agent, respectively, to obtain the target database configuration code, the backend engineering configuration code, and the frontend engineering configuration code. Based on the configuration environment rules of the fifth prompt word and the code knowledge base associated with the code integration agent, executable deployment scripts for the target database configuration code, the backend project configuration code, and the frontend project configuration code are generated respectively. The generated code of the target system is determined based on the executable deployment scripts, the target database configuration code, the backend project configuration code, and the frontend project configuration code.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the multi-agent-based code generation method according to any one of claims 1-9.