An agent-assisted and natural language understanding-based code automatic generation method

By using a three-layer architecture system assisted by intelligent agents, combined with natural language understanding and deep learning models, the system solves the code generation problem in complex business scenarios using low-code platforms and pure NLU generation tools, achieving efficient and controllable automatic code generation and improving the accuracy and logical consistency of the generated code.

CN122240082APending Publication Date: 2026-06-19WUHAN ENYI INTERNET TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
WUHAN ENYI INTERNET TECH CO LTD
Filing Date
2026-03-17
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing low-code platforms and pure natural language understanding code generation tools struggle to achieve efficient, convenient, and controllable code generation in complex business scenarios. Traditional platforms require users to manually configure complex logic, and pure NLU-generated code has poor controllability and chaotic logic, lacking effective verification, resulting in low development efficiency.

Method used

The system employs a three-layer architecture assisted by intelligent agents, comprising a requirement understanding layer, a logic planning layer, and an intelligent completion layer. Through intelligent agent scheduling, combined with natural language understanding and deep learning models, it achieves requirement understanding, logic planning, and code generation, with real-time verification and feedback, forming a collaborative system of "requirement understanding - logic planning - intelligent completion".

Benefits of technology

It achieves full automation from natural language input to automatic logic decomposition and generation of standardized code, improving the accuracy and controllability of code generation, avoiding the complex configuration of traditional platforms and the defects of NLU generation, and ensuring the logical consistency and syntactic correctness of the generated code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122240082A_ABST
    Figure CN122240082A_ABST
Patent Text Reader

Abstract

This invention discloses an automatic code generation method based on agent-assisted and natural language understanding. The method is implemented using a three-layer architecture system with agent scheduling. The system includes an agent, a requirement understanding layer, a logic planning layer, and an intelligent completion layer. The method comprises the following steps: receiving natural language code requirements input by a user; the agent calling the requirement understanding layer to process the natural language code requirements; the agent calling the logic planning layer to decompose and generate a corresponding business logic framework based on preset business scenario classification rules; and the agent calling the intelligent completion layer to perform syntax verification and logical consistency verification on the target code. This invention solves the technical problems of traditional low-code platforms requiring manual configuration of complex business logic, and the inconsistent user experience and poor controllability of pure natural language code generation tools by constructing a three-layer collaborative system of "requirement understanding-logic planning-intelligent completion".
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of automatic code generation technology, and more specifically to an automatic code generation method based on agent-assisted and natural language understanding. Background Technology

[0002] With the iteration of software development technology, low-code platforms and natural language-driven code generation tools have gradually become core means to improve development efficiency. However, existing technologies still have shortcomings and cannot meet users' needs for efficient, convenient and controllable code generation.

[0003] On the one hand, although traditional low-code platforms can provide basic code templates and visual configuration functions, for complex business scenarios, users still need to manually configure a large amount of business logic, module relationships and exception handling processes. This not only increases the user's operating costs, but also easily leads to code logic conflicts and runtime exceptions due to manual configuration errors. It cannot truly achieve the development goal of "zero code" or "less code", and has poor adaptability and flexibility. On the other hand, while code generation tools based solely on Natural Language Understanding (NLU) can directly generate code by receiving user natural language requirements, reducing user configuration, they suffer from inconsistent user experience and poor controllability. These tools often lack a systematic breakdown of business logic, resulting in code snippets that may significantly deviate from actual user needs. Furthermore, the code's hierarchical structure and module call relationships are often chaotic, making subsequent modification and optimization difficult. Simultaneously, the lack of effective verification and feedback mechanisms during the generation process makes it difficult to detect syntax errors and logical conflicts in real time. This renders the generated code unusable immediately, requiring extensive secondary modifications by the user, ultimately reducing development efficiency.

[0004] In existing technologies, some solutions attempt to combine agents with code generation or adopt multi-layer architectures to achieve requirement processing and code generation, but none of them have formed a three-layer collaborative system of "requirement understanding - logical planning - intelligent completion", nor have they achieved dynamic scheduling and closed-loop verification at each level through agents. They cannot simultaneously solve the problems of complex manual configuration and poor controllability of pure NLU code generation in traditional low-code platforms. Summary of the Invention

[0005] The present invention proposes an automatic code generation method based on agent assistance and natural language understanding, which can at least solve one of the technical problems in the background art.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: A method for automatic code generation based on agent-assisted natural language understanding is disclosed. This method is implemented using a three-layer architecture system with agent scheduling. The system includes an agent, a requirement understanding layer, a logic planning layer, and an intelligent completion layer. The agent is a central coordinating software module integrating state monitoring, decision scheduling, exception handling, and data iteration functions. The requirement understanding layer, logic planning layer, and intelligent completion layer are sequentially connected functional processing layers independently scheduled by the agent. The method includes the following steps: S1. Receive the user's input natural language code requirement. The intelligent agent calls the requirement understanding layer to process the natural language code requirement. The intelligent agent dynamically allocates computing resources to the requirement understanding layer based on the requirement complexity. The requirement complexity is determined using a quantitative scoring system, with evaluation indicators including the number of core functions, the number of performance constraints, the number of exception handling scenarios, and the complexity of the programming language. A total score ≤3 indicates a simple requirement, 4-7 indicates a medium requirement, and ≥8 indicates a complex requirement. Computing resources are allocated hierarchically according to requirement complexity: basic computing resources for simple requirements, medium computing resources for medium requirements, and high-order computing resources for complex requirements. Standardized requirement information is obtained after processing. S2. The intelligent agent invokes the logic planning layer, and based on the standardized requirement information, decomposes and generates the corresponding business logic framework according to the preset business scenario classification rules. The preset business scenario classification rules are divided into three categories according to the core software development scenarios: user interaction, data processing, and system operation and maintenance. Each scenario corresponds to a preset functional module decomposition rule. The business logic framework includes the hierarchical structure of the code, the core functional modules, and the calling relationship between each module. The logic planning layer feeds back the decomposition progress to the intelligent agent in real time. S3. The agent calls the intelligent completion layer to generate complete target code based on the business logic framework, combined with a preset code template library and a deep learning completion model based on the Transformer architecture. The deep learning completion model preloads programming language syntax rules and business logic association constraints. During the generation process of the intelligent completion layer, the functional matching degree and calling logic matching degree of the code snippet and the business logic framework are checked simultaneously. The matching degree must be ≥ the preset matching threshold. S4. The intelligent agent performs syntax and logical consistency checks on the target code. During the checks, it optimizes the weights and dimensions of the checks by incorporating similar error characteristics from the historical error case library, thereby improving the accuracy of the checks. If the checks pass, the target code is output. If the checks fail, an error classification algorithm is used to determine the error level and type. Requirement-related errors are returned to the requirement understanding layer, logic-related errors to the logic planning layer, and code-related errors to the intelligent completion layer for reprocessing until the checks pass. Simultaneously, the error information and correction plan are updated to the historical error case library.

