Component code generation method, computer device and storage medium
By parsing user intent and generating component code using a large language model, this technology solves the problems of low efficiency and accuracy in component code generation in existing technologies, enabling efficient generation of personalized component code for merchants and meeting the aesthetic requirements of store pages.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU SHANGYUN NETWORK TECH CO LTD
- Filing Date
- 2026-05-28
- Publication Date
- 2026-07-14
AI Technical Summary
Existing website building tools cannot dynamically generate or adjust component code based on users' natural language descriptions of functional or style requirements, resulting in low efficiency and accuracy in component code generation, making it difficult to meet merchants' needs for personalization and aesthetics of store pages.
By acquiring users' component requirements information, using a large language model to parse code style and historical dialogue, and combining preset reference information to generate component code that conforms to the target theme specifications, the process is divided into two stages: user intent understanding and code generation. Two large language model processes are used to improve generation efficiency and accuracy.
It enables the automatic generation of component code that conforms to the target theme specification based on the merchant's natural language description, which improves the efficiency and accuracy of component code generation, alleviates the syntax and formatting problems of large language models when generating domain-specific languages, and improves website building efficiency.
Smart Images

Figure CN122387461A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of artificial intelligence technology, and relates to data processing technology, and in particular to a component code generation method, computer equipment and storage medium. Background Technology
[0002] Existing website building tools typically only provide preset, fixed static components. Users complete page building by dragging and dropping or configuring parameters. The entire process requires manual code generation and adjustment for each component, which is inefficient and inaccurate. Summary of the Invention
[0003] This application provides a component code generation method, computer device, and storage medium to improve the problem of low efficiency and accuracy in component code generation.
[0004] In a first aspect, embodiments of this application provide a component code generation method, which includes: in response to component requirement information input by a user, obtaining topic code and session code; determining code style based on topic code, and determining historical dialogue, historical component code, and first reference information based on session code; based on component requirement information, code style, and historical dialogue, invoking a preset first language model to determine the validity of component requirement information, code preference information, and second reference information; if the component requirement information is determined to be a valid requirement based on validity, determining a target reference code based on historical component code, first reference information, and second reference information; and based on preset prior information, code preference information, target reference code, and component requirement information, invoking a preset second language model to determine the component code.
[0005] In some embodiments, determining the code style based on the theme code includes: parsing the theme code, determining the style attributes corresponding to the theme code, wherein the style attributes include at least one of color attributes, font attributes, and line spacing attributes; and determining the code style based on the style attributes.
[0006] In some embodiments, the method for determining historical dialogues includes: selecting a preset number of initial historical dialogues based on the session encoding and dialogue time; and determining the dialogue content output by the target object in the initial historical dialogues as historical dialogues.
[0007] In some embodiments, determining a target reference code based on historical component code, first reference information, and second reference information includes: using the historical component code as the target reference code when the historical component code and the first reference information are not empty and the first reference information and the second reference information are the same; and determining the target reference code based on the second reference information when the historical component code is empty or the first reference information and the second reference information are different.
[0008] In some embodiments, determining a target reference code based on second reference information includes: determining a reference code name based on the second reference information; and selecting a reference code corresponding to the reference code name from a preset reference code library as the target reference code.
[0009] In some embodiments, determining the target reference code based on the second reference information further includes: determining the description vector corresponding to the reference code based on the second reference information; selecting a target description vector from a preset reference code library whose vector distance to the description vector is less than or equal to a distance threshold, and using the reference code corresponding to the target description vector as the target reference code.
[0010] In some embodiments, after determining the component code, the method further includes: correcting the component code according to preset code correction information to obtain corrected component code; and generating a component based on the corrected component code.
[0011] In some embodiments, the method further includes: if the component requirement information is determined to be an invalid requirement based on validity, outputting guidance information indicating that the component requirement information is outside the scope of support.
[0012] Secondly, embodiments of this application provide a component code generation apparatus, comprising: a requirement response module, configured to obtain topic code and session code in response to component requirement information input by a user; an information determination module, configured to determine code style based on topic code, and determine historical dialogue, historical component code, and first reference information based on session code; a model processing module, configured to determine the validity of component requirement information, code preference information, and second reference information by invoking a preset first major language model based on component requirement information, code style, and historical dialogue; a reference determination module, configured to determine a target reference code based on historical component code, first reference information, and second reference information when the component requirement information is determined to be a valid requirement based on validity; and a model processing module, further configured to determine component code by invoking a preset second major language model based on preset prior information, code preference information, target reference code, and component requirement information.
[0013] Thirdly, embodiments of this application provide a computer device, which includes a controller and a memory. The controller is used to implement the component code generation method as described above when executing a computer program stored in the memory.
[0014] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a controller of a computer device, implements the component code generation method as described above.
[0015] In the component code generation method provided in this application embodiment, in response to component requirement information input by the user, topic code and session code are obtained; based on the topic code, code style is determined, and based on the session code, historical dialogues, historical component codes, and first reference information are determined; based on the component requirement information, code style, and historical dialogues, a preset first language model is invoked to determine the validity of the component requirement information, code preference information, and second reference information; if the component requirement information is determined to be a valid requirement based on validity, a target reference code is determined based on historical component codes, the first reference information, and the second reference information; based on preset prior information, code preference information, the target reference code, and component requirement information, a preset second language model is invoked to determine the component code. This application utilizes component code that automatically generates conforming to target theme specifications based on the component requirements described in the merchant's natural language, thereby improving the efficiency of component code generation. Furthermore, this application divides component code generation into two stages: user intent understanding and code generation. The first language model analyzes component requirement information, code style, and historical dialogues to determine user intent. The second language model processes pre-defined prior information, code preference information, target reference code, and component requirement information to generate component code. This two-stage language model processing effectively alleviates the illusion problems caused by sparse training data when generating domain-specific languages, such as fabricated non-grammatical structures, misused parameters, and format violations, thus improving the accuracy of component code generation. Attached Figure Description
[0016] Figure 1 This is an application scenario diagram of a component code generation method provided in some embodiments of this application.
[0017] Figure 2 This is a flowchart of a component code generation method provided in some embodiments of this application.
[0018] Figure 3 This is a flowchart illustrating a method for determining historical dialogues provided in some embodiments of this application.
[0019] Figure 4 This is a schematic diagram of the component code generation process provided in some embodiments of this application.
[0020] Figure 5 This is a schematic diagram of the structure of a component code generation apparatus provided in some embodiments of this application.
[0021] Figure 6 This is an application device diagram of the component code generation method provided in some embodiments of this application. Detailed Implementation
[0022] It should be noted that the terms "first" and "second" in the specification, claims and drawings of this application are used to distinguish similar objects, rather than to describe a specific order or sequence.
[0023] It should also be noted that the methods disclosed in the embodiments of this application or the methods shown in the flowcharts include one or more steps for implementing the method. Without departing from the scope of the claims, the execution order of multiple steps can be interchanged, and some steps can also be deleted.
[0024] Existing website building tools typically only provide pre-set, fixed static components and lack the ability to understand and respond to natural language interactions. They cannot dynamically generate or adjust component code based on user-described functional or style requirements in natural language. Therefore, users can only complete page building by dragging and dropping or configuring parameters. The entire process requires manual code generation and adjustment for each component, resulting in low efficiency and accuracy, and making it difficult to achieve fine-grained, highly flexible customized website building.
[0025] This technical issue is particularly prominent against the backdrop of the rapid development of independent websites. Merchants are increasingly demanding personalization and aesthetics for their store pages, hoping to quickly generate or adjust components in the theme according to their own needs in order to increase the total transaction volume of their stores. Taking the theme template system of a certain e-commerce platform (referred to as the Sline theme in this application) as an example, the existing technology has the following shortcomings: existing website building tools can only provide fixed static components, which cannot meet the flexible customization needs based on natural language; at the same time, the general code model lacks the specific context, theme style and prior knowledge of the Sline theme, and the code it directly generates often cannot be run directly in the Sline theme, and is prone to syntax or filter usage errors.
[0026] In view of the above problems, this application provides a component code generation method, computer equipment and storage medium, which automatically generates component code that conforms to the target theme specification based on the component requirement information described by the merchant in natural language, thereby improving the efficiency of component code generation and accelerating website building efficiency.
[0027] Some embodiments will now be described with reference to the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0028] Figure 1 This is an application scenario diagram of a component code generation method provided in some embodiments of this application. For example... Figure 1 As shown, as a feasible embodiment, the component code generation method provided in this application can be applied to computer device 10. The computer device 10 can be, for example, as shown in the diagram. Figure 1The server shown is illustrated. Computer device 10 can be connected to user terminal 20 via a network. The network serves as a medium for providing a communication link between computer device 10 and user terminal 20. The network can include various connection types, such as wired communication links, wireless communication links, etc., and this embodiment does not limit the types.
[0029] Figure 1 The computer device 10, network, and user terminal 20 shown are merely illustrative. The computer device 10 can be a physical server or a server cluster consisting of multiple servers, and the user terminal 20 can be a mobile phone, tablet, desktop computer, laptop computer, or other devices. Furthermore, by way of example, embodiments of this application may also allow multiple user terminals 20 to access the computer device 10.
[0030] In some embodiments, the technical solution of this application uses the operating environment of an e-commerce service platform as its application environment, and builds an e-commerce service platform in computer device 10. The e-commerce service platform can be an e-commerce service platform that offers open independent website services, such as a cross-border e-commerce service platform. An independent website refers to a new type of official website (website) built on a Software-as-a-Service (SaaS) technology platform, possessing an independent domain name, proprietary content, data, and rights, independent operational sovereignty and responsibility, supported by socialized cloud computing capabilities, and capable of independently and freely connecting to third-party software tools, promotional media, and channels. Typically, product sellers build and operate online stores on independent websites, enabling these stores to display their products and provide e-commerce services to buyers (i.e., users), such as searching for products, adding items to their cart, checkout, logistics delivery, order placement, after-sales service, and product combination recommendations.
[0031] In some embodiments, the user terminal 20, connected to the computer device 10, can access the theme editor on the computer device 10 and use the theme editor to build and optimize an online store. For example, a user accesses the theme editor on the computer device 10 through the user terminal 20 and inputs component requirement information described in natural language, such as: "I want a countdown promotion component with a bright red background." The computer device 10, according to the component code generation method provided in this application, parses the component requirement information, obtains the user's current environment (including at least theme code and session encoding), generates the required component code, and sends it to the user terminal 20. The user can preview the component code through the user terminal 20 and trigger the application of the component code to the online store. If the computer device 10 detects that the component requirement information input by the user in the theme editor is invalid, it outputs guidance information indicating that the component requirement information exceeds the supported range.
[0032] In the computer device 10 provided in the embodiments of this application, the computer device 10 can automatically generate component code that conforms to the target theme specification based on the component requirement information described by the merchant in natural language, thereby improving the efficiency of component code generation and accelerating website building efficiency.
[0033] Figure 2 This is a flowchart illustrating a component code generation method provided in some embodiments of this application. This component code generation method is applied to computer devices (e.g., Figure 1 Computer equipment 10). For example Figure 2 As shown, the component code generation method may include the following steps S11-S15.
[0034] S11, in response to the component requirement information input by the user, obtain the theme code and session code.
[0035] In some embodiments, component requirement information can be a natural language description representing the user's design requirements for the component. Component requirement information may include one or more of the component's functional requirements, style requirements, and structural requirements. It may also include design requirements for the style attributes of the component code. Functional requirements describe the specific business logic or interactive behavior that the component should implement, such as data acquisition, state management, or event response. Style requirements describe the component's visual appearance attributes, including layout, color, font, spacing, and animation. Structural requirements define the component's hierarchical relationship and content arrangement rules. For example, component requirement information could be: "I want a countdown promotion component with a bright red background."
[0036] In some embodiments, the topic code represents the design code of the online store, and the session code represents a unique identifier generated by the computer device to identify an independent interaction. The session code can be a string or a number, without limitation. For example, in response to a user's creation of a new session, the computer device generates a session code uniquely corresponding to that session. The user can interact within the session identified by this session code until, in response to the next creation of a new session, the computer device generates a new session code.
[0037] In some embodiments, after receiving component requirement information input by the user, the theme code of the component corresponding to the component requirement information and the session code at the time of inputting the component requirement information are obtained. For example, the component requirement information is parsed to determine the online store where the component corresponding to the component requirement information is located, and the design code of the online store is obtained. If the user performed a new session operation before inputting the component requirement information, the newly generated session code of the computer device is used as the session code corresponding to the component requirement information. If the user did not perform a new session operation before inputting the component requirement information, the most recently generated session code of the computer device is used as the session code corresponding to the component requirement information.
[0038] S12 determines the code style based on topic code, and determines historical dialogues, historical component codes, and first reference information based on session coding.
[0039] In some embodiments, by parsing the theme code, the code style can be determined, and subsequent component code is generated based on the code style to ensure visual consistency among the component code. The code style represents the global style information of the theme code and may include style attributes of the theme code. Therefore, determining the code style based on the theme code includes: parsing the theme code to determine the style attributes corresponding to the theme code, whereby style attributes include at least one of color attributes, font attributes, and line spacing attributes; and determining the code style based on the style attributes.
[0040] In some embodiments, the theme code contains preset fields that describe the style attributes of the code. These style attributes include, but are not limited to, color attributes, font attributes, line spacing attributes, font size attributes, and layout methods. By querying the preset fields, the style attributes of the theme code can be determined, and these style attributes can be identified as the code style.
[0041] This application embodiment parses the theme code to determine the code style, so that the subsequently generated component code is consistent with the code style, thereby improving the generation effect of component code.
[0042] In some embodiments, based on session coding, it is detected whether there is a historical dialogue associated with the session coding, and whether there is a historical component code and its first reference information associated with the session coding. The historical dialogue represents the dialogue between the user and the computer device before the user inputs component requirement information under the same session coding. The historical component code represents the component code generated by the computer device before the user inputs component requirement information under the same session coding. The first reference information represents relevant information about the reference code corresponding to the historical component code. For example, the first reference information includes the reference code name, code, and description vector corresponding to the reference code, etc. The reference code can be uniquely identified through the first reference information. The reference code can represent the design code corresponding to the component template. To improve the efficiency of component code generation, multiple component templates are pre-set, and each component template has a corresponding reference code. Multiple reference codes are stored in a preset database to obtain a reference code library.
[0043] This application embodiment determines historical dialogues, historical component codes, and their first reference information through session coding, and determines whether the user is fine-tuning the historically generated component code or generating new component code, thereby determining the user's intent, facilitating the generation of component code according to the user's intent, and improving the generation effect of component code.
[0044] S13, based on component requirement information, code style, and historical dialogue, calls the preset first language model to determine the validity of component requirement information, code preference information, and second reference information.
[0045] In some embodiments, component requirement information, code style, and historical dialogues are used as input data to the Large Language Model, and the validity of component requirement information, code preference information, and second reference information are used as output data to the Large Language Model. The Large Language Model (LLM) refers to a neural network model based on a deep learning architecture, pre-trained on massive amounts of text data, and possessing natural language understanding and generation capabilities. The Large Language Model can be Generative Pre-trained Transformer 5.1 (GPT-5.1), General Language Model 5 (GLM-5), Llama-3, DeepSeek Coder, etc., and is not limited here.
[0046] In some embodiments, the validity of component requirement information indicates whether the component requirement information is information related to the component. Validity includes valid and invalid. When the validity indicates that the component requirement information is a valid requirement, it indicates that the component requirement information is information related to the component. When the validity indicates that the component requirement information is an invalid requirement, it indicates that the component requirement information is information unrelated to the component. For example, the component requirement information contains meaningless characters or is casual chat that is beyond the scope of website building.
[0047] In some embodiments, code preference information represents the user's style design preferences for component code. For example, code preference information includes information such as the user's preferred colors, fonts, line spacing, font size, and layout.
[0048] In some embodiments, the second reference information represents the relevant information of the reference code generated after the first language model parses the component requirement information. For example, the second reference information includes the reference code name, encoding, description vector corresponding to the reference code, etc. The reference code can be uniquely identified through the second reference information.
[0049] S14, if the component requirement information is determined to be a valid requirement based on validity, the target reference code is determined based on the historical component code, the first reference information, and the second reference information.
[0050] In some embodiments, when the component requirement information is determined to be a valid requirement based on validity, a target reference code is determined based on historical component codes, first reference information, and second reference information. When the component requirement information is determined to be an invalid requirement based on validity, guidance information is output, indicating that the component requirement information exceeds the supported range. This embodiment of the application outputs guidance information when the component requirement information is invalid, enabling the user to adjust the component requirement information in a timely manner.
[0051] In some embodiments, a component fine-tuning condition is detected based on historical component code, first reference information, and second reference information. If the detection result indicates that the component fine-tuning condition has been triggered, the historical component code can be used as the reference code, i.e., the target reference code, for the generated component code. If the detection result indicates that the component fine-tuning condition has not been triggered, the reference code for the generated component code can be determined based on the second reference information generated by the first language model. Here, triggering the component fine-tuning condition indicates that the user expects to fine-tune a historically generated component or component code, while not triggering the component fine-tuning condition indicates that the user expects to generate a new component.
[0052] For example, determining the target reference code based on the historical component code, the first reference information, and the second reference information includes: when the historical component code and the first reference information are not empty, and the first reference information and the second reference information are the same, using the historical component code as the target reference code; when the historical component code is empty, or the first reference information and the second reference information are different, determining the target reference code based on the second reference information.
[0053] In cases where the historical component code and the first reference information are not empty, and the first reference information is identical to the second reference information, it indicates that the user's intention is to fine-tune the historically generated component and / or component code. Therefore, the component requirement information includes fine-tuning information based on the historically generated component and / or component code. This could involve fine-tuning one or more of the functionality, style, and structure of the historically generated component, or fine-tuning the style attributes of the historically generated component code. For example, the component requirement information could be incremental fine-tuning instructions such as "make the color darker" or "add a shadow." In this case, the historical component code is used as the target reference code, allowing subsequent generation of the component code corresponding to the component requirement information based on the target reference code.
[0054] In cases where the historical component code is empty, or the first reference information and the second reference information are different, it indicates that the user intends to generate a new component. Thus, the component requirement information includes one or more of the functional requirements, style requirements, and structural requirements that the user expects to generate the new component. The component requirement information may also include the user's design requirements for the style attributes of the component code. In this way, the target reference code is determined based on the second reference information.
[0055] Based on historical component code, first reference information, and second reference information, this application determines whether the user's intention is to fine-tune historically generated components and / or component code or to generate new components. When the user's intention is to fine-tune historically generated components and / or component code, the historical component code is used as the target reference code. This enables smooth modification based on historical component code, avoids generating from scratch each time, and improves the stability of component iteration.
[0056] In some embodiments, a target reference code can be selected from a reference code library based on the second reference information. For example, determining the target reference code based on the second reference information includes: determining a reference code name based on the second reference information; and selecting a reference code corresponding to the reference code name from a preset reference code library as the target reference code. The second reference information includes the reference code name, and the target reference code can be obtained by selecting the reference code corresponding to the reference code name from the reference code library.
[0057] The embodiments of this application determine the target reference code by referring to the code name, which can improve the accuracy and efficiency of the target reference code determination.
[0058] In other embodiments, the second reference information may include, in addition to the reference code name, a description vector corresponding to the reference code. The code description information of the reference code is vectorized to obtain the description vector. The code description information includes information such as the style attributes of the component corresponding to the code. For example, determining the target reference code based on the second reference information further includes: determining the description vector corresponding to the reference code based on the second reference information; selecting a target description vector from a preset reference code library whose vector distance to the description vector is less than or equal to a distance threshold, and using the reference code corresponding to the target description vector as the target reference code.
[0059] The reference code library includes reference codes and their description vectors. By calculating the vector distance between the description vector corresponding to the second reference information and the description vector corresponding to each reference code in the reference code library, description vectors whose vector distance is less than or equal to a distance threshold are selected from the reference code library as target description vectors. The reference code corresponding to the target description vector is then used as the target reference code. The distance threshold can be set according to actual needs and is not limited here.
[0060] This application implements semantic similarity matching through vectors, avoiding matching failures caused by differences in name descriptions, and improving the robustness and generalization ability of matching.
[0061] S15: Based on preset prior information, code preference information, target reference code, and component requirement information, the preset second language model is invoked to determine the component code.
[0062] In some embodiments, the Large Language Model (LLM) refers to a neural network model based on a deep learning architecture, pre-trained on massive amounts of text data, and possessing the ability to understand and generate natural language. The Large Language Model can be Generative Pre-trained Transformer 5.1 (GPT-5.1), General Language Model 5 (GLM-5), Llama-3, DeepSeek Coder, etc., and is not limited thereto.
[0063] In some embodiments, preset prior information, code preference information, target reference code, and component requirement information are used as input data for the second language model, and component code is used as output data for the second language model. The preset prior information may include, but is not limited to, proprietary syntax rules, tag rules, filter definitions, theme configuration structures, and data binding methods followed by a specific website building or component development environment.
[0064] In the component code generation method provided in this application embodiment, component code conforming to the target theme specification is automatically generated based on the component requirements described in the merchant's natural language, thereby improving the efficiency of component code generation. In addition, this application divides component code generation into two stages: user intent understanding and code generation. By parsing component requirement information, code style, and historical dialogue through a first large language model, user intent can be determined. By processing preset prior information, code preference information, target reference code, and component requirement information through a second large language model, component code can be generated. Through the two large language model processes, the illusion problems such as fabricated non-grammatical structures, misused parameters, and format violations caused by the sparsity of training data when the large language model generates domain-specific languages can be effectively alleviated, thereby improving the accuracy of component code generation.
[0065] In some embodiments, historical dialogue represents the dialogue content after noise reduction. Figure 3 This is a flowchart illustrating a method for determining historical dialogues provided in some embodiments of this application. The method for determining historical dialogues is applied to computer devices. Figure 3 As shown, the steps include the following.
[0066] S21. Select a preset number of initial historical dialogues based on the session code and dialogue time.
[0067] In some embodiments, the preset number represents the maximum number of dialogues output by both parties in the selected dialogue. The preset number can be set according to actual needs; for example, the preset number can be 15, 18, 20, 22, etc., and there is no limitation here. Based on the session code and dialogue time, the preset number of initial historical dialogues associated with the session code and whose time is closest to the user output component requirement information are selected.
[0068] S22, the dialogue content output by the target object in the initial historical dialogue is determined as the historical dialogue.
[0069] In some embodiments, the two parties to the dialogue include a computer device and a user, and the target object can be the user. The user's dialogue content from the initial historical dialogue is determined as the historical dialogue; that is, the user's output information is retained, while the computer device's responses are discarded.
[0070] This application embodiment filters a preset number of initial historical dialogues and determines the dialogue content of the target object from the initial historical dialogues as historical dialogues. This can preserve the user's intention evolution trajectory, reduce the number of model processing steps, and improve model processing efficiency.
[0071] In some embodiments, to compensate for minor grammatical errors in the large language model, after determining the component code, the method further includes: correcting the component code according to preset code correction information to obtain corrected component code; and generating a component based on the corrected component code.
[0072] The preset code correction information includes predefined error patterns and corresponding correction rules. Error patterns represent incorrect usage types of language filters, as well as common symbol omissions or misalignments. For example, error patterns may include misspelled filter names, missing or incorrectly ordered parameters, etc., while symbol omissions or misalignments may include missing closing symbols such as "}", "]", or ">". Correction rules represent standardized replacement or completion strategies for error patterns, such as automatically detecting and supplementing missing closing symbols, such as complete {}, [], or <>. Based on the preset code correction information, the component code is corrected, automatically completing syntax-level repairs.
[0073] This application embodiment improves the accuracy of component code by automatically correcting common errors in the code through modification processing.
[0074] Please see Figure 4 , Figure 4 This is a schematic diagram illustrating the component code generation process provided in some embodiments of this application. For example... Figure 4 As shown, the user inputs component requirement information, and the computer device responds by obtaining the topic code and session code. Code style is extracted from the topic code in a structured manner, and the existence of an initial historical dialogue associated with the session code is detected. If no initial historical dialogue exists, empty data is returned. If an initial historical dialogue exists, a preset number of initial historical dialogues are selected, and the dialogue content output by the target object is selected from these initial historical dialogues as historical dialogues to determine the historical component code and the first reference information.
[0075] The system takes historical dialogues, historical component codes, and first reference information as input data to the first language model, calls the first language model, and outputs the validity of component requirement information, code preference information, and second reference information.
[0076] The system checks whether the component requirement information is valid. If the requirement is determined to be invalid, it returns guidance information to the user and interrupts the process. If the requirement is valid, it checks whether the historical component code and the first reference information are not empty, and whether the first and second reference information are the same. If the historical component code and the first reference information are not empty, and both are the same, the historical component code is used as the target reference code. If the historical component code is empty, or the first and second reference information are different, the system queries a preset reference code library based on the second reference information to determine the target reference code.
[0077] The system takes predefined prior information, code preference information, target reference code, and component requirement information as input data to the second language model, and then calls the second language model to generate component code. The component code is then corrected, including correcting filter errors and adding missing curly braces, angle brackets, etc., resulting in corrected component code, which is then returned to the user.
[0078] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of a component code generation apparatus provided in some embodiments of this application. In some embodiments, the component code generation apparatus 100 may include multiple functional modules composed of computer program segments. The computer programs of each program segment in the component code generation apparatus 100 may be stored in the memory of the computer device 10 and executed by at least one controller to perform (see details). Figure 2 (Description) The function of component code generation.
[0079] In some embodiments, the component code generation apparatus 100 can be divided into multiple functional modules according to the functions it performs. The functional modules may include: a demand response module 101, an information determination module 102, a model processing module 103, and a reference determination module 104. As used in this application, a module refers to a series of computer program segments that can be executed by at least one controller and perform a fixed function, and which are stored in memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
[0080] The requirement response module 101 can be used to respond to component requirement information input by the user and obtain topic code and session code.
[0081] The information determination module 102 can be used to determine the code style based on topic code, and to determine historical dialogues, historical component codes, and first reference information based on session encoding.
[0082] The model processing module 103 can be used to determine the validity of the component requirement information, code preference information, and second reference information by calling the preset first language model based on component requirement information, code style, and historical dialogue.
[0083] The reference determination module 104 can be used to determine the target reference code based on historical component codes, first reference information, and second reference information when the component requirement information is determined to be a valid requirement based on validity.
[0084] The model processing module 103 can also be used to determine the component code by calling a preset second language model based on preset prior information, code preference information, target reference code and component requirement information.
[0085] In some embodiments, the information determination module 102 may include: an attribute parsing submodule, used to parse the theme code and determine the style attributes corresponding to the theme code, wherein the style attributes include at least one of color attributes, font attributes and line spacing attributes; and a style determination submodule, used to determine the code style based on the style attributes.
[0086] In some embodiments, the information determination module 102 may further include: a dialogue selection submodule, used to select a preset number of initial historical dialogues based on the dialogue encoding and dialogue time; and an object selection submodule, used to determine the dialogue content output by the target object in the initial historical dialogue as a historical dialogue.
[0087] In some embodiments, the reference determination module 104 may include: a condition judgment submodule, configured to use the historical component code as the target reference code when the historical component code is not empty and the first reference information is the same as the second reference information; the condition judgment submodule is further configured to determine the target reference code based on the second reference information when the historical component code is empty or the first reference information is different from the second reference information.
[0088] In some embodiments, the reference determination module 104 may further include: a name determination submodule, used to determine a reference code name based on the second reference information; and a code selection submodule, used to select a reference code corresponding to the reference code name from a preset reference code library as a target reference code.
[0089] In some embodiments, the reference determination module 104 may further include: a vector determination submodule, configured to determine the description vector corresponding to the reference code based on the second reference information; and a code selection submodule, configured to select a target description vector from a preset reference code library whose vector distance to the description vector is less than or equal to a distance threshold, and to use the reference code corresponding to the target description vector as the target reference code.
[0090] In some embodiments, the information determination module 102 may further include: a correction processing submodule, used to correct the component code according to preset code error correction information to obtain corrected component code; and a component generation submodule, used to generate a component based on the corrected component code.
[0091] In some embodiments, the model processing module 103 may further include: a guidance output submodule, configured to output guidance information when the component requirement information is determined to be an invalid requirement based on validity, the guidance information indicating that the component requirement information exceeds the support range.
[0092] It is understood that the component code generation device 100 and the component code generation method of the above embodiments belong to the same inventive concept. The specific implementation of each module of the component code generation device 100 corresponds to each step of the component code generation method in the above embodiments, and will not be repeated here.
[0093] The module division described above is a logical functional division, and other division methods may be used in actual implementation. Furthermore, the functional modules in the various embodiments of this application can be integrated into the same processing unit, or each module can exist physically separately, or two or more modules can be integrated into the same unit. The integrated modules described above can be implemented in hardware or in a combination of hardware and software functional modules.
[0094] Figure 6 These are application device diagrams illustrating the component code generation method provided in some embodiments of this application. For example... Figure 6 As shown, the computer device 10 includes a memory 11, at least one controller 12, and at least one communication bus 13. The controller 12 is used to implement a component code generation method when executing a computer program stored in the memory 11. The at least one communication bus 13 is configured to enable communication between the memory 11 and the at least one controller 12.
[0095] Figure 6 The structure of the computer device shown does not constitute a limitation on the embodiments of this application. The computer device 10 may also include more or fewer other hardware or software, or different component arrangements than shown.
[0096] In some embodiments of this application, the computer device 10 may also be connected to a client device, which includes, but is not limited to, any electronic product that can interact with the user via a keyboard, mouse, remote control, touchpad or voice control device, such as a personal computer, tablet computer, smartphone, digital camera, etc.
[0097] It should be noted that computer equipment 10 is merely an example. Other existing or future electronic products that are suitable for this application should also be included within the scope of protection of this application and are incorporated herein by reference.
[0098] In some embodiments, the computer device 10 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0099] In some embodiments, the memory 11 stores a computer program that, when executed by at least one controller 12, implements all or part of the steps in the component code generation method. The memory 11 includes read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.
[0100] In some embodiments, the computer-readable storage medium may primarily include a stored program area and a stored data area, wherein the stored program area may store an operating system, an application program required for at least one function, etc.; and the stored data area may store data created based on the use of the computer device 10, etc.
[0101] In some embodiments, at least one controller 12 is the control unit of the computer device 10, connecting various components of the computer device 10 via various interfaces and lines. It executes programs or modules stored in the memory 11 and calls data stored in the memory 11 to perform various functions and process data within the computer device 10. For example, when at least one controller 12 executes a computer program stored in the memory 11, it implements all or part of the steps of the component code generation method in this application embodiment; or it implements all or part of the functions of the component code generation device. At least one controller 12 may be composed of integrated circuits, such as a single-packaged integrated circuit or multiple integrated circuits with the same or different functions, including one or more central processing units (CPUs), microcontrollers, digital processing chips, graphics controllers, and combinations of various control chips.
[0102] The integrated unit implemented as a software functional module described above can be stored in a computer-readable storage medium. This software functional module, stored in a storage medium, includes several instructions to cause a computer device (which may be a personal computer, computer equipment, or network device, etc.) or controller (processor) to execute portions of the methods of the various embodiments of this application.
[0103] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.
[0104] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0105] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0106] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that it can be implemented in other specific forms without departing from the spirit or essential characteristics of this application. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within this application. No reference numerals in the claims should be construed as limiting the scope of the claims. Furthermore, it is clear that the word "comprising" does not exclude other elements or, and the singular does not exclude the plural. Multiple elements or devices recited in the specification may also be implemented by a single element or device through software or hardware. The terms "first," "second," etc., are used to indicate names and do not indicate any particular order.
[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application and are not intended to limit it. Although this application has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of this application without departing from the spirit and scope of the technical solutions of this application.
Claims
1. A component code generation method, characterized in that, The component code generation method includes: In response to user input regarding component requirements, obtain the theme code and session code; Based on the topic code, the code style is determined, and based on the session encoding, historical dialogues, historical component codes, and first reference information are determined; Based on the component requirement information, the code style, and the historical dialogue, a preset first language model is invoked to determine the validity of the component requirement information, code preference information, and second reference information. If the component requirement information is determined to be a valid requirement based on the validity criteria, a target reference code is determined based on the historical component code, the first reference information, and the second reference information. Based on preset prior information, the code preference information, the target reference code, and the component requirement information, a preset second language model is invoked to determine the component code.
2. The component code generation method as described in claim 1, characterized in that, The process of determining code style based on the topic code includes: Parse the theme code to determine the style attributes corresponding to the theme code. The style attributes include at least one of the following: color attribute, font attribute, and line spacing attribute. The code style is determined based on the style attributes.
3. The component code generation method as described in claim 1, characterized in that, The method for determining the historical dialogues includes: Based on the session encoding and dialogue time, a preset number of initial historical dialogues are selected; The dialogue content output by the target object in the initial historical dialogue is determined as the historical dialogue.
4. The component code generation method as described in claim 1, characterized in that, The determination of the target reference code based on historical component code, first reference information, and second reference information includes: If the historical component code is not empty and the first reference information is the same as the second reference information, the historical component code shall be used as the target reference code. If the historical component code is empty, or if the first reference information is different from the second reference information, the target reference code is determined based on the second reference information.
5. The component code generation method as described in claim 4, characterized in that, Determining the target reference code based on the second reference information includes: Based on the second reference information, determine the reference code name; Select the reference code corresponding to the reference code name from the preset reference code library as the target reference code.
6. The component code generation method as described in claim 4, characterized in that, The step of determining the target reference code based on the second reference information further includes: Based on the second reference information, determine the description vector corresponding to the reference code; Select a target description vector from the preset reference code library whose vector distance to the description vector is less than or equal to a distance threshold, and use the reference code corresponding to the target description vector as the target reference code.
7. The component code generation method as described in claim 1, characterized in that, After determining the component code, the method further includes: Based on preset code correction information, the component code is corrected to obtain the corrected component code; The component is generated based on the revised component code.
8. The component code generation method as described in claim 1, characterized in that, The method further includes: If the component requirement information is determined to be invalid based on the validity criteria, guidance information is output, indicating that the component requirement information is outside the supported range.
9. A computer device, characterized in that, The computer device includes a controller and a memory, wherein the controller is used to implement the component code generation method as described in any one of claims 1 to 8 when executing a computer program stored in the memory.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a controller of a computer device, implements the component code generation method as described in any one of claims 1 to 8.