Software code generation methods, apparatus, equipment, and media

By semantic alignment and fusion of multimodal information, combined with the encoding constraint instructions of a large language model, the problem of lagging understanding of multidimensional requirements and security assurance in code generation in existing technologies is solved, and the accuracy and security of the code generation process are achieved.

CN122086381APending Publication Date: 2026-05-26广州商研网络科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
广州商研网络科技有限公司
Filing Date
2026-02-10
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing automated code generation technologies are limited in understanding and expressing multi-dimensional software development requirements, and their security guarantees are lagging behind, resulting in generated code that cannot accurately match the developer's true intentions and poses security risks.

Method used

By receiving and parsing multimodal information, performing semantic alignment and fusion, generating software function planning information, and triggering coding constraint instructions when calling the large language model, the code generation process is ensured to comply with safety specifications.

Benefits of technology

It reduces information loss and ambiguity during code generation, ensures high consistency between the generated code in terms of functional logic and interface performance, and embeds proactive security defenses at the moment of generation, thereby reducing the cost and risk of subsequent security audits.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122086381A_ABST
    Figure CN122086381A_ABST
Patent Text Reader

Abstract

This application relates to the field of code generation technology, and discloses a software code generation method and its apparatus, device, and medium. The method includes: responding to a code generation driving event and determining the multimodal information corresponding to the event, wherein the multimodal information corresponds to the original software development requirements; semantically aligning the different modal information in the multimodal information and fusing them to generate software function planning information; extracting each function planning unit as a code generation subtask of the corresponding code generation type according to the code generation type corresponding to the function planning unit described in the software function planning information; calling a large language model to execute each code generation subtask and synchronously triggering the corresponding coding constraint instructions to generate target code. This application, through the semantic alignment and fusion of multimodal information and the synchronous triggering mechanism of coding constraints in the code generation process, highly restores the development requirements of the software code and reduces the subsequent security audit costs and software maintenance risks of the software code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of code generation technology, and in particular to a software code generation method, apparatus, device, and medium thereof. Background Technology

[0002] With the rapid development of artificial intelligence technology, automated code generation technology has made significant progress. Code assistants based on Large Language Models (LLMs) can automatically complete code snippets, functions, and even generate simple modules based on natural language descriptions or code context input by developers, greatly improving the efficiency of software development.

[0003] However, existing automated code generation technologies still face many challenges in practical applications, mainly in the following two aspects: First, the dimensions of requirement understanding and expression are limited. Most current software code generation methods rely on a single modal input, typically a text-based natural language description. However, actual software development requirements are often multi-dimensional and complex. For example, a complete software module not only includes functional logic that can be described in words, but also involves graphical user interface (UI) layout design and structured data entity relationships. If relying solely on text input, developers are forced to "translate" this intuitive visual or structured information into lengthy text descriptions. This process is not only inefficient and prone to information loss and ambiguity, but it also often results in code generated from large models failing to accurately match the developer's true intentions, particularly in the correspondence between the front-end interface and back-end logic.

[0004] Secondly, code security assurance lags behind. Existing large-scale code generation models primarily focus on the correctness of functional logic—that is, whether the code can run—while often neglecting the security of the generated code. Because these models learn from massive amounts of open-source code, they generate code containing common vulnerabilities, such as unfiltered SQL injection risks and cross-site scripting (XSS) attacks. This leads to an inefficient "generate first, fix later" work model, where developers must invest significant effort in security auditing and vulnerability patching after obtaining the code. This practice of placing security considerations at the end of the development process not only increases remediation costs but also leaves potential security vulnerabilities in the software system. Summary of the Invention

[0005] The purpose of this application is to solve the above-mentioned problems by providing a software code generation method, apparatus, device, and medium.

[0006] According to one aspect of this application, a software code generation method is provided, comprising the following steps: Respond to the code generation driver event and determine the corresponding multimodal information, which corresponds to the original software development requirements; Semantically align the different modal information in the multimodal information and fuse them to generate software function planning information; Based on the code generation type corresponding to the functional planning unit described in the software functional planning information, each functional planning unit is extracted as a code generation subtask of the corresponding code generation type. The large language model is invoked to execute various code generation subtasks and simultaneously trigger corresponding encoding constraint instructions to generate target code.

[0007] According to another aspect of this application, a software code generation apparatus is provided, comprising: A multimodal requirement awareness model is used to respond to code generation-driven events and determine the corresponding multimodal information, which corresponds to the original software development requirements. A semantic alignment and fusion planning model is used to semantically align different modal information in the multimodal information and fuse them to generate software function planning information. The task decomposition and scheduling model is used to extract each functional planning unit as a code generation subtask of the corresponding code generation type based on the code generation type corresponding to the functional planning unit described in the software functional planning information. The security-enhanced code generation model is used to call the large language model, execute various code generation subtasks, and synchronously trigger corresponding coding constraint instructions to generate target code.

[0008] According to another aspect of this application, an electronic device is provided, including a central processing unit and a memory, wherein the central processing unit is configured to invoke and run a computer program stored in the memory to perform the steps of the software code generation method described in this application.

[0009] According to another aspect of this application, a non-volatile readable storage medium is provided, which stores a computer program implemented according to the software code generation method in the form of computer-readable instructions, wherein the computer program, when invoked by a computer, executes the steps included in the method.

[0010] Compared with existing technologies, this application has numerous technical advantages, including but not limited to: This application receives and parses multimodal information to simultaneously identify potential security risks. When a large language model is invoked to execute a code generation subtask, it triggers encoding constraint instructions that match the multimodal information, subjecting the large language model to security rules the moment it "conceives" the code. This mechanism blocks SQL injection risks, cross-site scripting vulnerabilities, and other threats at the source, directly outputting target code with embedded proactive security defenses, significantly reducing subsequent security audit costs and software maintenance risks.

[0011] This application enables the construction of software function planning information that better reflects the developer's true intentions by semantically aligning and fusing information from different modalities. This significantly reduces ambiguity and loss during information transmission and ensures that the generated code is highly consistent in terms of functional logic and interface performance.

[0012] This application breaks down complex development requirements into specific code generation subtasks based on software function planning information, and associates each code generation subtask with a specific code generation type. This avoids logical confusion caused by overly large tasks, and also facilitates the application of fine-grained security coding constraints for different types of code generation subtasks, further improving the usability of the generated code. Attached Figure Description

[0013] Figure 1 This is an exemplary network architecture suitable for applying the software code generation method of this application; Figure 2 This is a flowchart illustrating one embodiment of the software code generation method of this application; Figure 3 This is a schematic block diagram of the software code generation device of this application; Figure 4 This is a schematic diagram of the structure of an electronic device used in this application. Detailed Implementation

[0014] To facilitate understanding of the various embodiments of this application, exemplary client architecture, network architecture, and application scenarios will be introduced first.

[0015] like Figure 1 As shown, the network architecture of this application aims to build a secure and controllable multimodal code generation system. The network architecture includes a developer terminal 80, a code generation server 81, and a large model server 82. The developer terminal 80 is connected to the code generation server 81 via the Internet, and the code generation server 81 is also connected to the large model server 82 via the Internet.