[0007] As a preferred embodiment of the automatic code generation method based on agent-assisted and natural language understanding described in this invention, wherein: in step S1, the processing of natural language code requirements by the requirement understanding layer includes: S11. Perform semantic segmentation, part-of-speech tagging, and stop word removal on the natural language code requirements. The semantic segmentation adopts a domain-adaptive segmentation algorithm, which is specifically optimized for commonly used terms and abbreviations in the code domain to obtain preprocessed text. S12. Based on the natural language understanding model, perform intent recognition and demand extraction on the preprocessed text. The natural language understanding model introduces code domain pre-trained weights to obtain initial demand information. S13. Based on the preset domain knowledge base, the initial requirement information is standardized to obtain standardized requirement information containing functional requirements, performance requirements, and constraints. The standardized requirement information is used to provide clear input basis for the logic planning layer. The standardized requirement information is accompanied by requirement priority tags. The requirement priority tags are divided into three levels according to the degree of coreness: high, medium, and low. Core functions are high priority, auxiliary functions are medium priority, and format constraints are low priority, which are used as references for the logic planning layer when decomposing.

[0008] As a preferred embodiment of the automatic code generation method based on agent-assisted and natural language understanding described in this invention, wherein: in step S2, the process of generating a business logic framework by the logic planning layer includes: S21. The intelligent agent decomposes the standardized requirement information into multiple independent functional sub-requirements. During the decomposition process, a clustering algorithm based on business scenarios is adopted. The clustering algorithm takes the business scenario as the cluster center, the semantic similarity of the functional sub-requirements as the clustering index, and adopts the K-means clustering algorithm with a clustering threshold of 0.8 to ensure a balance between the independence and correlation of the functional sub-requirements. Each functional sub-requirement corresponds to a core functional module. S22. Based on the relationship between the functional sub-requirements and the requirement priority tags, determine the hierarchical structure of each core functional module and the calling logic between modules. Add an exception jump branch design to the calling logic to generate the initial logic framework. S23. Perform a rationality check on the initial logic framework. The check indicators include module redundancy rate and call logic conflict rate. The module redundancy rate = number of redundant modules / total number of modules, with a pass threshold of ≤5%. The call logic conflict rate = number of conflicting branches / total number of branches, with a pass threshold of 0. Remove redundant modules and conflicting call logic to obtain the final business logic framework. The business logic framework corresponds to the standardized requirement information and is accompanied by a logic check report.

[0009] As a preferred embodiment of the automatic code generation method based on agent-assisted and natural language understanding described in this invention, wherein: in step S3, the process of generating target code by the intelligent completion layer includes: S31. Based on the core functional modules and requirement priority tags in the business logic framework, the corresponding basic code templates are matched from the preset code template library. The matching process adopts a template similarity sorting algorithm, which uses the matching degree of business scenario, programming language and functional module as the calculation dimension, and sorts them in descending order of comprehensive similarity. The templates that best match the constraints of business scenario and programming language are matched first. The basic code templates contain the basic syntax structure corresponding to the module. S32. Using a deep learning completion model, combined with the standardized requirement information and the calling relationship of the business logic framework, parameter filling and logic completion are performed on the basic code template. During the filling process, abnormal jump branches between modules are automatically adapted to generate initial code. S33. Redundant code is removed and format is standardized in the initial code. The format standardization follows the industry standards of the corresponding programming language and the user's preset format requirements to obtain complete target code. The target code is consistent with the logic of the business logic framework and the redundancy rate is lower than a preset threshold. The preset threshold is 1% by default for Python and 1.5% by default for Java. The adjustable range is 0.5%-3%.

[0010] As a preferred embodiment of the automatic code generation method based on agent-assisted and natural language understanding described in this invention, the agent employs a multi-module collaborative control mechanism. This mechanism includes: receiving real-time processing status data from the requirement understanding layer, logic planning layer, and intelligent completion layer; adjusting the processing priority of each layer based on the processing status data and requirement complexity using a dynamic priority scheduling algorithm; the dynamic priority scheduling algorithm follows the rule that the priority of unstarted layers is lower than that of layers in processing, and the priority of abnormal layers is temporarily increased to the highest level; when a processing abnormality occurs in a certain layer, the agent triggers an abnormality handling mechanism, suspending the current layer's processing and feeding back the abnormality information. Simultaneously, it calls the corresponding layer's backup processing strategy according to the abnormality type. The abnormality types are divided into fatal and non-fatal abnormalities. Fatal abnormalities include model crashes and insufficient computing resources, corresponding to triggering a local backup model call mode; non-fatal abnormalities include substandard processing efficiency and non-fatal syntax errors, corresponding to triggering a simplified adaptation mode for processing steps. This ensures that the three-layer system collaboratively advances the code generation process, and the entire abnormality handling process is recorded in the system log.

[0011] As a preferred embodiment of the code automatic generation method based on intelligent agent assistance and natural language understanding described in this invention, the domain knowledge base contains commonly used requirement terms, functional module definitions, and logical association rules in multiple technical fields, which are stored according to technical fields and accompanied by update timestamps; the domain knowledge base is updated in real time through intelligent agents, and the update triggering conditions include three scenarios: completion of new requirement processing, user feedback optimization, and industry technology iteration. The update data comes from historically processed natural language requirements, corresponding standardized requirement information, and the latest industry technical documents. After the update, the consistency of the knowledge base is automatically verified, duplicate and conflicting content is eliminated, and the accuracy of requirement understanding is continuously improved.

