Business module source code generation method and system based on large model business reasoning
By employing a business reasoning method based on large models, a weighted business association graph is constructed, and multi-agent collaborative generation of module code is utilized. This solves the problem that existing tools struggle to understand enterprise-level application logic, achieving efficient and automated code generation and quality assurance, thereby enhancing the enterprise's market competitiveness.
Patent Information
- Application Number
- CN202511476392.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-16
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2045-10-16
AI Technical Summary
Existing code generation tools struggle to understand the business logic of enterprise applications, resulting in generated code that lacks systematicity and coherence, cannot adapt to changes in business needs, and has poor scalability, making it difficult to respond quickly to market changes.
We adopt a large-model-based business reasoning approach, construct a weighted business association graph through semantic parsing, decompose tasks into sub-tasks, and utilize multi-agent collaborative generation of module code. Combined with domain-adaptive training and code quality verification, we ensure that the generated code meets high-quality standards.
It enables automated code generation from natural language requirements to complete business modules, improving code generation efficiency and quality, reducing subsequent debugging and maintenance workload, and enhancing the enterprise's ability to respond to changes in business requirements.
Smart Images

Figure CN120929089B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of code generation technology, and in particular to a method and system for generating source code for business modules based on large-model business reasoning. Background Technology
[0002] Enterprise application development refers to the process of developing software applications tailored to meet the specific business needs of enterprises. It covers multiple fields, from enterprise resource planning (ERP) and customer relationship management (CRM) to supply chain management, aiming to improve the operational efficiency of enterprises, reduce costs, and enhance competitiveness.
[0003] In enterprise application development, a significant amount of repetitive work consumes developers' time and energy. Statistics show that approximately 70% of the work is focused on writing repetitive code, which not only reduces development efficiency but also increases the risk of human error. While existing low-code platforms can reduce some coding, they require manual configuration of business rules, resulting in a lack of flexibility and automation in the development process. Furthermore, large-scale model code generation generally lacks overall architectural design, making it difficult for the generated code to form complete and effective business modules.
[0004] Several representative solutions exist in the current technology landscape. For example, the AI programming tool GitHub Copilot primarily performs code completion based on local context, but it can only generate function-level code snippets, failing to grasp the overall architecture and business logic of enterprise applications. Template engines, during code generation, exhibit strong coupling between business logic and code, resulting in poor maintainability and scalability, making it difficult to adapt to changing business needs. Monolithic large models cannot guarantee consistency in dependencies between modules during code generation, easily leading to problems during integration and execution. DeepCode, a tool that utilizes artificial intelligence for code review, typically employs static code analysis and pattern matching methods. While it can uncover some potential problems in the code, it cannot deeply understand the business logic, offering limited assistance to code generation.
[0005] Traditional code generation tools, unable to understand business logic, struggle to generate related business modules, resulting in code that lacks systematicity and coherence. Existing low-code platforms rely excessively on manual templates, severely limiting system scalability and leading to low modularity in the generated code, causing significant difficulties for subsequent maintenance. Furthermore, these tools generally lack the ability to dynamically adapt to changing business requirements. When business needs evolve, substantial redevelopment is often required, hindering timely responses to market changes. Summary of the Invention
[0006] To address the above technical problems, this invention provides a method for generating source code for business modules based on large-model business reasoning; on the other hand, it also provides a system for generating source code for business modules based on large-model business reasoning.
[0007] The technical problem solved by this invention can be achieved by the following technical solution: a method for generating source code for business modules based on large-model business reasoning, comprising: step S1, performing semantic parsing of business requirements and constructing a weighted business association graph; step S2, dividing the complete task into multiple sub-tasks based on the weighted business association graph; step S3, calling a coordinating agent to assign a corresponding large-model-based module code generation agent to each of the decomposed sub-tasks and injecting context information to generate the corresponding module code; wherein, the module code generation agent has been pre-trained based on domain adaptive phased training to learn the correspondence between the task and the injected context information and the code; step S4, calling a verification agent to verify the code quality of the generated module code.
[0008] Preferably, step S1 includes: step S11, extracting business entities and the relationships between business entities from business requirements; step S12, analyzing the business requirements and determining the weights of the relationships between business entities based on the interaction frequency, co-occurrence frequency, business importance, dependency strength, and operational complexity; and step S13, constructing a weighted business association graph based on the business entities, the relationships between business entities, and the corresponding weights.
[0009] Preferably, step S3 includes: invoking the workflow agent to coordinate the execution order of each agent in the multi-agent matrix and manage the code generation process; invoking the basic settings agent to generate basic settings code according to module storage requirements; invoking the database analysis agent to perform semantic analysis on the database table structure and extract database field information; invoking the front-end development agent to generate front-end interface code containing front-end controls based on a preset development framework for the assigned sub-tasks according to the database field information; invoking the back-end development agent to generate preset programming language code based on the preset development framework front-end according to the internationalization tags and control constraints of the front-end controls; invoking the core logic agent to generate core logic code according to preset business rules; and invoking the interface adaptation agent to generate interface adaptation layer code according to preset interface specifications.
[0010] Preferably, the steps for generating the internationalization tags include: extracting field description information from the front-end control configuration file; detecting whether the field description information contains preset keywords; when preset keywords are detected, determining the control type of the front-end control based on the mapping relationship between keywords and control types; when preset keywords are not detected, determining the default text input box as the control type; generating internationalization tags based on the determined control type; and outputting the front-end control configured with internationalization tags.
[0011] Preferably, the step of generating the preset programming language code includes: parsing the constraint metadata of the control constraint according to the internationalization tag of the front-end control to determine the constraint type; verifying the determined constraint type based on the preset verification function; and generating the corresponding code of the front-end control to form the preset programming language code after the constraint type verification is passed.
[0012] Preferably, the steps of the domain-adaptive phased training include: performing domain-aware pre-training on a general pre-trained model based on a large model according to domain text and general corpus to obtain a first intermediate model; performing task-oriented fine-tuning on the first intermediate model according to labeled task data to obtain a second intermediate model; performing reinforcement alignment optimization on the second intermediate model according to interaction logs to obtain a third intermediate model; and performing continuous domain evolution on the third intermediate model according to incremental data to obtain a domain expert model, and constructing the module code generation agent based on the large model according to the domain expert model.
[0013] Preferably, step S4 includes: analyzing the generated module code according to a preset code quality evaluation index system, determining the scores of each quality evaluation index, the innovation score, and the technical debt score, and summarizing them to obtain a quality evaluation score; verifying whether the generated module code meets the standards based on the quality evaluation score; deploying and releasing the generated module code when the verification meets the standards; and generating optimization suggestions based on the feedback from the verification failure when the verification fails, and repairing the module code according to the optimization suggestions, based on the information from the pre-trained reinforcement learning model.
[0014] Preferably, the quality assessment indicators include static quality indicators, dynamic quality indicators, and security and reliability indicators; the static quality indicators include one or more combinations of cyclomatic complexity, cognitive complexity, code duplication rate, file length, and coding standard compliance rate; the dynamic quality indicators include one or more combinations of line coverage, branch coverage, execution time, memory usage, and throughput; and the security and reliability indicators include one or more combinations of vulnerability count, security scan score, anomaly rate, and recovery time.
[0015] Preferably, the method for determining the quality assessment score is as follows:
[0016]
[0017] Wherein, S1 represents the static quality indicator score; S2 represents the dynamic quality indicator score; S3 represents the safety and reliability indicator score; S4 represents the innovation score; S5 represents the technical debt score; W1, W2, and W3 represent the corresponding weights; and Total represents the quality assessment score.
[0018] On the other hand, a business module source code generation system based on large-model business reasoning is provided to implement the aforementioned method for generating business module source code based on large-model business reasoning. The system includes: a semantic parsing module for semantically parsing business requirements and constructing a weighted business association graph; a module partitioning module connected to the semantic parsing module for partitioning modules based on the weighted business association graph, decomposing the complete task into multiple sub-tasks; a code generation module connected to the module partitioning module for invoking a coordinating agent to assign a corresponding large-model-based module code generation agent to each decomposed sub-task and injecting context information to generate the corresponding module code; wherein the module code generation agent has been pre-trained based on domain adaptive phased training to learn the correspondence between the task, the injected context information, and the code; and a code quality verification module connected to the code generation module for invoking a verification agent to verify the code quality of the generated module code.
[0019] The advantages or beneficial effects of the technical solution of this invention are as follows: This invention divides modules based on a weighted business association graph, adopts domain-adaptive phased training to construct multi-agent collaborative code generation, and verifies the quality of the generated code, promptly discovering potential problems and errors in the code, ensuring that the generated code meets high-quality standards, reducing the workload of subsequent debugging and maintenance, improving code generation efficiency and quality, saving a lot of time and manpower costs for enterprise-level application development, enhancing the enterprise's ability to respond to changes in business requirements, and improving the enterprise's competitiveness in the market. Attached Figure Description
[0020] Figure 1 This is a flowchart illustrating a preferred embodiment of the present invention for a method of generating source code for a business module based on large-model business reasoning.
[0021] Figure 2 This is a schematic diagram of the process for constructing a weighted business association graph in a preferred embodiment of the present invention;
[0022] Figure 3 This is a schematic diagram of a multi-agent matrix of an AI large model, as shown in a preferred embodiment of the present invention.
[0023] Figure 4 This is a schematic diagram of the process of domain-adaptive phased training in a preferred embodiment of the present invention;
[0024] Figure 5 This is a schematic diagram of the multi-agent collaboration process in a preferred embodiment of the present invention;
[0025] Figure 6 This is a schematic diagram of the process for generating internationalized labels in a preferred embodiment of the present invention;
[0026] Figure 7 This is a schematic diagram of the JS code generation process in a preferred embodiment of the present invention;
[0027] Figure 8 This is a schematic diagram of the process of converting control constraints to JS code in a preferred embodiment of the present invention;
[0028] Figure 9 This is a schematic diagram of the constraint management process in a preferred embodiment of the present invention;
[0029] Figure 10 This is a schematic diagram of the architecture of VJSP logic code in a preferred embodiment of the present invention;
[0030] Figure 11 This is a schematic diagram of the code generation process in a preferred embodiment of the present invention;
[0031] Figure 12 This is a schematic diagram of the code quality verification process in a preferred embodiment of the present invention;
[0032] Figure 13 This is a schematic diagram of the overall architecture flow in a preferred embodiment of the present invention;
[0033] Figure 14 This is a schematic diagram of the class-level granular code generation process in a preferred embodiment of the present invention;
[0034] Figure 15 This is a flowchart illustrating the class generation workflow in a preferred embodiment of the present invention. Detailed Implementation
[0035] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0036] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.
[0037] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, but this is not intended to limit the scope of the invention.
[0038] In a preferred embodiment of the present invention, based on the above-mentioned problems existing in the prior art, a method for generating source code of a business module based on large-model business reasoning is provided, such as... Figures 1 to 13 As shown, the method includes: Step S1, performing semantic parsing of business requirements and constructing a weighted business association graph; Step S2, dividing the complete task into multiple sub-tasks based on the weighted business association graph; Step S3, calling a coordinating agent to assign a corresponding module code generation agent based on a large model to each sub-task after decomposition, and injecting context information to generate the corresponding module code; wherein, the module code generation agent has been pre-trained based on domain adaptive phased training to learn the correspondence between the task and the injected context information and the code; Step S4, calling a verification agent to verify the code quality of the generated module code.
[0039] Specifically, traditional code generation tools struggle to understand business logic, resulting in code that lacks systematicity; low-code platforms rely on manual templates, exhibiting poor scalability, low modularity, and difficulty in adapting to business changes, thus failing to respond promptly to market demands.
[0040] In this embodiment, the complete task is broken down into multiple sub-tasks by dividing the data into modules based on a weighted business association graph. Then, based on a multi-agent collaborative code generation mechanism, a domain-adaptive phased training method is used to learn the correspondence between tasks, injected context information, and code. This allows for direct invocation of the coordinating agent during code generation, generating the corresponding module code for each sub-task and completing code quality verification. This invention's method inputs business requirements into a large AI model, enabling one-click execution and automated code generation from natural language requirements to complete business modules, ensuring high cohesion and low coupling characteristics in the generated code.
[0041] Furthermore, business requirements include the system's functionalities, performance, user experience, and other objectives. Business requirements can be documents, images, text, or even interactive prototypes or video demonstrations.
[0042] Furthermore, a semantic parsing engine is employed to implement the semantic parsing process for business requirements. The semantic parsing engine is an AI-based intelligent component used to deeply understand and accurately transform unstructured or semi-structured natural language business requirement documents into structured, machine-understandable semantic representations.
[0043] Semantic parsing engines are not limited to simple keyword matching, but can deeply analyze the text of requirements, understand its deeper meaning, context and the true intent it contains, and achieve in-depth analysis of requirements.
[0044] Simultaneously, the engine can identify and extract core business entities (such as "customer," "order," "product," and "inventory") and their attributes and relationships from the requirements, achieving business concept extraction. For implicit or explicit business rules in the requirements, including conditions, constraints, and logical flows, the engine can transform them into structured, executable rule descriptions for use by the "business rule base," completing the extraction and formalization of business rules. The engine can also understand the business processes described by the requirements, covering steps, branches, loops, and decision points, and transform them into structured process representations, achieving process modeling.
[0045] Furthermore, the engine can reference domain knowledge, mapping natural language vocabulary in the requirements to standardized domain terminology within the system. For any ambiguity, conflict, or incompleteness in the requirements, the engine will attempt to disambiguate using context or a knowledge base. If the disambiguation fails, it will be marked for manual review, thus achieving ambiguity resolution. Finally, the engine can link related elements scattered across different requirement descriptions, such as entity attributes referenced by rules, enabling requirement element association.
[0046] Semantic parsing engines are driven by large models, with their core capabilities stemming from pre-trained large language models (LLMs). These models possess powerful language understanding, contextual reasoning, and knowledge association abilities. While based on a general-purpose LLM, they are typically fine-tuned, employing prompt engineering, or combined with "business rule bases / knowledge bases" to focus on specific business domains, such as e-commerce, finance, and ERP. This allows them to understand domain-specific terminology and logic, resulting in strong domain adaptability.
[0047] The engine's goal is to generate machine-processable structured data, achieving structured output rather than natural language text. This structured output ensures more accurate and consistent input sources for rule definitions, module division, and code generation, improving the accuracy and consistency of requirement transformation. Its output serves downstream processes, such as rule bases and intermediate products of module generation, acting as an intermediate representation guide, rather than the final code.
[0048] The engine possesses iterative and learning capabilities, based on a feedback learning mechanism, such as continuously optimizing the feedback loop of the knowledge base. When humans correct the generated rules or code, relevant information is fed back to the engine to optimize its future parsing accuracy. Moreover, it can handle relatively complex business logic descriptions, including conditional statements, loops, exception handling, and multi-entity interactions.
[0049] This invention employs a semantic parsing engine to parse requirements, automatically and rapidly transforming massive amounts of ambiguous natural language requirements into structured, actionable information. This significantly reduces the time spent on manual sorting and specification writing, improving requirement processing efficiency. Leveraging AI's powerful understanding capabilities, it acts as a translator between business and technical language, minimizing the requirement gap caused by inconsistent interpretations of the same requirement text by different personnel, such as business analysts (BAs), developers, and testers. This reduces communication friction and misunderstandings, lowering communication costs. Providing high-quality, machine-friendly input for multi-agent collaboration and code generators is a crucial step in achieving an automated "requirements -> design -> code" pipeline, supporting automated development. The business rules and entity relationships identified and formalized during the parsing process are stored in a business rule base and a continuously optimized knowledge base, forming reusable enterprise knowledge assets. This makes it possible to process large-scale, highly complex business requirement documents and quickly initiate development.
[0050] In a preferred embodiment, such as Figure 2 As shown, step S1 includes: step S11, extracting business entities and the relationships between business entities from business requirements; step S12, analyzing business requirements and determining the weights of relationships between business entities based on the interaction frequency, co-occurrence frequency, business importance, dependency strength, and operational complexity; and step S13, constructing a weighted business association graph based on business entities, the relationships between business entities, and their corresponding weights.
[0051] Furthermore, weighted business relationship graphs are used to represent core concepts (entities) and their relationships within a specific business domain or requirement. Business entities and relationships can be extracted using a BERT+CRF model. The graph includes:
[0052] Nodes: These are business entities that can be extracted from the requirements document.
[0053] Edges: These are the relationships between entities. These relationships describe how entities interact or associate within a business scenario.
[0054] Weight: Used to quantify the importance or strength of a relationship, rather than simply indicating "related" or "unrelated". It is usually a numerical value appended to the edge. A higher weight indicates that the business relationship is more important, frequent, and close in the business scenario. Weights can be used in recommendation systems, risk control, and business optimization decisions.
[0055] Weights can be obtained by analyzing the structured representation after semantic parsing of business requirements, such as interaction frequency / co-occurrence frequency, business importance / dependency strength, and operational complexity.
[0056] Interaction frequency / co-occurrence frequency: In the requirement description, if two entities are frequently mentioned together, operated together, or closely collaborated in a business process, the weight value represents the interaction frequency, such as the number of purchases or views.
[0057] Business Importance / Dependency Strength: Sometimes the weight may be set in conjunction with business rules. For example, if a core business process depends on a certain entity, its weight may be increased even if they do not co-occur most frequently.
[0058] Operational complexity: The complexity of the operation performed on a particular entity or the amount of data involved will also affect the weight.
[0059] For example, the following is a business relationship graph example of an e-commerce platform, which shows the interaction relationships and frequency weights between different business entities.
[0060] Node definition (business entity) includes User, Product, Merchant, Order, Logistics, Payment, Customer Service, and edge definition (interaction relationship and weight).
[0061] Edge definition (entity relationship) includes user-related relationships, product-related relationships, order-related relationships, and merchant-related relationships.
[0062] Examples of user-related relationships are as follows:
[0063] User A -- Purchases --> Product X [Weight: 15 times]
[0064] User A -- Browse --> Product Y [Weight: 23 times]
[0065] User A -- Add to Favorites --> Merchant M [Weight: 5 times]
[0066] User A -- Inquiry --> Customer Service C [Weight: 3 times]
[0067] User A -- uses --> pays P [Weight: 18 times]
[0068] Examples of product relationships are as follows:
[0069] Product X -- belongs to --> Merchant M [Weight: 1 time]
[0070] Product X -- Similar Product --> Product Y [Weight: 8 times]
[0071] Product X -- Matching Package --> Product Z [Weight: 5 times]
[0072] Product X -- via --> Logistics L [Weight: 12 times]
[0073] The following is an example of order-related relationships:
[0074] Order O -- Contains --> Product X [Weight: 1 time]
[0075] Order O -- Belongs to --> User A [Weight: 1 time]
[0076] Order O -- Pass --> Payment P [Weight: 1 time]
[0077] Order O -- Delivery --> Logistics L [Weight: 1 time]
[0078] Examples of merchant relationships are as follows:
[0079] Merchant M -- offers --> Product X [Weight: 45 times]
[0080] Merchant M -- Use --> Payment P [Weight: 30 times]
[0081] Merchant M -- Cooperation --> Logistics L [Weight: 25 times]
[0082] Merchant M -- Processing --> Order O [Weight: 40 times]
[0083] For example, the visual representation of the graph is as follows:
[0084] User A
[0085] │
[0086] ├──(Purchased 15 times)──→ Item X ──(Belongs to 1 purchase)──→ Merchant M
[0087] │ │ │
[0088] ├──(Viewed 23 times)──→ Product Y ──(Similar products viewed 8 times)──┘ │
[0089] │ │
[0090] ├──(Collected 5 times)────────────────────┘
[0091] │
[0092] ├──(3 consultations)──→ Customer Service C
[0093] │
[0094] └──(Used 18 times)──→ Payment P ←──(Used 30 times)─── Merchant M
[0095] │
[0096] └──(25 collaborations)──→ Logistics L ←──(12 successful collaborations)── Product X
[0097] Furthermore, it also includes using decision trees instead of graph neural networks (GNNs) for business association graph partitioning.
[0098] Furthermore, the business rule base serves as the core knowledge storage and authoritative source in the entire intelligent requirement analysis and code generation process, providing crucial support for semantic analysis, module generation, and code verification.
[0099] A business rule base is a structured, digital, and persistently stored collection of business rules. It transforms vague and scattered business logic—found in requirement documents and in people's minds—into a clear, explicit, executable, manageable, and reusable readable form. This business rule base provides domain knowledge to the semantic parsing engine, helping it understand the terminology, constraints, and logic in requirements, and verifying the rationality of its parsing results, such as identifying conflicts between requirement descriptions and existing rules. It can also provide direct and precise input to the core logic agent, telling it "what the business requires," to drive code generation. During the module partitioning phase, the type, scope, and associated entities of the rules serve as important reference factors to support module partitioning decisions. During the code quality verification phase, the rule base can be used to check whether the generated code truly implements the business intent and verify code correctness. Furthermore, it can also accumulate business knowledge, becoming a valuable, shareable, and versioned business logic asset library for the enterprise.
[0100] The business rule base does not store the original requirement text, but rather atomic business rules extracted and structured from the requirements. Each business rule typically includes the following core elements: rule identifier, rule type, rule logical expression, scope and associated entities, and conflict handling information. The rule identifier includes the rule ID, rule name, and version number. The rule ID is a unique identifier for the rule; the rule name clearly describes the rule's purpose; and the version number supports rule evolution and traceability.
[0101] The rule description includes a natural language description and a business scenario / context. The natural language description refers to a clear, human-readable explanation of the rule; the business scenario / context describes the business context in which the rule applies.
[0102] Rule types identify the core logical category of rules, aiding in organization, retrieval, and understanding. Rule types include constraint classes (such as data constraints and state constraints), calculation / derivation classes, behavior / response classes, process / decision classes, authorization classes, and derivation / inference classes. Specifically, data constraints define the conditions that data must meet; state constraints define the operations that entities are allowed or prohibited from performing in a specific state; calculation / derivation classes define how to calculate a value; behavior / response classes define the actions the system should perform under specific events or conditions; process / decision classes define the branches, routing, or decision logic in a process; authorization classes define access control rules; and derivation / inference classes can deduce new facts based on existing information.
[0103] The rules and logic are expressed precisely using a structured, formal, and machine-parseable language.
[0104] The scope and associated entities include the applicable domain / module, associated business entities, effective conditions / context, and attributes / metadata. The applicable domain / module defines which business domain or system module the rule belongs to, such as the order domain, customer management, or payment module; the associated business entities define which business entities the rule primarily operates on or constrains; the effective conditions / context define the additional conditions for the rule to take effect; and the attributes / metadata define the source, status, effective / expiration date, responsible person / owner, priority / weight, and dependencies.
[0105] Conflict handling information includes potential conflict rules and conflict resolution strategies. Potential conflict rules are other rule IDs that may conflict with the current rule, identified by the system or manually marked. Conflict resolution strategies specify the resolution mechanisms when conflicts occur.
[0106] This invention constructs a large AI model multi-agent matrix of 100, such as... Figure 3 As shown, it includes nine parts: coordination agent 101, basic setup agent 102, core logic agent 103, interface adaptation agent 104, verification agent 105, database analysis agent 106, front-end development agent 107, back-end development agent 108, and workflow agent 109, and supports code generation for dynamic business rule adjustments.
[0107] In a preferred embodiment, step S3 includes: invoking the workflow agent 109 to coordinate the execution order of each agent in the multi-agent matrix and manage the code generation process; invoking the basic setup agent 102 to generate basic setup code according to module storage requirements; invoking the database analysis agent 106 to perform semantic analysis on the database table structure and extract database field information; invoking the front-end development agent 107 to generate front-end interface code containing front-end controls based on a preset development framework (VJSP) for the assigned subtasks according to the database field information; invoking the back-end development agent 108 to generate preset programming language code based on the preset development framework front-end according to the internationalization tags and control constraints of the front-end controls; invoking the core logic agent 103 to generate core logic code according to preset business rules; and invoking the interface adaptation agent 104 to generate interface adaptation layer code according to preset interface (API) specifications.
[0108] Specifically, in this embodiment, after receiving the input business requirements and database tables, the AI big data model first generates VJSP front-end code based on the database fields and requirements; then, it automatically generates internationalization (I18N) tags for the front-end controls based on the front-end controls and field descriptions; next, the AI big data model generates VJSP front-end JS code based on the control constraints; finally, the VJSP logic code generates, inserts, modifies, and queries the requirements and database fields.
[0109] like Figure 6 As shown, the steps for generating internationalization labels include:
[0110] A1 extracts field description information from the front-end control configuration file; it can also perform natural language processing on the field description information.
[0111] A2, check if there are preset keywords in the field description information; when preset keywords are detected, determine the control type of the front-end control according to the mapping relationship between keywords and control types; when preset keywords are not detected, determine the default text input box as the control type;
[0112] A3, generate internationalization tags based on the determined control type;
[0113] A4 outputs front-end controls configured with internationalized tags.
[0114] For example, the code for generating internationalized language tags is as follows:
[0115] {}json
[0116] {
[0117] "zh_CN": {
[0118] "closeBtn": "Close"
[0119] "submitBtn": "Save",
[0120] "textboxLabel1": "text",
[0121] "textboxLabel2": "Application Information"
[0122] "numberboxLabel1": "Sort",
[0123] "DIC_TEXT_validateMsg1": "The text length cannot exceed 40 characters".
[0124] "DIC_TEXT_validateMsg2": "Text cannot be empty"
[0125] "PRODUCTAPP_vaLidateMsg1": "Application information length cannot exceed 1e0 characters".
[0126] "PRODUCT_APP_vaLIdateMsg2*: Application information cannot be empty"
[0127] },
[0128] "en_US": {
[0129] "closeBtn":"Close",
[0130] "textboxLabel1":"Text",
[0131] "textboxLabel2":"ApplicationInformation",
[0132] "numberboxLabel1":"Index',
[0133] "DIC_TEXT_validateMsgl°:"Text length cannot exceed 40characters",
[0134] "DIC_TEXT_validateMsg2":"Textisrequired",
[0135] "pRoDucT APP_validateMsgi":"Application 1nformation Length cannotexceed 1eo characters",
[0136] "pRODuCTAPP_validateMsg2*:"Application1nformation1srequired"
[0137] }
[0138] }
[0139] This invention uses a large AI model to detect the description text of front-end control fields and combine it with the control type to automatically generate internationalized tags.
[0140] In a preferred embodiment, such as Figure 7 As shown, the steps for generating the preset programming language code include: B1, parsing the constraint metadata of the control constraint based on the internationalization (I18N) tag of the front-end control to determine the constraint type; B2, verifying the determined constraint type based on the preset verification function; B3, after the constraint type verification is passed, generating the corresponding code of the front-end control to form the preset programming language (such as JavaScript, JS) code.
[0141] Specifically, JavaScript code is generated based on control constraints. Control constraints are a key mechanism to ensure that user input conforms to business rules. Control constraints include, but are not limited to: basic data type constraints, value range constraints, content specification constraints, business logic constraints, and UI presentation constraints, as shown in Tables 1-5 below.
[0142] Table 1 Basic Data Type Constraints
[0143]
[0144] Table 2. Range Constraints
[0145]
[0146] Table 3 Content Specification Constraints
[0147]
[0148] Table 4 Business Logic Constraints
[0149]
[0150] Table 5 UI Presentation Constraints
[0151]
[0152] The process of converting control constraints to JS code is as follows: Figure 8 As shown, constraint metadata is input into the constraint parser to obtain the constraint type; based on the constraint type, the corresponding verification function, such as the basic verification function, the value range verification function, and the business verification function, is called to verify the front-end control corresponding to the constraint type; and after the verification is passed, the module control code is generated through the code generator, i.e., the aforementioned intelligent agent.
[0153] Constraint management system, such as Figure 9 As shown, the system includes a constraint definition interface, providing users with an intuitive and convenient platform to define constraints; a constraint parser, capable of accurately analyzing and understanding user-defined constraints; a constraint repository, used to store various constraint information; a code generator, which automatically generates corresponding code based on constraints; a front-end component, presenting a user-friendly interface; a user interaction module, ensuring efficient and smooth communication between users and the system; a verification feedback mechanism, capable of verifying the execution of constraints and providing timely feedback; and a constraint optimization module, continuously improving and refining the constraint repository based on constraint verification results. The system comprises four core functional modules: a constraint visual editor, constraint version management, constraint test suites, and constraint performance monitoring. The constraint visual editor provides a drag-and-drop constraint configuration interface, allowing real-time preview of verification effects and constraint dependency graphs; constraint version management enables constraint change history tracking, version rollback, and multi-environment constraint configuration; the constraint test suite automatically generates test cases, boundary value tests, and abnormal input tests; and constraint performance monitoring verifies function execution time, verifies failure rate statistics, and analyzes common error types.
[0154] VJSP logic code performs operations such as generating, inserting, modifying, and querying based on requirements and database fields. For example... Figure 10 As shown, the code generator can perform requirements analysis, database model generation, AP route generation, and front-end control generation. The code generation process is as follows: Figure 11 As shown, the front-end HTML sends API calls to the back-end, and the back-end interacts with various databases (such as MySQL, PostgreSQL, and MongoDB) through the database operation layer to perform operations such as data generation, insertion, modification, and querying.
[0155] The mapping rules from database fields to database models are shown in Table 6 below.
[0156] Table 6. Mapping rules from database fields to database models
[0157]
[0158] In a preferred embodiment, such as Figure 4 As shown, the steps of the domain-adaptive phased training include: performing domain-aware pre-training on a general pre-trained model based on a large model using domain text and general corpus to obtain a first intermediate model; performing task-oriented fine-tuning on the first intermediate model using labeled task data to obtain a second intermediate model; performing reinforcement alignment optimization on the second intermediate model using interaction logs to obtain a third intermediate model; and continuously evolving the third intermediate model using incremental data to obtain a domain expert model, and constructing a module code generation agent based on a large model based on the domain expert model.
[0159] Specifically, during the data preparation phase, data such as project requirement documents, project code, test plans, test cases, and workflows covering different industries are extracted from various historical projects.
[0160] In the data preprocessing stage, raw, noisy data is cleaned into relatively clean and standardized text. Preprocessing operations include, but are not limited to, quality filtering, deduplication, and privacy and security filtering.
[0161] Quality filtering can be rule-based, filtering out overly short, repetitive, spam, placeholder text, or excessive special characters content; it can also be classifier-based, training a machine learning model to predict document quality and retaining only high-scoring documents. For example, a classifier can be trained using high-quality data (such as Wikipedia) to score Common Crawl web pages; or it can be based on heuristic metrics, using statistical indicators such as the type-to-token ratio and punctuation ratio to remove low-quality text.
[0162] Deduplication can be performed using precise deduplication to remove identical documents or paragraphs; or using fuzzy deduplication (near-duplicate deletion) to remove documents with highly similar content (such as news articles that differ only in title), preventing the model from over-memorizing and mechanically reproducing in the output.
[0163] Privacy and security filtering is used to remove or anonymize data containing personally identifiable information (PII), such as email addresses, phone numbers, and addresses.
[0164] Furthermore, after data preprocessing, the preprocessed data can be labeled. For the Supervised Fine-Tuning (SFT) and Reward Model (RM) training phases, high-quality labeled data can be generated manually or with model assistance. Labeling types include, but are not limited to, instruction-response pairs, instructions, and preference ranking; instruction-response pairs are used in the SFT phase. Labelers write instructions and provide high-quality responses. For example:
[0165] Instruction: "Please design a user management function for me."
[0166] Answer: "Okay, the user management function should include the following fields: user name, gender, age, contact number, email, etc."
[0167] Preference ranking is used in the training phase of RM. For the same instruction, the model is given multiple different responses, which are then ranked by the annotators (from best to worst).
[0168] Furthermore, given the significant differences in data quality across different sources and types, this embodiment also includes data mixing and recipe preparation to balance the model's capabilities and prevent it from being biased towards a particular domain, such as having weak code capabilities due to an abundance of web page data. Specifically, the data is divided into different categories, including but not limited to web page data, code data, academic papers, dialogue data, and SFT data; the mixing ratio of each type of data in the final dataset is determined, i.e., the data recipe, and a sampling weight is assigned to each category. High-quality data (such as books and SFT data) typically has a higher weight and is sampled more frequently during training.
[0169] Furthermore, this includes data formatting and storage, converting the processed data into a format that the model training framework can efficiently read. Specifically, this involves tokenizing text data and converting it into vocabulary IDs corresponding to the model; and serializing and storing the data in an efficient format, such as JSONL (one JSON object per line). For pre-training data, documents are concatenated and then segmented into fixed-length sequences (e.g., 2048 tokens).
[0170] After obtaining pre-training data, a large model is trained in stages using domain adaptation to obtain a domain expert model, thereby constructing the aforementioned intelligent agents. Specifically, in stage 1, training methods such as mixed corpus training, domain-enhanced MLM (Masked Language Model) tasks, and domain contrastive learning are used to perform domain-aware pre-training based on general corpora and domain text, establishing basic domain understanding capabilities. In stage 2, training methods such as progressive task training, multi-task joint training, and adversarial domain adaptation are used to perform task-oriented fine-tuning based on labeled task data, cultivating domain task-solving capabilities. In stage 3, training methods such as reward function, PPO (Proximal Policy Optimization) training, and human preference learning are used to perform reinforcement alignment optimization based on interaction logs, aligning with domain business logic and constraints. In stage 4, training methods such as incremental learning mechanisms, domain knowledge replay, and drift detection and response are used to perform continuous domain evolution based on incremental data, adapting to dynamic changes in domain knowledge, and finally obtaining a domain expert model.
[0171] Furthermore, this includes evaluating the domain adaptation performance of the acquired domain expert models. Evaluation methods include using a static test set, i.e., the core domain benchmark (CDB); or a dynamic challenge set, which consists of monthly updated domain problems to reflect the latest domain status; or manual auditing, with expert sampling evaluation leveraging the experience and judgment of professionals; and A / B testing, comparing the new and old models online to visually demonstrate the performance differences between them. Evaluation metrics include, but are not limited to, domain understanding, task performance, rule compliance, and evolutionary capability. Domain understanding includes terminology accuracy and concept recall; rule compliance includes constraint violation rate and compliance score; and evolutionary capability includes knowledge freshness and forgetting rate.
[0172] Multi-agent collaborative system architecture, such as Figure 5 As shown. The specific operating steps include:
[0173] Step 1, Task Initialization: First, input content, such as requirement documents and page designs, is submitted to the large model via text input, image upload, or attachment upload. Next, the large model parses the input content, determining its type and length. If it's an image, the visual model is used for processing; if it's text, the text length and content are assessed, and if the input is long, it's broken down into multiple steps to form an execution plan. Then, based on the decomposed tasks, a coordinating agent is invoked, assigning a dedicated agent to each task and injecting contextual information, including but not limited to module specifications and association rules.
[0174] Step 2, code generation: For example, input the module's storage requirements into the basic settings agent; input the business rules into the core logic agent; input the API specifications into the interface adaptation agent, and automatically generate module code using the large model.
[0175] Step 3: Establish a collaboration mechanism among agents. This mechanism negotiates based on the critical path to ensure that agents can collaborate efficiently around the core process when executing tasks. Simultaneously, it resolves conflicts through real-time arbitration to promptly address any potential disagreements between agents.
[0176] Step 4: Establish a closed-loop verification and feedback system: Call the verification agent to perform code quality verification, and then optimize and iterate based on the verification results to improve system performance.
[0177] Step 5: Continuously optimize knowledge base synchronization to ensure that the information in the knowledge base is always up-to-date and accurate, providing reliable knowledge support for the agent's decision-making and execution.
[0178] In a preferred embodiment, such as Figure 12 As shown, step S4 includes: S41, submitting the generated module code; S42, analyzing the generated module code according to the preset code quality evaluation index system, determining the scores of each quality evaluation index, innovation score, and technical debt score, and summarizing them to obtain the quality evaluation score; S43, verifying whether the generated module code meets the standards based on the quality evaluation score; S44, deploying and releasing the generated module code if the verification meets the standards; S45, generating optimization suggestions based on the feedback from the verification failure using a pre-trained reinforcement learning model, and fixing the module code according to the optimization suggestions.
[0179] Specifically, in this embodiment, a continuously optimized code quality evaluation index system is established through a code quality optimization model based on reinforcement learning, thereby achieving dynamic quality evaluation and feedback optimization.
[0180] The code quality assessment index system is shown in Tables 7-9 below.
[0181] Table 7. Specific indicators and evaluation criteria for static quality indicators (static quality indicators account for 40%)
[0182]
[0183] Table 7 shows that the core idea of cyclomatic complexity calculation is to evaluate the complexity and testability of a program by calculating the number of linearly independent paths. Cyclomatic complexity M = number of decision points + 1. The more branch decision points (such as if, for, while, case, catch, &&, ||, etc.) there are in the code, the more possible execution paths the program can take, and the more complex the logic becomes.
[0184] Cognitive complexity aims to compensate for the shortcomings of cyclomatic complexity. Cognitive complexity increases with each level of nesting. The deeper the nesting, the greater the penalty. Execution statements such as `if`, `else if`, `else`, `for`, `while`, `do while`, `switch`, `catch`, anonymous functions / Lambda expressions, etc., all increase nesting levels. In Boolean expressions, combinations of multiple `&&` and `||` increase complexity. For example, using multiple consecutive `if` statements to handle mutual exclusion conditions instead of `else if` will not incur additional penalties, but cyclomatic complexity will increase. `break`, `continue`, and `goto` do not increase cognitive complexity.
[0185] Table 8. Specific indicators and evaluation criteria for dynamic quality indicators (dynamic quality indicators account for 35%)
[0186]
[0187] Table 9. Specific indicators and evaluation criteria for safety and reliability (safety and reliability indicators account for 25%)
[0188]
[0189] In a preferred embodiment, the method for determining the quality assessment score is as follows:
[0190]
[0191] Wherein, S1 represents the static quality indicator score; S2 represents the dynamic quality indicator score; S3 represents the safety and reliability indicator score; S4 represents the innovation score, 0-5 points; S5 represents the technical debt score, 0-10 points; W1, W2, and W3 represent the corresponding weights; and Total represents the quality assessment score.
[0192] like Figure 13 As shown, the entire software module development pipeline is automatically generated through training a large AI model and adding an agent.
[0193] Furthermore, this invention can control the generation granularity at the class level, rather than the module level. For example... Figure 14As shown, the implementation scheme includes the following steps: First, input business requirements; then, call the requirement decomposition engine to break down the input business requirements; after identifying class boundaries, perform class responsibility allocation, class structure generation, inter-class relationship constraints, and class-level verification in sequence, finally outputting class files to complete the class-level generation task. The layered generation control strategy includes domain layer class generation, application service layer generation, and infrastructure layer generation. Class granularity-level verification includes structural integrity checks and class relationship rationality checks. The class generation workflow is as follows: Figure 15 As shown.
[0194] Furthermore, this includes adding a security audit layer during code generation to build a security enhancement model. Additionally, it allows for automatic anonymization of sensitive operations to ensure data security and privacy.
[0195] Furthermore, to be suitable for small and medium-sized enterprises (SMEs), a lightweight single agent can be used to replace multi-agent collaboration, helping SMEs to respond quickly to market demands and enhance their competitiveness.
[0196] On the other hand, a business module source code generation system based on large-model business reasoning is provided to implement the aforementioned method for generating business module source code based on large-model business reasoning. The system includes: a semantic parsing module for semantically parsing business requirements and constructing a weighted business association graph; a module partitioning module connected to the semantic parsing module for partitioning modules based on the weighted business association graph, decomposing the complete task into multiple sub-tasks; a code generation module connected to the module partitioning module for invoking a coordinating agent to assign a corresponding large-model-based module code generation agent to each decomposed sub-task and injecting context information to generate the corresponding module code; wherein the module code generation agent has been pre-trained based on domain adaptive phased training to learn the correspondence between the task, the injected context information, and the code; and a code quality verification module connected to the code generation module for invoking a verification agent to verify the code quality of the generated module code.
[0197] The method and system of this invention support end-to-end generation from requirements and database table structure to code. Compared with the 75% accuracy rate of existing solutions, the accuracy rate of modular code generation is improved to 92%. Traditional solutions often take several hours to complete code generation, while the dynamic fine-tuning response speed of this invention is extremely fast, and can be completed in less than 5 minutes. At the same time, this invention reduces the workload of repetitive development, lowers system maintenance costs, shortens project delivery cycle, and saves enterprises a lot of time and resources.
[0198] The above are merely preferred embodiments of the present invention and are not intended to limit the implementation methods and protection scope of the present invention. Those skilled in the art should recognize that any equivalent substitutions and obvious changes made using the content of this specification and illustrations should be included within the protection scope of the present invention.
Claims
1. A method for generating source code for business modules based on large-model business reasoning, characterized in that, include: Step S1: Semantically analyze business requirements and construct a weighted business association graph; Step S2: Based on the weighted business association graph, the module is divided into multiple sub-tasks. Step S3: Invoke the coordinating agent to assign a corresponding module code generation agent based on the large model to each of the decomposed subtasks, and inject context information to generate the corresponding module code; wherein, the module code generation agent has been pre-trained based on domain adaptive phased training to learn the correspondence between the task and the injected context information and the code; Step S4: Invoke the verification agent to verify the code quality of the generated module code; Step S1 includes: Step S11: Extract business entities and the relationships between business entities from business requirements; Step S12: Analyze the business requirements and determine the weights of the relationships between business entities based on the frequency of interaction, co-occurrence frequency, business importance, dependency strength, and operational complexity. Step S13: Construct a weighted business association graph based on the business entities, the relationships between business entities, and their corresponding weights; The steps of the domain-adaptive phased training include: Based on domain text and general corpus, a domain-aware pre-training is performed on a general pre-trained model based on a large model to obtain the first intermediate model; Based on the labeled task data, the first intermediate model is fine-tuned in a task-oriented manner to obtain the second intermediate model; Based on the interaction logs, the second intermediate model is enhanced and aligned to obtain the third intermediate model; Based on incremental data, the third intermediate model is continuously evolved to obtain a domain expert model, and the module code generation agent based on the large model is constructed.
2. The method for generating source code of a business module based on large-model business reasoning according to claim 1, characterized in that, Step S3 includes: Invoke the workflow agent to coordinate the execution order of each agent in the multi-agent matrix and manage the code generation process; Invoke the basic settings agent to generate basic settings code based on module storage requirements; Call the database analysis agent to perform semantic analysis on the database table structure and extract database field information; The front-end development agent is invoked to generate front-end interface code containing front-end controls based on a preset development framework for the assigned subtasks, according to the database field information. Call the backend development agent to generate preset programming language code based on the internationalization tags and control constraints of the frontend controls; Invoke the core logic agent to generate core logic code based on preset business rules; The API is called to adapt the intelligent agent and generate the API adaptation layer code according to the preset API specification.
3. The method for generating source code of a business module based on large-model business reasoning according to claim 2, characterized in that, The steps for generating the internationalized label include: Extract field description information from the front-end control configuration file; Detect whether the field description information contains preset keywords; When a preset keyword is detected, the control type of the front-end control is determined based on the mapping relationship between the keyword and the control type. When no preset keyword is detected, the default text input box will be determined as the control type; Generate internationalization tags based on the determined control type; Output front-end controls configured with internationalized tags.
4. The method for generating source code of a business module based on large-model business reasoning according to claim 2, characterized in that, The steps for generating the preset programming language code include: Based on the internationalization tags of the front-end controls, the constraint metadata of the control constraints is parsed to determine the constraint type; Based on the preset verification function, the determined constraint type is verified; After the constraint type verification is passed, the corresponding code for the front-end control is generated to form the preset programming language code.
5. The method for generating source code of a business module based on large-model business reasoning according to claim 1, characterized in that, Step S4 includes: Based on the preset code quality assessment index system, the generated module code is analyzed to determine the scores of each quality assessment index, innovation score and technical debt score, and the quality assessment score is obtained by summarizing. The generated module code is verified to meet the standards based on the quality assessment score. Once the generated module code passes verification, it will be deployed and released. If the generated module code fails verification, optimization suggestions are generated based on the feedback from the failure to verify, and the module code is repaired according to the optimization suggestions.
6. The method for generating source code of a business module based on large-model business reasoning according to claim 5, characterized in that, The quality assessment indicators include static quality indicators, dynamic quality indicators, and safety and reliability indicators; The static quality metrics include one or more combinations of cyclomatic complexity, cognitive complexity, code duplication rate, file length, and coding standard compliance rate. The dynamic quality metrics include one or more combinations of row coverage, branch coverage, execution time, memory usage, and throughput; The security and reliability metrics include one or more combinations of the following: number of vulnerabilities, security scan score, anomaly rate, and recovery time.
7. The method for generating source code of a business module based on large-model business reasoning according to claim 5, characterized in that, The method for determining the quality assessment score is as follows: ; Wherein, S1 represents the static quality indicator score; S2 represents the dynamic quality indicator score; S3 represents the safety and reliability indicator score; S4 represents the innovation score; S5 represents the technical debt score; W1, W2, and W3 represent the corresponding weights; S total This indicates the quality assessment score.
8. A business module source code generation system based on large-model business reasoning, characterized in that, The method for generating source code for a business module based on large-model business reasoning as described in any one of claims 1-7 includes: The semantic parsing module is used to perform semantic parsing of business requirements and construct a weighted business association graph. The module partitioning module, connected to the semantic parsing module, is used to partition modules based on the weighted business association graph, decomposing the complete task into multiple sub-tasks. The code generation module, connected to the module partitioning module, is used to call the coordinating agent to assign a corresponding module code generation agent based on a large model to each of the decomposed subtasks, and inject context information to generate the corresponding module code; wherein, the module code generation agent has been pre-trained based on domain adaptive phased training to learn the correspondence between the task, the injected context information and the code; The code quality verification module is connected to the code generation module and is used to call the verification agent to verify the code quality of the generated module code.
Citation Information
Patent Citations
An efficient mobile application management website front-end development method and system
CN109032594A
Intelligent programming auxiliary method and system based on multi-mode AI language model
CN120315685A
Cited By
Knowledge enhanced agent data source integration method and system for low-code platform
CN122174953A
Method and system for knowledge-augmented agent data source integration for low-code platforms
CN122174953B