[0016] Specifically, the code generation server 81 responds to the code generation driver event of the developer terminal 80, determines and accepts the multimodal information corresponding to the event, performs semantic alignment and fusion on the multimodal information, generates a code generation subtask with security coding constraint instructions, and forwards the code generation subtask to the large model server 82. By calling the large model server 82, the code generation subtask is executed and the corresponding coding constraints are triggered synchronously to generate the target code with embedded security defense measures.

[0017] Accordingly, the network architecture of this application introduces a code generation server 81 as an intelligent middleware layer to take over and enhance the interaction between the developer terminal 80 and the large model server 82. Multimodal fusion logic and proactive security defense mechanisms are embedded in the request forwarding process, enabling the large model server 82 to produce code that is more in line with business intent and has security. At the same time, unified control over the code generation process is also achieved.

[0018] In an exemplary application scenario, the software code generation method of this application can be applied to the automated development of front-end interaction and business logic in mobile applications. In this scenario, the developer uploads a hand-drawn wireframe of the "user login interface" and inputs text instructions describing the login rules, such as "After the user enters their account and password and clicks login, the password length must be verified to be no less than 8 characters. If login fails, a prompt should be displayed." The wireframe and text instructions serve as multimodal information. The multimodal information is processed by analyzing the wireframe through image recognition to extract interface element components such as the "account input box," "password input box," and "login button." The text instructions are parsed using natural language processing to extract the functional constraint of "verifying password length" and the functional operation of "clicking login." Semantic alignment is performed to map the functional constraint of "password length no less than 8 characters" in the text instructions to the recognized attributes of the "password input box" interface element. The functional logic of "clicking login" in the text instructions is anchored to the state of the "login button" interface element in the visual modality. After completing the deep fusion of text and image modalities, the code generation subtask is generated based on the fused software function planning information. The coding constraint instructions of "preventing brute-force attacks" and "password hash storage" are automatically matched. Finally, the large language model is called to generate login module code that includes accurate UI layout, complete interaction logic and complies with security specifications.

[0019] Through the detailed description of the network architecture and application scenarios described above, a better understanding of the specific application of the software code generation method of this application in the field of code generation technology can be achieved. The following will elaborate on the detailed description of various specific embodiments of this application based on these exemplary contents.

[0020] like Figure 2 As shown, in one embodiment, the software code generation method of this application includes: Step S5100: Response code generation driver event, determine the multimodal information corresponding to the event, the multimodal information corresponding to the original software development requirements; The execution entity is the code generation server in the aforementioned network architecture. The code generation server receives a driving event from the developer's terminal to trigger the code generation process, and identifies and obtains multimodal information associated with the driving event, which includes at least two different forms of expression. The multimodal information together constitutes the developer's original functional planning and design intent for the target software.

[0021] Code generation-driven events can be the triggering mechanism for the generation process. They manifest as a specific network request sent from the developer's terminal to the code generation server. This network request can be triggered by explicit operations on the developer's terminal interface or automatically by the terminal according to preset rules.

[0022] Multimodal information can serve as a data carrier for describing software development requirements, and is a dataset used to comprehensively describe software development requirements, including visual modal information and text modal information.

[0023] Visual modal information can be data presented in visual forms such as graphics, images, or video frames. It is mainly used to carry intuitive requirements such as front-end interface design, layout structure, component style, and interaction flow of software, such as UI design drafts, hand-drawn wireframes, and interface screenshots.

[0024] Text modal information can be logical description data presented in character encoding form or that can be converted into character encoding form, including but not limited to natural language instruction information and data structure definition information. Natural language instruction information refers to business logic, functional rules, or operational intentions described by developers in human language. It should be noted that voice information also belongs to natural language instruction information. Voice instructions input by developers through a microphone, after being converted into text by speech recognition technology, are treated as text modal information for processing. In this application, voice information is regarded as an input source or pre-form of text modality. Data structure definition information refers to structured text code provided by developers to define data models, storage structures, or interface contracts, such as SQL table creation statements, JSON data contracts, and XML configuration files.

[0025] The code generation server can be deployed with a web server or API gateway interface, such as a RESTful API or gRPC interface. When the developer terminal sends an HTTP POST message carrying a code generation driver event, the code generation server receives the message, parses the message header or message body, identifies the specific event identifier, and responds to the code generation driver event.

[0026] The code generation server can determine and extract multimodal data from the HTTP POST message carrying the code generation driving event, or based on the index information provided in the message. For example, the code generation server can extract the uploaded image file stream from the multipart / form-data segment of the message; or when the message only carries a URL link, the code generation server can download the corresponding image data from cloud storage based on the URL; or if the message contains a voice data stream, the code generation server can call the speech recognition module to convert it into text as natural language instruction information; or if the message contains text fields or uploaded script files, the server can read their character content as natural language instruction information or data structure definition information, respectively.

[0027] Step S5200: Semantically align the different modal information in the multimodal information and fuse them to generate software function planning information; The code generation server parses the acquired visual and textual modal information, establishes logical mapping relationships between different modal data objects through semantic alignment, and integrates these mapping relationships with the original information to generate a structured software function planning information for defining the functional specifications of the software to be developed.

[0028] Semantic alignment is the process of establishing a mapping between data objects of different modalities. Software development requirements are often scattered across visual and textual modal information, lacking a direct, computer-readable connection. Semantic alignment aims to identify the correspondence between interface objects in the visual modality and logical description objects in the textual modality. Considering the diversity of software development requirements, this application proposes that the semantic alignment process cover multiple dimensions, including but not limited to matching at the levels of functional operation, functional logic, and functional constraints. This multi-dimensional alignment mechanism ensures a complete mapping of software development requirements from the interface interaction layer to the backend business layer.

[0029] The code generation server can perform image analysis on visual modal information, identify and extract a set of interface element components, including component type, position coordinates, and text labels. It can also perform semantic analysis on text modal information to extract a set of business logic units, including action instructions, validation rules, and data field definitions. Based on feature extraction, it executes semantic alignment logic. To achieve accurate characterization of software requirements, this application supports the construction of multi-level mapping relationships. The established mapping relationships, the set of interface element components, and the set of business logic units are encapsulated to generate software function planning information, which can be stored in structured data formats such as JSON and XML.

[0030] Step S5300: Based on the code generation type corresponding to the functional planning unit described in the software functional planning information, extract each functional planning unit as a code generation subtask of the corresponding code generation type; The code generation server traverses and parses the software function planning information, decomposes it into several independent function planning units based on semantic integrity, determines the code generation type of the technical implementation category of each function planning unit, and constructs code generation subtasks of executable processing objects that are compatible with the code generation type, thereby realizing the structured decomposition of complex software development requirements.

[0031] A functional planning unit can be the smallest unit of division in software functional planning information that has independent business semantics or execution logic, including a complete page module, an independent data interface, or specific interaction logic.

[0032] The code generation type can be a classification and identification of functional planning units based on the layering of the software architecture or the characteristics of the technology stack. The code generation types in this application include, but are not limited to, front-end interface interaction types and back-end business logic types.