[0012] As a preferred embodiment of the automatic code generation method based on agent-assisted and natural language understanding described in this invention, the deep learning completion model adopts an improved model based on the Transformer architecture. This improved model introduces a code syntax constraint layer and a logical association layer. The code syntax constraint layer preloads syntax rules from multiple programming languages, converts these rules into regular expressions, and performs real-time validation on each line of code during the code completion process to intercept syntax errors. The logical association layer combines the call relationships and exception jump branches of the business logic framework to construct a logical association matrix between code segments. The logical association matrix uses core functional modules as its rows and columns, with matrix elements representing the call relationship weights between modules. 0 indicates no call, 1 indicates a direct call, and 0.5 indicates an indirect call. The matrix weights are dynamically updated in conjunction with exception jump branches to avoid generating code snippets with logical conflicts. Simultaneously, the model is optimized using the INT8 quantization scheme. This improves the efficiency and accuracy of code completion while maintaining a model accuracy loss of no more than 5%. The completion response time is controlled within a preset range: ≤0.3 seconds for simple requirements, ≤0.5 seconds for medium requirements, and ≤1 second for complex requirements. The adjustable range is 0.1 seconds to 2 seconds.

[0013] As a preferred embodiment of the automatic code generation method based on agent-assisted and natural language understanding described in this invention, in step S4: the syntax verification adopts a preset code syntax rule library, which is classified according to programming language; the logical consistency verification adopts a predicate logic-based logical deduction algorithm, which transforms the call relationship of the business logic framework into a predicate logic formula, and transforms the logical flow of the target code into a corresponding predicate logic sequence. The consistency verification is completed through the resolution principle, verifying whether the call logic and exception handling logic of each module in the target code are consistent with the business logic framework; if the verification fails, the agent determines the error level and error type based on the verification error information through an error classification model based on the Naive Bayes algorithm. The classification dimensions include error level and error type. The error level is divided into requirement understanding layer, logic planning layer, and intelligent completion layer. The error type is divided into syntax error, logic conflict, requirement matching error, and format error. The corresponding processing steps are returned for reprocessing, and the error type, processing scheme, and processing result are recorded for optimizing the subsequent code generation process and updating the historical error case library.

[0014] As a preferred embodiment of the automatic code generation method based on agent assistance and natural language understanding described in this invention, the method further includes step S5: receiving user feedback on modifications to the output target code; the agent, through a feedback intent recognition model, classifies the modification feedback information into three categories: requirement adjustment instructions, logic adjustment instructions, and format adjustment instructions, which are respectively sent to the requirement understanding layer, logic planning layer, and intelligent completion layer; the corresponding layers update the processing results according to the priority of the adjustment instructions, regenerate the target code, compare the differences between the code before and after the adjustment, and generate a difference report for user confirmation, thereby realizing interactive optimization of code generation.

[0015] As a preferred embodiment of the automatic code generation method based on intelligent agent assistance and natural language understanding described in this invention, the method supports automatic code generation in multiple programming languages. The preset code template library contains basic templates for multiple programming languages ​​and is stored in a dual category of programming language and business scenario. The intelligent completion layer matches the corresponding template and generates target code in the corresponding programming language based on the programming language constraints in the standardized requirement information and the template similarity threshold. The programming languages ​​include at least two of Java, Python, and C++, and support dynamic expansion of programming languages. When expanding, the corresponding programming language's syntax rule library and basic template are added.

[0016] The beneficial effects of this invention are: 1. By using a three-layer collaborative system of "requirement understanding - logical planning - intelligent completion" and combining it with the collaborative scheduling of intelligent agents, we can avoid the problem of users having to manually configure complex business logic in traditional low-code platforms, and solve the defects of pure natural language code generation tools such as inconsistent experience and poor controllability. We can achieve full-process automation of "natural language input - automatic logic decomposition - standardized code generation".

[0017] 2. Significantly improved accuracy and controllability of code generation: The requirement understanding layer adopts a domain-adaptive word segmentation algorithm and a code domain pre-trained model, combined with a domain knowledge base that can be updated in real time, to ensure the accuracy of requirement extraction; the logic planning layer decomposes functional sub-requirements through clustering algorithms, adds abnormal jump branches, and performs rationality checks to ensure the standardization and rationality of the business logic framework; the improved Transformer model of the intelligent completion layer introduces a syntax constraint and logical association layer to avoid syntax errors and logical conflicts, while simultaneously checking the matching degree between code snippets and the logical framework during the generation process. Attached Figure Description

[0018] Figure 1 This is a flowchart illustrating the method steps of the automatic code generation method based on agent-assisted and natural language understanding of the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, 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 some embodiments of the present invention, but not all embodiments.

[0020] like Figure 1 As shown, this embodiment of the invention provides a method for automatic code generation based on agent-assisted and natural language understanding. The core architecture is a three-layer collaborative system of agent scheduling: "requirement understanding - logical planning - intelligent completion," wherein: The intelligent agent is an integrated central coordination software module, specifically including: (1) Status monitoring unit: responsible for collecting the processing progress, status data and abnormal information of the requirement understanding layer, logic planning layer and intelligent completion layer in real time, and updating them synchronously to the decision scheduling unit. The sampling frequency is 100ms / time. (2) Decision scheduling unit: It has a built-in requirement complexity assessment model and dynamic priority scheduling algorithm. It is responsible for receiving status data from the status monitoring unit, assessing requirement complexity, allocating computing resources at each level, adjusting the processing priority at each level, and issuing scheduling instructions to the corresponding level. (3) Exception handling unit: It has a built-in exception classification model and backup handling strategy library. It is responsible for identifying the exception information reported at each level, determining the exception type and level, triggering the corresponding exception handling strategy, and synchronously recording the entire exception handling process to the system log. (4) Data Iteration Unit: Responsible for updating and managing the domain knowledge base, historical error case library, and code template library, triggering update verification, and ensuring the consistency and timeliness of the knowledge base and case library.

[0021] The interaction process between the agent and each level is as follows: the agent issues scheduling instructions to the corresponding level → the corresponding level executes the processing and provides real-time feedback on status data → the agent monitors the processing status and dynamically adjusts the scheduling strategy → after processing is completed, the agent triggers the scheduling instructions of the next level to achieve coordinated advancement of the entire process.

[0022] The historical error case database uses structured data storage. Each case data includes: error ID, error type, error level, error code snippet, error cause, correction plan, correction result, requirement scenario, and processing time. The update rules for the case library are as follows: (1) Incremental update: After each code generation and verification is completed, if a new error type or a new correction plan appears, the corresponding data will be automatically extracted and added to the case library; (2) Optimization and Update: After the code errors reported by users are reviewed and confirmed to be valid, the error information and optimization solutions are added to the case library; (3) Regular cleanup: Clean up duplicate and invalid cases in the case library every quarter, optimize the weight of the correction scheme for high-frequency error cases, and improve the verification accuracy; The case library supports searching by error type, level, programming language, and business scenario, providing a basis for error feature matching in the verification process.

[0023] The steps of the method of the present invention are as follows: S1. Receive the natural language code requirement input by the user, and have the intelligent agent call the requirement understanding layer to process the natural language code requirement; the intelligent agent dynamically allocates the computing resources of the requirement understanding layer based on the requirement complexity, and obtains standardized requirement information after processing; The unified standard for judging the complexity of requirements is as follows: a quantitative scoring system is adopted, with a total score of 10 points. The judging indicators include the number of core functions (1-4 functions, 1-4 points), the number of performance constraints (1 constraint, 1 point), the number of exception handling scenarios (1 scenario, 1 point), and the complexity of programming languages ​​(simple languages ​​such as Python, 1 point; medium languages ​​such as Java, 2 points; complex languages ​​such as C++, 3 points). A total score of ≤3 points indicates a simple requirement, 4-7 points indicates a medium requirement, and ≥8 points indicates a complex requirement. The rules for allocating computing resources are as follows: basic computing resources are allocated for simple needs, with CPU utilization ≤20% and memory usage ≤2GB; medium computing resources are allocated for medium needs, with CPU utilization 20%-40% and memory usage 2GB-4GB; and high-level computing resources are allocated for complex needs, with CPU utilization 40%-60% and memory usage 4GB-8GB.

[0024] The specific processing steps of the requirements understanding layer are as follows: S11. Perform semantic segmentation, part-of-speech tagging, and stop word removal on the natural language code requirements. Semantic segmentation adopts a domain-adaptive segmentation algorithm, which is specifically optimized for commonly used terms and abbreviations in the code domain to obtain preprocessed text. The complete implementation steps of the domain-adaptive word segmentation algorithm are as follows: Step 1: Build a code domain terminology dictionary, which includes programming language keywords, technical terms, common abbreviations, and compound functional terms. Each term is marked with its part of speech and applicable domain. The dictionary supports incremental updates. Step 2: Based on the jieba word segmentation framework, load the code domain terminology dictionary and use the bidirectional maximum matching algorithm to perform initial word segmentation on the input natural language requirement text; Step 3: Perform abbreviation identification on the initial word segmentation results. For abbreviations that do not match the dictionary, perform terminology completion and annotation based on contextual semantics to avoid missegmentation. Step 4: Perform overall matching verification on compound technical terms. If the word segmentation result splits the compound term into multiple sub-words, and the combination of sub-words matches the compound term in the dictionary, then merge them into a complete term. Step 5: Perform part-of-speech tagging and stop word removal on the word segmentation results, remove modal words and conjunctions without actual semantic meaning, and finally output the preprocessed text; The algorithm achieves a word segmentation accuracy of ≥98% and a code domain terminology recognition accuracy of ≥99%.

[0025] S12. Based on a natural language understanding model that incorporates pre-trained weights from the code domain, intent recognition and requirement extraction are performed on pre-processed text to improve the accuracy of extracting functional requirements and constraints, and to obtain initial requirement information. S13. Based on the pre-set domain knowledge base, the initial requirement information is standardized to obtain standardized requirement information that includes functional requirements, performance requirements and constraints. The standardized requirement information is accompanied by requirement priority tags for reference when the logic planning layer decomposes the requirement information.

[0026] S2. The intelligent agent calls the logic planning layer, which, based on the standardized requirement information and combined with the preset business scenario classification rules, decomposes and generates the corresponding business logic framework. The business logic framework includes the hierarchical structure of the code, the core functional modules and the calling relationship between each module, and the logic planning layer feeds back the decomposition progress to the intelligent agent in real time. The pre-defined business scenario classification rules are as follows: based on the core scenarios of software development, they are divided into three categories: user interaction, data processing, and system operation and maintenance. Each category corresponds to a pre-defined functional module decomposition rule. For example, user interaction scenarios are preferentially decomposed into input modules, validation modules, and prompt modules. The rules can be updated in real time through intelligent agents combined with industry technology iterations to ensure adaptation to various new business scenarios.

[0027] The process of generating the business logic framework from the logic planning layer is as follows: S21. The intelligent agent decomposes the standardized requirement information into multiple independent functional sub-requirements. During the decomposition process, a clustering algorithm based on business scenarios is used to ensure a balance between the independence and relevance of the functional sub-requirements. Each functional sub-requirement corresponds to a core functional module. The clustering algorithm used is the K-means clustering algorithm, which is an existing technology and has not been improved. It will not be described in detail here. S22. Based on the relationship between the functional sub-requirements and the requirement priority tags, determine the hierarchical structure of each core functional module and the calling logic between modules. Add an exception jump branch design to the calling logic to generate the initial logic framework. S23. Perform a rationality check on the initial logic framework. The check indicators include module redundancy rate and call logic conflict rate. Eliminate redundant modules and conflicting call logic to obtain the final business logic framework. The business logic framework corresponds to the standardized requirement information and is accompanied by a logic check report.

[0028] S3. The agent calls the intelligent completion layer, which generates complete target code based on the business logic framework, combined with a preset code template library and a deep learning completion model. During the generation process of the intelligent completion layer, the matching degree between the code snippet and the business logic framework is verified simultaneously. The process of generating target code using the intelligent completion layer is as follows: S31. Based on the core functional modules and requirement priority tags in the business logic framework, the corresponding basic code templates are matched from the preset code template library and stored in dual categories of programming language and business scenario. The matching process adopts a template similarity sorting algorithm, giving priority to matching the templates that best fit the business scenario and programming language constraints. The basic code templates contain the basic syntax structure corresponding to the module. S32. Using a deep learning completion model, combined with standardized requirement information and the calling relationship of the business logic framework, parameter filling and logic completion are performed on the basic code template. During the filling process, abnormal jump branches between modules are automatically adapted to generate initial code. S33. Redundant code is removed and format is standardized from the initial code. The format standardization follows the industry standards of the corresponding programming language and the user's preset format requirements to obtain complete target code. The target code is consistent with the logic of the business logic framework and the redundancy rate is lower than the preset threshold.