[0033] The code generation subtask is a task instruction package generated by the functional planning unit, containing a clear input context and generation target, which serves as the specific execution unit for subsequent invocation of the large language model for code generation.

[0034] The code generation server can read structured software function planning information and identify it based on semantic integrity. This includes identifying interrelated interface element components, functional logic, and data structure definitions within the function planning information, and combining these interrelated components into an independent function planning unit. For example, if the code generation server detects a data set containing input-type interface element components, trigger-type interface element components, and corresponding data validation logic, and because they collectively complete a specific business interaction, the code generation server divides it into a function planning unit, ensuring that each code generation server contains the complete context information required to execute a specific function.

[0035] After dividing the functional planning units, the code generation server can parse the technical feature attributes contained in each functional planning unit to determine its code generation type. For example, if a functional planning unit contains interface element components derived from visual modal information, or contains functional operations derived from text modal information and semantically aligned with the interface element components, the code generation server identifies it as a front-end code generation type; if a functional planning unit contains data structure definition information derived from text modal information, or contains functional logic derived from text modal information and used to describe the back-end business of the software to be generated, the code generation server identifies it as a back-end code generation type.

[0036] Once the code generation type of a functional planning unit is determined, the code generation server can extract all data elements corresponding to that functional planning unit and construct code generation subtasks. For example, for a functional planning unit identified as a backend code generation type, a backend code generation subtask is created, and the functional logic and data structure definition information from the text modal information contained in the functional planning unit are encapsulated into the input parameters of the code generation subtask. For a functional planning unit identified as a frontend code generation type, a frontend code generation subtask is created, and the interface element components from the visual modal information contained in the functional planning unit, as well as the functional operations from the text modal information aligned with those components, are encapsulated into the input parameters of the code generation subtask. Through encapsulation, each code generation subtask becomes an independent execution object containing clearly defined input data and a target type, thus preparing the data for subsequent targeted code generation by calling a large model.

[0037] Step S5400: Call the large language model, execute each code generation subtask and synchronously trigger the corresponding encoding constraint instructions to generate the target code.

[0038] The code generation server establishes a communication connection with the large model server, and the determined code generation subtasks are used as processing objects. Based on the attributes of the code generation subtasks, the code generation server determines and associates the encoding constraint instructions of the control conditions that are compatible with the code generation subtasks, and sends the data stream containing the code generation subtask content and the encoding constraint instructions to the large model server, driving it to generate target code of computer source code that meets the control conditions.

[0039] Coding constraint instructions can serve as guidance for standardizing the generation behavior of large language models. Since large language models have the characteristic of open generation, directly inputting code to generate subtasks may result in the generated target code not meeting specific engineering standards or security requirements. The role of coding constraint instructions is to set boundaries for the generation process.

[0040] Synchronous triggering refers to the simultaneous activation of corresponding coding constraint instructions within the same timeframe when the code generation subtask is submitted to the large language model for execution, ensuring that the generated target code meets predetermined requirements upon output.

[0041] The code generation server can introduce a rule matching mechanism based on task attributes. According to the code generation type of the code generation subtask to be executed, it searches and determines the constraint rules applicable to the code generation subtask from the internally preset rule set. This ensures that different types of code generation subtasks can be matched with targeted constraint strategies, laying the foundation for the subsequent generation of differentiated coding constraint instructions.

[0042] After the applicable constraint rules are determined, the code generation server can perform instruction conversion operations. Given that the large language model has specific requirements for the form of input information, the code generation server converts the determined constraint rules into encoded constraint instructions that the large language model can recognize, ensuring that the large language model can accurately parse and follow these constraint rules.

[0043] The code generation server can combine coding constraint instructions with code generation subtasks. The code generation server includes a reasoning request with a complete context, embeds coding constraint instructions as a necessary condition for task execution into the code generation subtask, and sends it to the large model server to output target code that meets the functional requirements and conforms to the constraint specifications.

[0044] As can be seen from the above embodiments, this application breaks through the limitation of traditional code generation relying solely on single text input by responding to code generation driving events and determining the corresponding multimodal information. This establishes a precise mapping relationship between multimodal information, generating structured software function planning information. This allows the large language model to directly understand multi-dimensional original requirements, including UI design diagrams, natural language instructions, and data structure definitions, eliminating the need for developers to perform tedious text-to-image translation. This eliminates information loss and ambiguity at the source, ensuring that the generated code accurately matches the developer's true intent in both front-end interface interaction and back-end business logic. Furthermore, this application implements a proactive defense mechanism of "safe left shift" by identifying the code generation type of the function planning unit and synchronously triggering corresponding coding constraint instructions when executing code generation subtasks. This ensures that the large language model is constrained by security specifications the moment code is generated, thereby directly producing target code with embedded security defense measures.

[0045] Based on any embodiment of the method in this application, the semantic alignment of different modal information in the multimodal information includes one or more of the following: Step S5210: Identify the functional operations in the text modal information and the interface element components in the visual modal information, and semantically align the functional operations and interface element components. The code generation server parses the text modal information to extract the functional operations of semantic units that describe user interaction behavior. At the same time, it parses the visual modal information to extract the interface element components that constitute the user interface. Based on semantic relevance or positional relationship, it establishes a one-to-one or one-to-many association mapping relationship between the functional operations and the interface element components.

[0046] Functional operations can be behavioral instructions described in text modal information that need to be triggered through a specific user interface, such as verb-object phrases like "click the submit button", "swipe to see more", and "enter search keywords".

[0047] Interface element components can be graphical areas identified from visual modal information that have interactive or display attributes, such as buttons, input boxes, drop-down menus, and icons.

[0048] Code generation servers can utilize dependency parsing or named entity recognition techniques from natural language processing to identify verb phrases and their objects in text modal information. For example, from the instruction "User enters account and clicks login", the set of functional operations can be extracted: {op1:"Enter account", op2:"Click login"}. Code generation servers can also use object detection models or UI element recognition algorithms to identify component categories and location coordinates in visual modal information, and combine this with OCR technology to extract text labels from the components. For example, the set of interface element components can be identified: {comp1:type="Input", label="Account"}, {comp2:type="Button", label="Login"}.

[0049] The code generation server can calculate the matching degree between functional operations and interface element components, and establish alignment relationships. The matching logic includes, but is not limited to, text similarity-based matching, component type-based matching, and comprehensive matching strategies. For example, text similarity-based matching can calculate the semantic similarity between keywords in functional operations and OCR tags of interface element components. If the similarity exceeds a preset threshold, an association is established. Component type-based matching can filter component types according to the verb attributes of functional operations. For example, the verb "input" tends to match Input type components, and the verb "click" tends to match Button type components. The comprehensive matching strategy can determine that op2:"click to log in" and comp2:type="Button",label="login" constitute the best match, and generate a mapping record: Map(op2,comp2).

[0050] In summary, this hybrid alignment strategy of functional operations and interface element components can significantly improve the robustness of alignment, especially for complex scenarios where there are multiple similar components in the interface element components, such as multiple "OK" buttons.

[0051] Step S5220: Identify the functional logic in the text modal information and the interface element state in the visual modal information, and semantically align the functional logic and the interface element state. The code generation server parses the text modal information, extracts the functional logic of semantic units that describe the conditions of software operation, interface change rules, or business state transitions, and parses the visual modal information, extracts the interface element states of the visual representation of interface element components under different interaction scenarios, and establishes a logical association mapping relationship between the functional logic and the interface element states.

[0052] The functional logic in the text modal information can be the dynamic rules described in the text modal information that determine how the software interface responds to external input or changes in internal data. For example, "disable the submit button when the input box is empty".

[0053] The state of interface elements in visual modal information can be a specific visual variant of the interface element component in the visual modal information, such as available / disabled state, selected / unselected state, visible / hidden state, etc.

[0054] The code generation server can utilize natural language processing techniques to identify conditional logic and result descriptions in text modal information. For example, from the instruction "Gray the login button when the password length is insufficient," it can extract the conditional logic "Condition: "Password length < threshold" and the target state description "Button grayed out." The code generation server can also use image feature analysis algorithms to identify different visual variations of the same type of interface element components in visual modal information. For instance, it can identify two button components in a UI design that look similar but differ in color or grayscale, labeling them as State1: "Button_Normal" (normal state) and State2: "Button_Disabled" (disabled state). The code generation server can match the state description "grayed out" in the text modal information with the visual attribute feature "gray fill" in the visual modal. Finally, the code generation server can bind the extracted functional logic to the corresponding interface element state, for example, establishing a mapping relationship: Map(Logic: "Password_Length_Invalid", Component: "Btn_Login", Target_State: "Disabled").

[0055] In summary, by "injecting" the functional logic from the text modal information into the different states of the visual components in the visual modal information, the generated software code is endowed with business responsiveness, ensuring that the final generated software can dynamically interact according to the developer's intentions.

[0056] Step S5230: Identify the functional constraints in the text modal information and the interface element attributes in the visual modal information, and semantically align the functional constraints and interface element attributes.

[0057] The code generation server parses the text modal information to extract the functional constraints of semantic units that describe data input restrictions, format requirements, or validation rules. At the same time, it parses the visual modal information to extract the interface element attributes that are inherent to the interface element components and are used to control input behavior or display format. It then establishes parameter binding or assignment mapping relationships between the functional constraints and the interface element attributes.

[0058] Functional constraints can be rules described in text modal information that restrict user input or processed data, such as "password length must be greater than 8 characters", "amount can only be entered as numbers", and "phone number must conform to regular expression format". Interface element attributes can be configurable technical parameters possessed by interface element components in visual modal information. For example, for HTML / front-end components, interface element attributes include maxlength (maximum length), placeholder, type (input type), and pattern (regular expression validation mode).

[0059] Code generation servers can utilize regular expression matching or large model extraction techniques to extract constraint values ​​from text modal information. For example, from the instruction "Comment character count limited to 500 characters," the constraint type "Max_Length" and constraint value "500" can be extracted. Code generation servers can also use component recognition algorithms to determine the type of UI element components and query the list of supported attributes for that type of component. For example, identifying the TextArea component and determining that it supports attributes such as maxlength and rows.

[0060] The code generation server can find the corresponding component attribute based on the type of functional constraint. For example, it can map "character limit" to the `maxlength` attribute, "only numbers can be entered" to the `type="number"` attribute, and "default prompt: please enter" to the `placeholder` attribute. The code generation server can then assign the extracted constraint values ​​to the corresponding attributes, for example, by establishing a mapping relationship: `Map(Constraint:"Limit 500", Component:"Comment_Box", Target_Attribute:"maxlength=500")`.

[0061] As can be seen from the above embodiments, this application achieves the binding of user interaction behavior and front-end triggering carrier by identifying and establishing semantic alignment between functional operations and interface element components, ensuring that the generated code can correctly respond to the user's operation intentions. Furthermore, by identifying and establishing semantic alignment between functional logic and interface element states, abstract business rules are transformed into specific interface visual feedback, giving the generated code the ability to interact dynamically. Additionally, by identifying and establishing semantic alignment between functional constraints and interface element attributes, data validation rules are directly solidified into the technical parameters of the front-end components. Through a multi-dimensional alignment mechanism, the information gap between text and graphics modalities is eliminated comprehensively from the three levels of operation, logic, and constraints, enabling the generated software functional planning information to losslessly reproduce complex business requirements. This ensures that the final generated code highly conforms to the developer's original design in terms of the completeness of the interaction logic and the rigor of data processing. Moreover, this application not only achieves text-graphic correspondence but also front-end and back-end consistency. For example, by directly mapping the field length constraints in the data structure definition to the attributes of the front-end component with the maximum input length, potential errors caused by inconsistencies in the front-end and back-end data contracts are effectively prevented. This deep integration processing provides a solid structured data foundation for generating high-quality, directly executable target code from the subsequent large language model.

[0062] Based on any embodiment of the method in this application, the step of extracting each functional planning unit as a code generation subtask of the corresponding code generation type according to the code generation type corresponding to the functional planning unit described by the software functional planning information includes: Step S5310: Traverse the software function planning information and identify multiple function planning units in the software function planning information based on semantic integrity; The code generation server identifies software function planning information and, based on preset aggregation rules, identifies component sets, logical rules, and data definitions that have strong logical connections or jointly serve a single business objective. It then cuts and encapsulates the interrelated information elements into several independent, logically self-consistent functional planning units.

[0063] A functional planning unit can be the smallest set of executions with independent business semantics, extracted from macro-level software functional planning information. Examples include a complete "user login form," a "product list display area," or a "file upload control group." Semantic integrity ensures that, during unit division, each unit contains all the contextual elements required to execute the function.

[0064] The code generation server can read software function planning information. For example, it can use depth-first search or breadth-first search algorithms to access nodes in the planning information one by one. Node types can be interface containers, atomic components, logical rules, and data fields. The code generation server can apply semantic integrity for clustering, including but not limited to interface container-based aggregation, logic link-based aggregation, and data entity-based aggregation. Interface container-based aggregation can identify container components such as Panel, Card, and Form in the visual modality. For example, all input boxes, buttons, and their bound validation logic within a Form container naturally constitute a function planning unit. Logic link-based aggregation can start from a "submit button," find its triggered "API request logic" through semantic alignment, and then find the "input box data" that the API request depends on. All nodes on this complete triggering, processing, and data chain are marked as a function planning unit. Data entity-based aggregation can aggregate all interface components bound to an entity defined in the data structure. For example, all input components bound to the User table are aggregated into a "user information management unit."

[0065] Step S5320: Identify the functional planning unit corresponding to backend code generation among the multiple functional planning units, and create the corresponding backend code generation subtask; The code generation server performs attribute detection on multiple identified functional planning units, filters out those containing backend feature information such as data persistence operations, business logic processing, or API interface definitions, and constructs a backend code generation subtask for each selected functional planning unit, which contains an execution instruction object containing clear backend development requirements and context parameters.