[0029] S4. The agent performs syntax and logic consistency checks on the target code. During the check, it optimizes the check accuracy by combining the historical error case library. If the check passes, the target code is output. If the check fails, the agent accurately returns to the corresponding level according to the error type for reprocessing until the check passes. At the same time, the error information is updated to the historical error case library.

[0030] Furthermore, the method also includes step S5: receiving user feedback on modifications to the output target code. The intelligent agent uses a feedback intent recognition model to classify the modification feedback into three categories: requirement adjustment instructions, logic adjustment instructions, and format adjustment instructions. These are then sent to the requirement understanding layer, logic planning layer, and intelligent completion layer, respectively. The corresponding layers update the processing results according to the priority of the adjustment instructions, regenerate the target code, compare the differences between the code before and after the adjustment, and generate a difference report for user confirmation, thus achieving interactive optimization of code generation.

[0031] Furthermore, the method supports automatic code generation in multiple programming languages. The preset code template library contains basic templates for various programming languages ​​and is stored in a dual category of programming language and business scenario. The intelligent completion layer can match the corresponding template and generate target code in the corresponding programming language based on the programming language constraints in the standardized requirements information and the template similarity threshold. The programming languages ​​include at least two of Java, Python, and C++, and dynamic expansion of programming languages ​​is supported. When expanding, only the syntax rule library and basic template of the corresponding programming language need to be added, without modifying the core logic of the three-layer system.

[0032] The specific implementation examples are as follows: Example 1: Generating Python user login verification code: Step S1: Natural language processing to obtain standardized requirement information. 1. Requirement for receiving natural language code input from users: The user inputs "Generate a Python user login verification code that includes account and password verification, encrypted password storage, error message prompts (account not found, password incorrect), and response time not exceeding 0.5 seconds".

[0033] 2. Allocating computing resources to the agent: The agent assesses the complexity of the requirement, which includes two core functions, one performance constraint, and two exception handling scenarios. It is determined to be of medium complexity, and medium-priority computing resources are dynamically allocated to the requirement understanding layer to ensure processing efficiency.

[0034] 3. Requirements understanding layer processing: S11. Preprocessing: Adopting a domain-adaptive word segmentation algorithm, semantic word segmentation, part-of-speech tagging, and stop word removal are performed on natural language requirements. Specialized word segmentation is performed on commonly used code domain terms such as "Python", "account password verification", and "password encrypted storage" to obtain the preprocessed text: "Python language, user login verification code, account password verification, password encrypted storage, exception prompt, account does not exist, password error, response time ≤ 0.5 seconds".

[0035] The specific implementation of the domain-adaptive word segmentation algorithm is as follows: Based on the jieba word segmentation framework, an improved code domain terminology dictionary is introduced, which includes programming language keywords, technical terms, and common abbreviations. A bidirectional maximum matching algorithm is used for word segmentation, and a dynamic completion strategy based on contextual semantics is adopted for new terms not included in the dictionary. The word segmentation accuracy is ≥98%. The specific optimizations are as follows: Commonly used abbreviations in the code domain, such as "NLU", "API", and "MD5", are individually labeled to avoid missegmentation. Composite technical terms, such as "account password verification" and "password encryption storage", are matched as a whole to ensure the integrity of word segmentation.

[0036] S12. Intent Recognition and Requirement Extraction: Based on a natural language understanding model that incorporates domain-specific pre-trained weights from Python code, intent recognition is performed on the pre-processed text. The intent is "generate Python login verification code". Initial requirement information is extracted: the programming language is Python, the functional requirements are account and password verification, encrypted password storage, error message (account does not exist, password is incorrect), and the performance requirement is response time ≤ 0.5 seconds.

[0037] S13. Standardization Processing: Combining the pre-set code domain knowledge base, including Python login verification-related terminology definitions, functional module association rules, and update timestamps, the initial requirement information is standardized to obtain standardized requirement information, and requirement priority tags are added. Functional requirement priority: account password verification > password encryption and storage > exception prompts. Performance requirement priority: Response time ≤ 0.5 seconds. Standardized requirement information is as follows: [Programming language: Python; Functional requirements: 1. Account and password verification, 2. Password encrypted storage using MD5 encryption, 3. Error message: if the account does not exist, output "Account does not exist, please re-enter", if the password is incorrect, output "Incorrect password, 2 more attempts"; Performance requirement: Response time ≤ 0.5 seconds; Constraints: Code format follows PEP8 standard].

[0038] 4. Domain Knowledge Base Update: After this requirement is processed, the agent triggers a knowledge base update, updating the knowledge base with new information such as "Python login verification MD5 encryption" and "abnormal prompt text specifications", and automatically checks the consistency of the knowledge base to ensure the accuracy of subsequent similar requirement processing.

[0039] Step S2: The logic planning layer generates the business logic framework. 1. The agent calls the logic planning layer. The logic planning layer combines the preset "user verification" business scenario classification rules to start breaking down standardized requirement information and provides real-time feedback on the breakdown progress, such as "account password verification function has been broken down" and "determining module association relationship" to the agent.

[0040] 2. Logical framework generation process: S21. Functional Sub-requirement Decomposition: Using a clustering algorithm based on business scenarios, standardized requirement information is decomposed into 3 independent and related functional sub-requirements, corresponding to 3 functional modules: ① Account and Password Input Module, which receives the account and password input by the user; ② Verification and Encryption Module, which realizes account existence verification, password MD5 encryption, and password correctness verification; ③ Anomaly Prompt and Response Module, which realizes anomaly prompt output and response time control.