[0066] The corresponding backend code generation functional planning unit can be a planning unit that involves database read / write or inter-system communication in terms of business logic, and its implementation depends on the backend technology stack (such as Java, Go, Python) and database system (such as MySQL, Redis). The backend code generation subtask can be a task package generated for the corresponding backend code generation functional planning unit, used to drive the large language model to produce source code, including data table structure definition, business process logic and interface specifications.

[0067] The code generation server can iterate through all functional planning units, checking whether they contain data structure definition information derived from text modal information, such as SQL table creation statements and ORM model definitions; whether they contain functional logic to be executed, such as "verifying user password hash values," "querying inventory quantities," and "calling third-party payment interfaces"; and whether they contain data submission or retrieval behaviors bound to front-end components, such as the intent of a POST request corresponding to "submitting a form." If any of the above characteristics are found, the code generation server marks the functional planning unit as "involving back-end implementation."

[0068] The code generation server can extract related information elements and context parameters for backend code generation subtasks for functional planning units marked "involving backend implementation". For example, it can use the associated data structure definition information as the data context of the backend code generation subtask; use the functional logic in the associated text modal information as the logical context of the backend code generation subtask; and derive and generate the specification description of the API interface based on the interaction requirements of the frontend components, and incorporate it into the task description of the backend code generation subtask.

[0069] The code generation server can construct and encapsulate backend code generation subtasks based on the context parameters of the backend code generation subtasks. These subtasks can include information elements such as a task type identifier, generation prompts, and output target definitions. The task type identifier can explicitly mark the subtask as a backend type, such as `Backend_Type`, which is used to match secure coding rules in subsequent steps. The generation prompts can be natural language instructions designed for backend development, such as "Please write a user registration interface using the Spring Boot framework based on the following SQL structure...". The output target definition can specify the expected code file type and code architecture level to be generated by the backend code generation subtask.

[0070] Step S5330: Identify the functional planning unit corresponding to front-end code generation among the multiple functional planning units, and create the corresponding front-end code generation subtask.

[0071] The code generation server performs attribute detection on multiple identified functional planning units, and filters out functional planning units that contain front-end feature information such as interface layout description, user interaction event definition or visual style attributes. For each selected unit, a front-end code generation subtask is constructed, which contains a set of execution instructions with clear front-end development requirements and context parameters.

[0072] The identification of the functional planning unit corresponding to the front-end code generation among the multiple functional planning units can be executed synchronously with the identification of the functional planning unit corresponding to the back-end code generation among the multiple functional planning units in step S5320. When the code generation server performs attribute detection on the identified multiple functional planning units, it simultaneously completes the detection of front-end feature information and back-end feature information.

[0073] The corresponding front-end code generation functional planning unit can be a planning unit that involves user interface rendering, browser-side interactive response, or client-side data display in terms of business logic. Its implementation depends on the front-end technology stack, such as Vue.js, React, and HTML / CSS. The front-end code generation subtask can be a task package generated for the corresponding front-end code generation functional planning unit, used to drive the large language model to produce client-side source code, including component structure definitions, style rules, and interaction scripts.

[0074] The code generation server can traverse all functional planning units, checking whether each unit contains UI element components derived from visual modal information, such as buttons, input boxes, and card containers; whether it contains functional operations derived from text modal information and aligned with UI element components, such as "click button" and "swipe screen"; and whether it contains logical descriptions of UI element state changes, such as "change color when mouse hovers" and "display red box when an error occurs." If any of these features are detected, the functional planning unit is marked as "involving front-end implementation."

[0075] The code generation server can extract related information elements for functional planning units marked as "involving front-end implementation" and construct context parameters for front-end code generation subtasks. For example, it can use related UI element components and their hierarchical relationships (such as parent-child nesting relationships and sibling arrangement relationships) as the structural context of the front-end code generation subtask; use related UI element attributes as the style context of the front-end code generation subtask; and use related functional operations and functional logic as the behavioral context of the front-end code generation subtask. For example, it can map the "click login" operation to the onClick event handler function definition of the front-end component.

[0076] The code generation server can construct and encapsulate front-end code generation subtasks based on the context parameters of the subtasks. These subtasks can include information elements such as a task type identifier, generation prompts, and data binding interfaces. The task type identifier, for example, "Frontend_Type," marks the subtask as a front-end type and is used to match secure coding rules in subsequent steps. The generation prompts can be natural language instructions designed for front-end development, such as "Please write a login component using the Vue3 framework based on the following interface layout description and implement click events...". The data binding interfaces can specify the API interface names and parameter structures that the front-end component needs to call if there is data interaction between the functional planning unit and the backend, thus completing the transformation from a functional planning unit to an executable front-end code generation subtask.

[0077] As can be seen from the above embodiments, this application decomposes complex software function planning information into multiple independent function planning units based on semantic integrity. Through a parallel recognition mechanism, it distinguishes the backend business attributes and frontend interaction attributes corresponding to each unit, creating dedicated backend code generation subtasks and frontend code generation subtasks respectively. This achieves structural decoupling from "mixed requirements" to "layered tasks," effectively solving the technical problem of potential discrepancies between the correspondence between the frontend interface and backend logic. Furthermore, this application ensures that the large language model focuses on specific technical contexts when generating code by encapsulating data structure definitions in the backend code generation subtask and interface layout information in the frontend code generation subtask. This avoids logical confusion caused by information mixing, thereby improving the matching accuracy of the generated code in terms of frontend and backend interface consistency and business logic integrity.

[0078] Based on any embodiment of the method in this application, the step of calling the large language model, executing various code generation subtasks and synchronously triggering corresponding encoding constraint instructions to generate target code includes: Step S5410: Based on the code generation type corresponding to the code generation subtask, match at least one security coding rule from the preset security rule base for each code generation subtask; The code generation server identifies the code generation type of the code generation subtask, such as backend or frontend. Using this type as the search key, it queries the internally maintained preset security rule library that stores various network security defense strategies, filters out one or more policy entries that are applicable to the task type, and associates them with the code generation subtask.

[0079] The pre-defined security rule base can be a collection of data containing structured security policies stored on the code generation server. Each security coding rule in the security rule base includes a rule ID, applicable scenario (such as Backend / Frontend), vulnerability type (such as SQL Injection, XSS), and a description of the defense measures. Security coding rules can be specific, actionable code writing standards, such as "all database query parameters must be parameterized" and "all user input echoes must be HTML escaped".

[0080] The code generation server can preload a layered security rule base. This security rule base is indexed and categorized according to code generation type into backend security rule sets, frontend security rule sets, and general security rule sets. The backend security rule set may include security coding rules such as preventing SQL injection, preventing command injection, defending against insecure file uploads, and encrypting sensitive data storage. The frontend security rule set may include security coding rules such as preventing cross-site scripting attacks, preventing cross-site request forgery (CSRF), input length limits, and masking sensitive information display. The general security rule set may include code commenting standards, error handling standards, etc.

[0081] The code generation server can read code generation subtasks, extract their code generation type identifiers, and perform a combination of dedicated rule matching and general rule matching. Dedicated rule matching can automatically query and match security encoding rules in the backend security rule set if the backend type is identified as `Backend_Type`, for example, matching rule `Rule_01:Use_Prepared_Statement` (using prepared statements). Dedicated rule matching can also automatically query and match rules in the "Frontend_Type" security rule set if the frontend type is identified as `Frontend_Type`, for example, matching rule `Rule_02:Output_Encoding` (output encoding). General rule matching can automatically query and match global rules in the general security rule set regardless of the code generation type identifier, for example, matching rule `Rule_Global_01:No_Hardcoded_Secrets` (prohibiting hard-coded passwords or API keys from being included in the code) and rule `Rule_Global_02:Error_Handling_Standard` (uniformly using try-catch blocks to handle exceptions without leaking system information).

[0082] The code generation server can merge the matched special rules with the general rules to generate a complete list of rules for the code generation subtask, and temporarily store it in the metadata of the subtask, such as Task_ID:101->Rules:[Rule_SQL_Inj, Rule_No_Hardcoded_Secrets].

[0083] In summary, this application achieves precise deployment of security defense strategies by dynamically matching exclusive security coding rules from a pre-defined security rule base based on the backend or frontend type of the code generation subtask. This effectively solves the problem of large language models easily generating vulnerable code due to a lack of specific security context. Furthermore, by locking down the mandatory security specifications based on task attributes before the code generation action is executed, this application avoids the risk of security rule mismatch or omission from the source. This lays a strategic foundation for the subsequent generation of target code with embedded proactive security defense measures, thus completely changing the inefficient traditional "generate first, fix later" development model.

[0084] Step S5420: Convert the security coding rules into coding constraint instructions that can be recognized by the large language model; The code generation server obtains one or more matched secure encoding rules, performs format conversion on the secure encoding rules according to the input specifications of the large language model, and generates encoding constraint instructions for natural language text that the large language model can understand and follow, which are used to limit the code generation behavior.

[0085] The code generation server can convert internally stored security encoding rules into encoded constraint instructions for natural language prompts that can be understood by the large language model, based on direct mapping transformation logic. For example, if the matched security encoding rule is Rule_SQL_Inj, the server can find the corresponding prompt instruction template, such as "When generating database operation code, please force the use of parameterized queries and prohibit the use of string concatenation," to generate natural language prompt instructions that can be understood by the large language model.

[0086] Step S5430: Embed the encoding constraint instructions into the corresponding code generation subtask, and input the code generation subtask with the encoding constraint instructions into the large language model to generate target code.

[0087] The code generation server combines the generated coding constraint instructions with the code generation subtasks to construct a model inference request containing complete context information. The model inference request is then sent to the large model server, which performs code generation operations based on the model inference request and returns source code data that meets the requirements of the coding constraint instructions.

[0088] The code generation server can construct model inference request messages based on the API interface specifications of the large language model. This includes placing coding constraint directives into the message content of the system role, for example, {"role":"system", "content":"You are a secure coding assistant. Please strictly follow the following rules: [coding constraint directives]..."}, ensuring that the coding constraint directives have the highest priority; and placing the specific content of the code generation subtasks, such as SQL definitions, function descriptions, and UI layouts, into the message content of the user role, for example, {"role":"user", "content":"Please generate code based on the following requirements: [subtask content]..."}.

[0089] The code generation server can send the constructed model inference request message to the server endpoint of the large model server. The large model server receives the model inference request message and, based on the attention mechanism of the Transformer architecture, pays attention to both the constraints in the system and the requirements in the user. When generating each token, it is affected by the probability weighting of the coding constraint instructions to ensure that the generated target code conforms to security specifications.

[0090] The code generation server can receive response messages from the large model server and extract the target code for the assistant role's reply content from the response messages. The code generation server can also perform formatting cleanup on the target code, such as removing Markdown tags, to obtain clean source code files.

[0091] As can be seen from the above embodiments, this application matches backend or frontend-specific security coding rules according to the subtask type, transforms abstract internal rules into natural language coding constraint instructions that large models can understand, and embeds these instructions into the system-level context of code generation requests. This achieves instruction-level proactive defense and solves the technical problem of large models neglecting code security and easily generating common vulnerabilities. Furthermore, by transforming security specifications into generation instructions, this application ensures that large language models are subject to clear security boundary constraints at every step of inference generation. This guarantees that the generated target code is embedded with specific defenses against SQL injection risks and cross-site scripting attacks from the outset, eliminating the need for developers to perform large-scale security refactoring and reducing the security risks and maintenance costs of software development.

[0092] Based on any embodiment of the method in this application, the step of converting the security coding rules into coding constraint instructions recognizable by a large language model includes: Step S5421: When there is only one matching security coding rule, convert the security coding rule into a coding constraint instruction that can be recognized by the large language model; The code generation server checks the number of security encoding rules. If the check result shows that there is only one rule entry, it calls the direct mapping conversion logic to convert the internal definition information of the rule into encoding constraint instructions for natural language text that conforms to the input specification of the large language model.

[0093] Step S5422: When there are multiple matching security coding rules, combine the multiple security coding rules into a composite security coding rule, and convert the composite security coding rule into a coding constraint instruction that can be recognized by the large language model.

[0094] The code generation server detects the number of secure coding rules. If the detection result shows that there are two or more secure coding rule entries, it executes the aggregation processing logic to merge these discrete secure coding rule entries into a logically coherent composite secure coding rule. The composite secure coding rule is then semantically reconstructed and formatted to generate a natural language text encoding constraint instruction that a large language model can understand and follow.

[0095] Composite security coding rules can be a unified rule object formed by combining multiple independent security policies at the internal logical level. For example, "preventing SQL injection" and "preventing data leakage" can be combined into a "comprehensive data security strategy".

[0096] The code generation server can read multiple matched security coding rules and check for explicit logical conflicts between them. For example, if one security coding rule requires "encryption is mandatory" and another requires "a hash algorithm must be used," then there is no explicit logical conflict. The definition information of all current security coding rules is extracted into a temporary list to form a composite security coding rule. If there is an explicit logical conflict, such as one security coding rule requiring "encryption is mandatory" and another requiring "plaintext is mandatory," then the current operation is stopped and a conflict error is reported.

[0097] Code generation servers can convert complex security coding rules into coding constraint instructions for natural language text, including but not limited to refactoring strategies that employ list-based or paragraph-based approaches.

[0098] As can be seen from the above embodiments, this application achieves adaptive processing of security scenarios with different complexities by using direct mapping transformation logic for a single security coding rule and composite reconstruction transformation for multiple security coding rules. This maximizes the execution focus of the large language model and avoids problems such as verbose Prompt instructions, context exceeding limits, or model attention dispersion caused by the stacking of security coding rules.

[0099] Based on any embodiment of the method in this application, after invoking the large language model, executing each code generation subtask and synchronously triggering the corresponding encoding constraint instructions to generate the target code, the process includes: Step S6410: Respond to the code modification driving event of the target code and determine the code modification information corresponding to the event; After completing the initial code generation and delivering the target code, the code generation server continuously listens for or receives subsequent interaction signals from the developer's terminal. When it detects a code modification-driven event that triggers changes, optimizations, or feature extensions to the generated code, the code generation server parses the data payload carried by the event, identifies and extracts code modification information in text, voice, or image data that describes the specific modification intent or incremental requirements.