[0041] The specific implementation of the business scenario-based clustering algorithm is as follows: taking the business scenario type, such as user verification, order query, and data statistics, as the cluster center, and the semantic similarity of the functional sub-requirements as the clustering index, the K-means clustering algorithm is adopted, with the clustering threshold set to 0.8. Requirements with semantic similarity ≥ 0.8 are grouped into the same category. By calculating the cosine similarity between each requirement keyword and the cluster center, the functional sub-requirements are accurately decomposed, ensuring that the decomposed sub-requirements are independent and have no functional overlap.

[0042] S22. Module hierarchy and calling logic determination: Based on the relationship between each functional sub-requirement and the requirement priority tags, the hierarchical structure is determined as follows: account and password input module - verification and encryption module - exception prompt and response module. An exception jump branch is added to the calling logic. For example, if the verification and encryption module determines that the account does not exist, it jumps to the exception prompt and response module to output the corresponding prompt; if the password is wrong, it jumps to the exception prompt module and records the number of attempts, thus generating the initial logic framework.

[0043] S23. Reasonableness Verification: Verify the initial logic framework. The verification indicator is the module redundancy rate. In this case, the redundancy rate is 0, meaning there are no redundant modules. The logic call conflict rate is also 0, meaning there are no conflicting logic calls. After the verification passes, the final business logic framework is obtained, and a logic verification report is generated, clearly defining the framework hierarchy, module relationships, and abnormal branch design. The verification result is considered qualified.

[0044] Step S3: Generate target code from the intelligent completion layer: 1. The agent calls the intelligent completion layer. During the generation process, the intelligent completion layer synchronously verifies the matching degree between each code snippet and the business logic framework to ensure that the code and the logic framework are consistent.

[0045] 2. Code generation process: S31. Template Matching: Based on the three core functional modules of the business logic framework and the requirement priority tags, basic templates related to "user login verification" in Python language are matched from the preset code template library and stored in dual categories of programming language and business scenario. The template similarity sorting algorithm is used to prioritize matching templates that contain account password verification and exception prompt functions. These templates contain basic syntax structures, such as function definitions and input / output statements.

[0046] S32. Parameter Filling and Logic Completion: Utilizing an improved deep learning completion model based on the Transformer architecture, combined with standardized requirement information and the calling relationships of the business logic framework, parameters are filled into the basic template, such as MD5 encryption functions, exception prompt text, and response time control parameters. During the filling process, exception jump branches are automatically adapted, such as adding if-else conditional statements to implement exception jumps, and initial code is generated.

[0047] The improved model's code syntax constraint layer preloads Python language PEP8 syntax rules to intercept syntax errors in real time, such as avoiding indentation errors and non-standard variable naming; the logical association layer combines the call relationships and exception branches of the business logic framework to build a logical association matrix between code segments, ensuring logical coherence between the encryption module, verification module, and exception prompting module, and avoiding logical conflicts.

[0048] The specific implementation logic of the code syntax constraint layer is as follows: preload the syntax rule library of each programming language, convert the syntax rules into regular expressions, and perform regular expression matching on each generated code snippet during code completion. If a syntax error is matched, such as non-standard indentation, missing semicolons, or undefined variables, it is intercepted and corrected in real time, with the correction priority following "syntactic correctness > format standardization". The logical association matrix of the logical association layer is constructed as follows: the core functional modules are the rows and columns of the matrix, and the matrix elements are the call relationship weights between modules. 0 represents no call, 1 represents a direct call, and 0.5 represents an indirect call. Combined with exception jump branches, the matrix weights are dynamically updated to ensure that the generated code snippets conform to the call relationships in the matrix and avoid logical conflicts. The model quantization optimization specifically adopts the INT8 quantization scheme to quantize the model weights and activation values ​​to improve the completion response speed.

[0049] S33. Formatting and Redundancy Removal: Redundant code is removed from the initial code. Unnecessary comments and variables in the template are deleted. The format is standardized to follow the PEP8 standard. Indentation, variable naming, and comment format are adjusted to obtain the complete target code.

[0050] Step S4: Agent loop closure verification, output target code: 1. The agent performs double verification on the target code, incorporating a historical error case library during the verification process. This library includes syntax errors and logical conflicts from past Python login verification code, optimizing verification accuracy. (1) Syntax verification: The Python syntax rule library, which is classified by programming language, is used to verify the syntax correctness of the target code in real time by synchronizing the Python 3.10 version syntax update. No syntax errors were found in this verification.

[0051] (2) Logical consistency verification: The predicate logic-based logical deduction algorithm is adopted. Based on the call relationship and exception jump branch of the business logic framework, the algorithm verifies whether the call logic and exception handling logic of each module in the target code are consistent with the framework. For example, it verifies whether the jump to the exception prompt module is correct when "account does not exist" and whether the password encryption uses the MD5 algorithm. No logical conflicts were found in this verification. The specific implementation of the predicate logic-based logical deduction algorithm is as follows: the call relationship of the business logic framework is converted into a predicate logic formula. For example, "if the account does not exist, call the exception prompt module" is converted into "account exists - call the exception prompt module". The logical flow of the target code is converted into the corresponding predicate logic sequence. Logical deduction is performed through the reduction principle. If the deduction result is consistent with the predicate formula of the logical framework, the verification is passed. The specific implementation of the error classification algorithm is as follows: a classification model is built based on the error type. The classification dimensions include error level, requirement understanding layer, logical planning layer, intelligent completion layer, and error type, such as syntax error, logical conflict, redundant error, and format error. The Naive Bayes algorithm is used for classification to ensure that the error can be accurately located to the corresponding level.

[0052] 2. After successful verification, the agent outputs the target code; at the same time, the current requirement processing process, code generation result, and verification result are recorded in the system log, and error types that did not occur this time are added to the historical error case library to provide data support for subsequent optimization.

[0053] Step S5: Interactive optimization, this step is optional: After reviewing the output target code, the user requests modification feedback: "Change the password encryption method to SHA-256, and change the exception message to a pop-up window." The agent, using a feedback intent recognition model, categorizes this feedback into: logic adjustment instructions, password encryption method modification instructions, format adjustment instructions, and exception message format modification instructions. These are then sent to the verification and encryption module, the logic planning layer, the exception message and response module, and the intelligent completion layer, respectively. The corresponding modules update their processing results based on the priority of the adjustment instructions (logic adjustment > format adjustment), regenerate the target code, compare the differences between the generated and modified code, and generate a difference report specifying the modifications: the encryption method is changed from MD5 to SHA-256, and the exception message is changed from a print statement to a tkinter pop-up window for user confirmation. After the user confirms that everything is correct, the final target code is output.

[0054] Example 2: Multi-programming language extensions and exception handling The difference between this embodiment and Embodiment 1 is that the user requirement is to "generate Java code for order querying, supporting querying order information based on order number, including exception prompts for empty order number and non-existent order," and an exception occurs during the decomposition of the logic planning layer, resulting in a conflict in module call logic. The specific implementation process is as follows: 1. Step S1: Natural language requirement processing to obtain standardized requirement information, wherein the programming language constraint is Java, the functional requirements are order number query and exception prompt, and the standardized requirement information is accompanied by requirement priority tags.

[0055] 2. Step S2: During the decomposition of the logic planning layer, a module call logic conflict occurs, specifically a conflict in the call order between the order query module and the exception notification module. The logic planning layer feeds back the exception information to the agent in real time. The agent triggers the exception handling mechanism, suspends the logic planning layer processing, and feeds back the exception information: "Module call logic conflict: The order query module and the exception notification module are called in the wrong order." Simultaneously, based on the exception type and logic conflict, the agent invokes the backup handling strategy and the local backup logic planning model, re-decomposes the standardized requirement information, adjusts the module call order, and prioritizes the exception notification module, first verifying whether the order number is empty before calling the order query module. After resolving the conflict, the final business logic framework is generated.

[0056] 3. Step S3: The intelligent completion layer matches the basic templates related to "order query" in Java language from the preset code template library, and generates the initial code by combining the improved deep learning completion model. After format normalization and redundancy removal, the target code is obtained.

[0057] 4. Step S4: The agent verifies the target code and outputs it after passing the verification. If the user needs to extend it to C++ language later, they only need to add the basic template for order query in C++ language to the preset code template library and add C++ syntax rules to the syntax rule library. The order query code in C++ language can be generated without modifying the core logic of the three-layer system.

[0058] Both of the above embodiments are implemented strictly in accordance with the technical solution of the present invention, verifying the feasibility and effectiveness of the method of the present invention. Embodiment 1 demonstrates the entire process of generating Python code in a conventional scenario, including requirement processing, logic planning, code completion, closed-loop verification, and interactive optimization, reflecting the convenience, controllability, and accuracy of the method of the present invention; Embodiment 2 demonstrates a scenario with support for multiple programming languages ​​and exception handling, reflecting the flexibility, stability, and scalability of the method of the present invention.

[0059] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0060] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0061] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An agent-assisted and natural language understanding based code generation method, characterized in that, This method is implemented based on a three-layer architecture system of agent scheduling. The system includes an agent, a demand understanding layer, a logic planning layer, and an intelligent completion layer. The agent is a central coordination software module integrating state monitoring, decision scheduling, exception handling, and data iteration functions. The demand understanding layer, logic planning layer, and intelligent completion layer are sequentially connected functional processing layers that are independently scheduled by the agent. The method includes the following steps: S1. Receive the user's input natural language code requirement, and have the intelligent agent call the requirement understanding layer to process the natural language code requirement; the intelligent agent dynamically allocates the computing resources of the requirement understanding layer based on the requirement complexity, the requirement complexity is determined by a quantitative scoring system, and standardized requirement information is obtained after processing. S2. The intelligent agent calls the logic planning layer, which, based on the standardized requirement information and combined with preset business scenario classification rules, decomposes and generates the corresponding business logic framework; the business logic framework includes the hierarchical structure of the code, core functional modules and the calling relationship between each module, and the logic planning layer feeds back the decomposition progress to the intelligent agent in real time. S3. The agent calls the intelligent completion layer to generate complete target code based on the business logic framework, combined with a preset code template library and a deep learning completion model based on the Transformer architecture. The deep learning completion model preloads programming language syntax rules and business logic association constraints. During the generation process of the intelligent completion layer, the functional matching degree and calling logic matching degree of the code snippet and the business logic framework are checked simultaneously. The matching degree must be ≥ the preset matching threshold. S4. The intelligent agent performs syntax verification and logical consistency verification on the target code. If the verification passes, the target code is output. If the verification fails, the error classification algorithm is used to determine the level and type of the error. Requirement-related errors are returned to the requirement understanding layer, logic-related errors are returned to the logic planning layer, and code-related errors are returned to the intelligent completion layer for reprocessing until the verification passes. At the same time, the error information and correction plan are updated to the historical error case library.

2. The method of claim 1, wherein the agent-based assistance and natural language understanding based code generation method is characterized by: In step S1, the process of the requirement understanding layer processing the natural language code requirement includes: S11. Perform semantic segmentation, part-of-speech tagging, and stop word removal on the natural language code requirements. The semantic segmentation adopts a domain-adaptive segmentation algorithm, which is specifically optimized for commonly used terms and abbreviations in the code domain to obtain preprocessed text. S12. Based on the natural language understanding model, perform intent recognition and demand extraction on the preprocessed text. The natural language understanding model introduces code domain pre-trained weights to obtain initial demand information. S13. Based on the preset domain knowledge base, the initial requirement information is standardized to obtain standardized requirement information containing functional requirements, performance requirements, and constraints. The standardized requirement information is used to provide clear input basis for the logic planning layer. The standardized requirement information is accompanied by requirement priority tags. The requirement priority tags are divided into three levels according to the degree of coreness: high, medium, and low. Core functions are high priority, auxiliary functions are medium priority, and format constraints are low priority, which are used as references for the logic planning layer when decomposing.

3. The code automatic generation method based on agent-assisted and natural language understanding according to claim 1, characterized in that: In step S2, the process of the logic planning layer generating the business logic framework includes: S21. The intelligent agent decomposes the standardized requirement information into multiple independent functional sub-requirements. During the decomposition process, a clustering algorithm based on business scenarios is adopted. The clustering algorithm takes the business scenario as the cluster center and the semantic similarity of the functional sub-requirements as the clustering index. Each functional sub-requirement corresponds to a core functional module. S22. Based on the relationship between the functional sub-requirements and the requirement priority tags, determine the hierarchical structure of each core functional module and the calling logic between modules. Add an exception jump branch design to the calling logic to generate the initial logic framework. S23. Perform a rationality check on the initial logic framework. The check indicators include module redundancy rate and call logic conflict rate. The module redundancy rate = number of redundant modules / total number of modules. The call logic conflict rate = number of conflicting branches / total number of branches. Eliminate redundant modules and conflicting call logic to obtain the final business logic framework. The business logic framework corresponds to the standardized requirement information and is accompanied by a logic check report.