[0100] Code modification-driven events are secondary build requests initiated by developers during software development iterations due to changes in requirements, bug fixes, or feature enhancements. Unlike code generation-driven events, these events occur only when existing baseline code exists. Code modification information can be incremental requirement data describing "how to modify existing code," including the target scope of the modification (e.g., "for the login module"), the specific actions of the modification (e.g., "add," "delete," "replace"), and the expected state after the modification (e.g., "add CAPTCHA functionality").

[0101] Code generation servers can provide interactive interfaces for code iteration, such as a "Refine" button or dialog box in an IDE plugin. When a developer selects a piece of generated target code on the interface and enters modification instructions, or uploads a new UI partial screenshot and clicks "Modify", the terminal sends a modification request message to the code generation server. The code generation server receives the modification request message, identifies its operation type identifier, such as action:refine_code, and responds to the code modification-driven event.

[0102] The code generation server can parse modification request messages and extract code modification information, such as natural language instructions like "Please change the color of the login button to red and add debounce logic after clicking"; a UI screenshot with modification suggestions, or visual incremental information such as a new wireframe with a "Forgot Password" link; and contextual positioning information such as the range of code line numbers selected by the sender or the specified function name.

[0103] The code generation server can encapsulate the extracted code modification information into a structured modification request object, such as {"modification_type":"feature_addition","target_context":"LoginModule","instruction":"Add captcha verification","visual_ref":"captcha_design.png"}.

[0104] Step S6420: Modify the corresponding code generation subtask according to the code modification information; Based on the code modification information, the code generation server locates the target subtask associated with the code modification information in the existing set of code generation subtasks, incrementally modifies, resets, or refactors the context parameters of the target subtask, thereby generating a corrected code generation subtask that reflects the latest requirement status.

[0105] The code generation server can retrieve the corresponding code generation subtask ID from the historical task record based on the location features in the code modification information, such as the selected file name, function name, or UI area.

[0106] The code generation server can execute modification strategies for feature increments, logic changes, and visual adjustments based on the type of modifications in the code modification information. For feature increments, the modification strategy might be to append new natural language instructions to the Prompt instruction of the atomic task. For example, if the original Prompt instruction was "Generate login form," it could be modified to "Generate login form and add a verification code input box." For logic changes, the modification strategy might be to replace specific constraints in the atomic task. For example, replacing the original "password length > 6" constraint with "password length > 8 and contains special characters." For visual adjustments, if the code modification information includes new UI screenshots, the modification strategy might be to replace the visual context data in the atomic task with the feature data of the new image.

[0107] Step S6430: Call the large language model, execute the modified code generation subtask and synchronously trigger the corresponding encoding constraint instructions to generate the modified target code.

[0108] The code generation server treats the modified code generation subtask as a new execution object. When initiating a model call request, it re-executes the security coding rule matching and instruction conversion process to ensure that the coding constraint instructions adapted to the modified code generation subtask are loaded synchronously. It then sends the modified code generation subtask and coding constraint instructions to the large model server, driving it to generate modified target code that meets the latest requirements and security specifications.

[0109] As can be seen from the above embodiments, this application incrementally modifies the existing code generation subtask by responding to code modification driving events and determining modification information, and then calls the large language model again to synchronously trigger encoding constraint instructions, thereby realizing a security closed loop under dynamic requirements and effectively solving the technical problems of lagging security considerations and high repair costs in code generation by the large language model.

[0110] Based on any embodiment of the method in this application, after invoking the large language model, executing each code generation subtask and synchronously triggering the corresponding encoding constraint instructions to generate the target code, the process includes: Step S7410: Based on the software function planning information, determine the functional architecture of the software to be generated, wherein the functional architecture represents multiple functional components of the software to be generated and the relationships between the multiple functional components; The code generation server reads and parses the software function planning information. Based on the structured description in the function planning information, it abstracts and reconstructs the functional architecture of the top-level logical structure of the software system to be generated. It identifies and marks the functional components of each independent business unit contained in the functional architecture, as well as the associations between the functional components of the data flow or calling relationship between these business units.

[0111] Step S7420: Associate the code generation subtask with the functional component and label the code generation subtask with matching coding constraints to generate a security report.

[0112] The code generation server establishes an association label for the mapping relationship between code generation subtasks and functional components. At the same time, it queries the coding constraints of the security coding rules matched by each code generation subtask, and attaches the rule information as metadata to the corresponding subtask record. Based on the association relationship and the attached security metadata, it summarizes and generates a visual or structured security report to show the security defense implementation status of the software system.

[0113] As can be seen from the above embodiments, this application reverse-engineers the functional architecture of the software to be generated, associates and annotates the code generation subtasks with functional components, and explicitly discloses the coding constraints executed by each task, generating a visualized security report, which effectively solves the problems of lagging security considerations and high manual auditing costs.

[0114] like Figure 3As shown, a software code generation apparatus according to one aspect of this application includes a multimodal requirement awareness model 5100, a semantic alignment and fusion planning model 5200, a task decomposition and scheduling model 5300, and a security-enhanced code generation model 5400. The multimodal requirement awareness model 5100 is used to respond to code generation driving events and determine the multimodal information corresponding to the event, wherein the multimodal information corresponds to the original software development requirements. The semantic alignment and fusion planning model 5200 is used to semantically align different modal information in the multimodal information and fuse them to generate software functional planning information. The task decomposition and scheduling model 5300 is used to extract each functional planning unit as a code generation subtask of the corresponding code generation type according to the code generation type corresponding to the functional planning unit described by the software functional planning information. The security-enhanced code generation model 5400 is used to call a large language model, execute each code generation subtask, and synchronously trigger corresponding encoding constraint instructions to generate target code.

[0115] Based on any embodiment of the apparatus in this application, the semantic alignment and fusion planning model 5200 includes one or more of the following: The interactive element mapping module is used to identify functional operations in text modal information and interface element components in visual modal information, and to semantically align the functional operations with the interface element components. The state logic association module is used to identify the functional logic in the text modal information and the state of the interface elements in the visual modal information, and to semantically align the functional logic and the state of the interface elements. The attribute constraint binding module is used to identify functional constraints in text modal information and interface element attributes in visual modal information, and to semantically align the functional constraints and interface element attributes.

[0116] Based on any embodiment of the apparatus in this application, the task decomposition and scheduling model 5300 includes: The functional unit parsing module is used to traverse the software function planning information and identify multiple functional planning units in the software function planning information based on semantic integrity. The backend task instantiation module is used to identify the functional planning unit for backend code generation among the multiple functional planning units and create the corresponding backend code generation subtask. The front-end task instantiation module is used to identify the corresponding front-end code generation functional planning unit among the multiple functional planning units and create the corresponding front-end code generation subtask.