4. The code automatic generation method based on agent-assisted and natural language understanding according to claim 3, characterized in that: In step S3, the process of generating target code by the intelligent completion layer includes: S31. Based on the core functional modules and requirement priority tags in the business logic framework, the corresponding basic code templates are matched from the preset code template library. The matching process adopts a template similarity sorting algorithm, which uses the matching degree of business scenario, programming language and functional module as the calculation dimension, and sorts them in descending order of comprehensive similarity. The templates that best match the constraints of business scenario and programming language are matched first. The basic code templates contain the basic syntax structure corresponding to the module. S32. Using a deep learning completion model, combined with the standardized requirement information and the calling relationship of the business logic framework, parameter filling and logic completion are performed on the basic code template. During the filling process, abnormal jump branches between modules are automatically adapted to generate initial code. S33. Redundant code is removed and format is standardized in the initial code. The format standardization follows the industry standards of the corresponding programming language and the user's preset format requirements to obtain complete target code. The target code is consistent with the logic of the business logic framework and the redundancy rate is lower than a preset threshold.

5. The code automatic generation method based on agent-assisted and natural language understanding according to claim 1, characterized in that: The intelligent agent employs a multi-module collaborative control mechanism, which includes: receiving real-time processing status data from the requirement understanding layer, logic planning layer, and intelligent completion layer; adjusting the processing priority of each layer based on the processing status data and requirement complexity using a dynamic priority scheduling algorithm; the dynamic priority scheduling algorithm follows the rule that the priority of unstarted layers is lower than that of layers in processing, and the priority of abnormal layers is temporarily increased to the highest; when a processing abnormality occurs in a certain layer, the intelligent agent triggers an abnormality handling mechanism, suspends the processing of the current layer and reports the abnormality information, and simultaneously calls the corresponding layer's backup processing strategy according to the abnormality type. The abnormality types are divided into fatal and non-fatal abnormalities. Fatal abnormalities include model crashes and insufficient computing resources, which trigger a local backup model call mode; non-fatal abnormalities include substandard processing efficiency and non-fatal syntax errors, which trigger a simplified adaptation mode for processing steps, ensuring that the three-layer system collaboratively advances the code generation process, and the entire abnormality handling process is recorded in the system log.

6. The automatic code generation method based on agent-assisted and natural language understanding according to claim 5, characterized in that: The domain knowledge base contains commonly used requirement terms, functional module definitions, and logical association rules in multiple technical fields. It is stored in categories according to technical fields and includes update timestamps. The domain knowledge base is updated in real time through intelligent agents. The update trigger conditions include three scenarios: completion of new requirement processing, user feedback optimization, and industry technology iteration. The update data comes from historically processed natural language requirements, corresponding standardized requirement information, and the latest industry technical documents. After the update, the consistency of the knowledge base is automatically verified, and duplicate and conflicting content is removed to continuously improve the accuracy of requirement understanding.

7. The code automatic generation method based on agent-assisted and natural language understanding according to claim 4, characterized in that: The deep learning completion model adopts an improved model based on the Transformer architecture. The improved model introduces a code syntax constraint layer and a logical association layer. The code syntax constraint layer preloads the syntax rules of multiple programming languages, converts the syntax rules into regular expressions, and performs real-time verification on each line of code during the code completion process to intercept syntax errors. The logical association layer combines the call relationships and exception jump branches of the business logic framework to construct a logical association matrix between code fragments. The logical association matrix uses the core functional modules as the matrix rows and columns, and the matrix elements are the call relationship weights between modules. 0 indicates no call, 1 indicates direct call, and 0.5 indicates indirect call. The matrix weights are dynamically updated in conjunction with exception jump branches to avoid generating code fragments with logical conflicts.

8. The code automatic generation method based on agent-assisted and natural language understanding according to claim 1, characterized in that: In step S4, the syntax verification uses a preset code syntax rule library, which is classified according to programming language; the logical consistency verification uses a predicate logic-based logical deduction algorithm, which transforms the calling relationship of the business logic framework into a predicate logic formula, transforms the logical flow of the target code into a corresponding predicate logic sequence, and completes the consistency verification through the resolution principle, verifying whether the calling logic and exception handling logic of each module in the target code are consistent with the business logic framework. If the verification fails, the agent determines the level and type of the error based on the verification error information. The classification dimensions include error level and error type. Error levels are divided into requirement understanding layer, logic planning layer, and intelligent completion layer. Error types are divided into syntax error, logic conflict, requirement matching error, and format error. The agent returns to the processing steps corresponding to the level for reprocessing and records the error type, processing solution, and processing result for optimizing the subsequent code generation process and updating the historical error case library.

9. The code automatic generation method based on agent-assisted and natural language understanding according to claim 1, characterized in that: The method further includes step S5: receiving user feedback on modifications to the output target code. The intelligent agent, through a feedback intent recognition model, classifies the modification feedback information into three categories: requirement adjustment instructions, logic adjustment instructions, and format adjustment instructions. These are then sent to the requirement understanding layer, logic planning layer, and intelligent completion layer, respectively. The corresponding layers update the processing results according to the priority of the adjustment instructions, regenerate the target code, compare the differences between the code before and after the adjustment, and generate a difference report for user confirmation, thereby achieving interactive optimization of code generation.

10. The code automatic generation method based on agent-assisted and natural language understanding according to claim 1, characterized in that: The method supports automatic code generation in multiple programming languages. The preset code template library contains basic templates for multiple programming languages ​​and is stored in a dual category of programming language and business scenario. The intelligent completion layer matches the corresponding template and generates target code in the corresponding programming language based on the programming language constraints in the standardized requirements information and the template similarity threshold. The programming language includes at least two of Java, Python and C++, and supports dynamic expansion of the programming language. When expanding, the corresponding programming language syntax rule library and basic template are added.