[0117] Based on any embodiment of the device in this application, the security-enhanced code generation model 5400 includes: The security rule mapping module is used to match at least one secure coding rule from the preset security rule library for each code generation subtask based on the code generation type corresponding to the code generation subtask. A constraint instruction adaptation module is used to convert the security coding rules into coding constraint instructions that can be recognized by a large language model; The constraint integration and scheduling module is used to embed the encoding constraint instructions into the corresponding code generation subtask, and input the code generation subtask with the encoding constraint instructions into the large language model to generate target code.

[0118] Based on any embodiment of the device in this application, the constraint instruction adaptation module includes: The single constraint coding module is used to convert a single security coding rule into a coding constraint instruction that can be recognized by the large language model when there is only one matching security coding rule. The composite constraint synthesis module is used to combine multiple security coding rules into a single composite security coding rule when there are multiple matching security coding rules, and then convert this composite security coding rule into a coding constraint instruction that can be recognized by the large language model.

[0119] Based on any embodiment of the apparatus in this application, the security-enhanced code generation model 5400, following this, includes: The change monitoring and capture module is used to respond to code modification-driven events on the target code and determine the corresponding code modification information for the event. The task model incremental update module is used to modify the corresponding code to generate subtasks based on the code modification information. The constraint-preserving regeneration module is used to call the large language model, execute the modified code generation subtask, and synchronously trigger the corresponding encoding constraint instructions to generate the modified target code.

[0120] Based on any embodiment of the apparatus in this application, the security-enhanced code generation model 5400, following this, includes: The software architecture modeling module is used to determine the functional architecture of the software to be generated based on the software function planning information. The functional architecture represents multiple functional components of the software to be generated and the relationships between these components. The security association mapping and report generation module is used to associate and label the code generation subtask with the functional component, and to label the code generation subtask with matching coding constraints to generate a security report.

[0121] like Figure 4As shown, another embodiment of this application also provides an electronic device, wherein the internal structure of the electronic device is illustrated. The electronic device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database may store a sequence of control information. When the computer-readable instructions are executed by the processor, the processor can implement the software code generation method described in this application. The processor of the electronic device provides computing and control capabilities to support the operation of the entire electronic device. The memory of the electronic device may store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor can execute the software code generation method described in this application. The network interface of the electronic device is used for communication with a terminal. Those skilled in the art will understand that... Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the electronic device to which the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.

[0122] In this execution method, the processor is used for execution. Figure 3 The specific functions of each module and its submodules are defined within the system. The memory stores the program code and various data required to execute these modules or submodules. The network interface is used for data transmission between the user terminal and the server. In this execution method, the memory stores the program code and data required to execute all modules / submodules in the software code generation device of this application. The server can call the server's program code and data to execute the functions of all submodules.

[0123] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the method described in any embodiment of this application.

[0124] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The aforementioned storage medium can be a computer-readable storage medium such as a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM).

[0125] The above description is only a partial implementation method of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A software code generation method, characterized in that, include: Respond to the code generation driver event and determine the corresponding multimodal information, which corresponds to the original software development requirements; Semantically align the different modal information in the multimodal information and fuse them to generate software function planning information; Based on the code generation type corresponding to the functional planning unit described in the software functional planning information, each functional planning unit is extracted as a code generation subtask of the corresponding code generation type. The large language model is invoked to execute various code generation subtasks and simultaneously trigger corresponding encoding constraint instructions to generate target code.

2. The software code generation method according to claim 1, characterized in that, The semantic alignment of different modal information in the multimodal information includes one or more of the following: Identify functional operations in text modal information and interface element components in visual modal information, and semantically align the functional operations and interface element components. Identify the functional logic in the text modal information and the interface element state in the visual modal information, and semantically align the functional logic and the interface element state. Identify functional constraints in text modal information and interface element attributes in visual modal information, and semantically align the functional constraints and interface element attributes.

3. The software code generation method according to claim 1, characterized in that, The step of extracting each functional planning unit as a code generation subtask of the corresponding code generation type based on the code generation type corresponding to the functional planning unit described in the software functional planning information includes: Traverse the software function planning information and identify multiple functional planning units in the software function planning information based on semantic integrity; Identify the functional planning unit that corresponds to backend code generation among the multiple functional planning units, and create the corresponding backend code generation subtask; Identify the functional planning unit corresponding to front-end code generation among the multiple functional planning units, and create the corresponding front-end code generation subtask.

4. The software code generation method according to claim 1, characterized in that, The process of calling the large language model, executing various code generation subtasks and synchronously triggering corresponding encoding constraint instructions to generate target code includes: Based on the code generation type corresponding to the code generation subtask, at least one secure coding rule is matched from the preset security rule base for each code generation subtask; The security coding rules are then converted into coding constraint instructions that can be recognized by a large language model; The encoding constraint instructions are embedded into the corresponding code generation subtask, and the code generation subtask with the encoding constraint instructions is input into the large language model to generate the target code.

5. The software code generation method according to claim 4, characterized in that, The step of converting the security coding rules into coding constraint instructions recognizable by a large language model includes: When there is only one matching security coding rule, that security coding rule is converted into a coding constraint instruction that can be recognized by the large language model; When there are multiple matching security coding rules, the multiple security coding rules are combined into a composite security coding rule, and the composite security coding rule is converted into a coding constraint instruction that can be recognized by the large language model.

6. The software code generation method according to claim 1, characterized in that, The process of calling the large language model, executing various code generation subtasks and synchronously triggering corresponding encoding constraint instructions to generate the target code includes: In response to a code modification-driven event affecting the target code, determine the corresponding code modification information. Based on the code modification information, modify the corresponding code to generate subtasks; The large language model is invoked to execute the modified code generation subtask and simultaneously trigger the corresponding encoding constraint instructions to generate the modified target code.

7. The software code generation method according to any one of claims 1 to 6, characterized in that, The process of calling the large language model, executing various code generation subtasks and synchronously triggering corresponding encoding constraint instructions to generate the target code includes: Based on the software function planning information, the functional architecture of the software to be generated is determined. The functional architecture represents multiple functional components of the software to be generated and the relationships between these components. The code generation subtask is associated with the functional component and labeled with matching coding constraints to generate a security report.

8. A software code generation device, characterized in that, include: A multimodal requirement awareness model is used to respond to code generation-driven events and determine the corresponding multimodal information, which corresponds to the original software development requirements. A semantic alignment and fusion planning model is used to semantically align different modal information in the multimodal information and fuse them to generate software function planning information. The task decomposition and scheduling model is used to extract each functional planning unit as a code generation subtask of the corresponding code generation type based on the code generation type corresponding to the functional planning unit described in the software functional planning information. The security-enhanced code generation model is used to call the large language model, execute various code generation subtasks, and synchronously trigger corresponding coding constraint instructions to generate target code.

9. An electronic device comprising a central processing unit and a memory, characterized in that, The central processing unit is used to invoke and run a computer program stored in the memory to perform the steps of the method as described in any one of claims 1 to 7.

10. A non-volatile storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 7, which, when invoked by a computer, executes the steps included in the corresponding method.