A code generation method and device, electronic equipment, storage medium and product

By analyzing the project structure and component functions using a large language model, code that meets the requirements is generated, solving the problem of high costs in knowledge base construction and maintenance, and achieving efficient code generation.

CN122111399APending Publication Date: 2026-05-29BEIJING QIYI CENTURY SCI & TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING QIYI CENTURY SCI & TECH CO LTD
Filing Date
2026-01-28
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In software development, the cost and efficiency of building and maintaining knowledge bases are high, which leads to high cost and low efficiency of code generation.

Method used

By using a large language model to analyze the project structure and component functions, code that matches the project type and meets the requirements description text is generated, avoiding the use of knowledge bases.

Benefits of technology

It reduces the manual cost of code generation, improves the efficiency of code generation, and ensures that the generated code matches the project type and meets the requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122111399A_ABST
    Figure CN122111399A_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a code generation method and device, electronic equipment, storage medium and product, relates to the technical field of software development, and the method comprises the following steps: obtaining to-be-utilized information and a requirement description text describing a to-be-updated function of a specified project; the to-be-utilized information comprises project information comprising a project type of the specified project and a component library identifier referenced by the specified project, and attribute information of a generated component in the specified project; the project information is obtained by analyzing the structure of the specified project by using the latest project file of the specified project and a large language model; the attribute information is obtained by performing component function analysis by using the component code file of the generated component in the project file and the large language model; and the large language model is used to generate code of the to-be-updated function matched with the project type and meeting the requirement description text in combination with the attribute information and a component library represented by the component library identifier. The code generation cost can be reduced, and the code generation efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] In software development, such as web and mobile application development, front-end development is often required to provide users with a user interface. For example, RAG (Retrieval-augmented Generation) technology can be used. When front-end code needs to be generated, relevant information can be retrieved from a knowledge base based on user requirements, and then combined with LLM (Large Language Model) to generate the front-end code. This approach requires pre-collecting and organizing relevant information (also known as code knowledge) of the code for each component in an existing component library and storing it in the knowledge base.

[0003] However, knowledge bases require a significant investment of manpower and time in the collection, organization, and maintenance of knowledge. The high labor costs and time required for building and maintaining knowledge bases result in high code generation costs and low efficiency. Summary of the Invention

[0004] The purpose of this application is to provide a code generation method, apparatus, electronic device, storage medium, and product to reduce the manual cost of code generation and improve the efficiency of code generation. The specific technical solution is as follows:

[0005] In a first aspect of this application, a code generation method is provided, the method comprising:

[0006] Obtain the information to be utilized, as well as a description text describing the required updated features for the specified project;

[0007] The information to be utilized includes: project information containing the project type of the specified project and the component library identifier referenced by the specified project, as well as attribute information of the components already generated in the specified project; the project information is obtained by analyzing the structure of the specified project using the latest project file and the first major language model; the attribute information is obtained by analyzing the component functions using the component code files of the generated components in the project file and the second major language model.

[0008] Using the third language model, combined with the attribute information and the component library represented by the component library identifier, code for the function to be updated that matches the project type and conforms to the requirement description text is generated.

[0009] In a second aspect of this application, a code generation apparatus is also provided, the apparatus comprising:

[0010] The data acquisition module is used to acquire information to be utilized, as well as text describing the requirements for the updated functions of a specified project.

[0011] The information to be utilized includes: project information containing the project type of the specified project and the component library identifier referenced by the specified project, as well as attribute information of the components already generated in the specified project; the project information is obtained by analyzing the structure of the specified project using the latest project file and the first major language model; the attribute information is obtained by analyzing the component functions using the component code files of the generated components in the project file and the second major language model.

[0012] The code generation module is used to generate code for the function to be updated that matches the project type and conforms to the requirement description text by utilizing the third language model, combining the attribute information and the component library represented by the component library identifier.

[0013] In a third aspect of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0014] Memory, used to store computer programs;

[0015] The processor, when executing a program stored in memory, implements any of the code generation methods described above.

[0016] In another aspect of this application, a computer-readable storage medium is provided, wherein a computer program is stored therein, and the computer program, when executed by a processor, implements any of the code generation methods described above.

[0017] In another aspect of this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the code generation methods described above.

[0018] The code generation method provided in this application can pre-analyze the project structure of the project (i.e., the specified project) that needs to update its functionality using a large language model (i.e., the first large language model) to obtain project information. It can also use a large language model (i.e., the second large language model) to analyze the component code files of the generated components in the specified project to obtain attribute information. The project information may include the project type and the component library identifiers referenced by the specified project, while the attribute information represents the functionality of the generated components. In other words, the context of the specified project can be pre-analyzed to obtain usable information containing project information and attribute information. When a user needs to update the functionality of the specified project and needs to generate code for the updated functionality, the requirement description text describing the updated functionality can be obtained.

[0019] Furthermore, the third language model can be used, combined with attribute information and component library identifiers, to generate code for the updated functionality that matches the project type and conforms to the requirement description text. In other words, the large language model can be used to process the user information and requirement description text to generate code for the updated functionality that meets user needs and matches the project type of the specified project. Thus, project information and attribute information can be obtained through large language model analysis, and the required code can be generated by combining the large language model with user requirements, project information, and attribute information. This avoids the use of knowledge bases to generate code, eliminating the need for manual maintenance of knowledge bases, reducing the manual cost of code generation, and the high efficiency of large language model analysis also improves the efficiency of code generation. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.

[0021] Figure 1 A flowchart illustrating a code generation method provided in an embodiment of this application;

[0022] Figure 2 This is a schematic diagram of the process for obtaining code style information in the code generation method provided in the embodiments of this application;

[0023] Figure 3 This is a flowchart illustrating the process of obtaining project information in the code generation method provided in this application embodiment;

[0024] Figure 4 This is a flowchart illustrating the process of obtaining attribute information in the code generation method provided in this application embodiment;

[0025] Figure 5 A schematic diagram of the framework for obtaining information to be utilized in the code generation method provided in the embodiments of this application;

[0026] Figure 6 A schematic diagram illustrating the framework of a code generation method provided in an embodiment of this application;

[0027] Figure 7 This is a schematic diagram of the structure of a code generation device provided in an embodiment of this application;

[0028] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0029] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0030] In software development, such as web and mobile application development, front-end development is often required to provide users with a user interface. For example, RAG (Rich Internet Logic) technology can be used to generate front-end code by retrieving relevant information from a knowledge base based on user needs, and then using an LLM (Local Management Model) to combine the retrieved information with the user's requirements. However, this approach requires pre-collecting and organizing existing component library code knowledge and storing it in the knowledge base. Building and maintaining this knowledge base requires significant manpower and time; that is, the labor cost of building and maintaining a knowledge base is high and time-consuming, resulting in high code generation costs and low efficiency.

[0031] To reduce the manual cost of code generation and improve its efficiency, this application provides a code generation method, see [link to relevant documentation]. Figure 1 , Figure 1 This is a flowchart illustrating a code generation method provided in an embodiment of this application. The code generation method may include:

[0032] Step S101: Obtain the information to be utilized, and a description text describing the requirements for the updated functions of the specified project;

[0033] The information to be utilized includes: project information containing the project type of the specified project and the component library identifiers referenced by the specified project, as well as the attribute information of the components already generated in the specified project; the project information is obtained by analyzing the structure of the specified project using the latest project file and the first major language model; the attribute information is obtained by analyzing the component functionality using the component code files of the components already generated in the project file and the second major language model.

[0034] Step S102: Using the third language model, combined with the component library represented by attribute information and component library identifiers, generate code for the function to be updated that matches the project type and meets the requirements description text.

[0035] Based on the above processing, the project structure of the project requiring updated functionality (i.e., the specified project) can be analyzed in advance using the large language model (i.e., the first large language model) to obtain project information. Furthermore, the component code files of the generated components in the specified project can be analyzed using the large language model (i.e., the second large language model) to obtain attribute information. Project information may include the project type and the component library identifiers referenced by the specified project, while attribute information represents the functionality of the generated components. In other words, the context of the specified project can be analyzed in advance to obtain usable information containing project and attribute information. When a user needs to update the functionality of the specified project and needs to generate code for the updated functionality, the requirement description text describing the updated functionality can also be obtained.

[0036] Furthermore, the third language model can be used, combined with attribute information and component library identifiers, to generate code for the updated functionality that matches the project type and conforms to the requirement description text. In other words, the large language model can be used to process the user information and requirement description text to generate code for the updated functionality that meets user needs and matches the project type of the specified project. Thus, project information and attribute information can be obtained through large language model analysis, and the required code can be generated by combining the large language model with user requirements, project information, and attribute information. This avoids the use of knowledge bases to generate code, eliminating the need for manual maintenance of knowledge bases, reducing the manual cost of code generation, and the high efficiency of large language model analysis also improves the efficiency of code generation.

[0037] Regarding step S101, the specified project can be a front-end project that needs to be updated or have new features added. For example, the specified project can be the front-end interface of a webpage or mobile application. The method of creating the specified project is not specifically limited; for example, the specified project can be created in advance by manually writing code, or it can be generated based on user instructions using a large language model with code generation capabilities. Correspondingly, the features to be updated can be new features that the user needs to add to the specified project, or they can be existing features in the specified project that need to be updated. For example, the features to be updated can be new pages, components, JS (JavaScript, a programming language) functions, or dynamic effects to be added, or they can be pages or components already added to the specified project that need to have their display effects updated.

[0038] Users can use natural language to describe the features to be updated for a specific project, resulting in a requirement description text. For example, the requirement description text could be: "I need a user list page that includes a search box, a list of user cards, a pagination component, and the ability to edit user information by clicking on a user card."

[0039] The information to be utilized may include: project information containing the project type of the specified project and the component library identifiers referenced by the specified project, as well as the attribute information of the components already generated in the specified project. The structure of the specified project can be analyzed in advance using the latest project files and the first major language model to obtain project information. The latest project files of the specified project are all files of the current specified project, which may include code files (e.g., component code files of generated components) and various configuration files (e.g., package configuration files, code rule configuration files, environment configuration files, and basic configuration files). Project files can be stored in a preset storage space (i.e., the data source layer in subsequent embodiments). Accordingly, when project files are needed, they can be retrieved from the preset storage space.

[0040] Specifying the project type can also refer to specifying the project framework. For example, the project type can be: Vue (a front-end framework), React (a front-end framework), or Angular (a front-end framework). The specified project can reference open-source component libraries; correspondingly, the project information can also include identifiers of the component libraries referenced by the specified project. For example, the component libraries referenced by the specified project can be Element Plus (a component library), Ant Design Vue (a component library), or Vuetify (a component library).

[0041] The project file may include at least one component code file. One component code file may correspond to one or more generated components. The component code files of the generated components in the project file and the second major language model can be used in advance to perform component function analysis and obtain attribute information. Specifying the attribute information of the generated components in the project can represent the name and function of the generated components. The first major language model, the second major language model, and the major language model in subsequent embodiments can be the same major language model, or they can be different major language models. The type of major language model used in the embodiments of this application is not limited, as long as it can achieve the corresponding function. For example, the major language model can be GPT-4, Qwen-72B, or DeepSeek.

[0042] The information to be used may also include code style information that characterizes the code style of the project files for the specified project. The method for obtaining the code style information can be found in the descriptions of steps S201 and S202 in subsequent embodiments.

[0043] In other words, it can analyze the context of a specified project to obtain usable information including project information, attribute information, and code style information. This allows for the dynamic acquisition of component library information without the need for a pre-built knowledge base, eliminating the costs of knowledge base construction and maintenance. Furthermore, it can automatically identify the project's technology stack and architectural patterns, dynamically adapting to the code styles of different projects—that is, it can achieve project-aware intelligent analysis.

[0044] Regarding step S102, the third language model is used, combined with attribute information and the component library represented by the component library identifier, to generate code for the function to be updated that matches the project type and conforms to the requirement description text. That is, the large language model can be used to generate the required code by combining user requirements, project information, and attribute information. The generated code for the function to be updated matches the project type, ensuring that the code conforms to the framework of the specified project. Furthermore, during the generation of the code for the function to be updated, the large language model can combine attribute information and the component library represented by the component library identifier, allowing for the use of components already generated in the specified project and components in the component library to implement the function to be updated. Thus, the large language model can be used to process the information to be used and the requirement description text to generate code for the function to be updated that meets user needs and matches the project type of the specified project.

[0045] Step S102 can be achieved through either method one or method two:

[0046] In method one, step S102 includes:

[0047] Step 1: Input the requirement description text and the information to be used into the third language model to obtain functional requirement information that matches the requirement description text;

[0048] The obtained functional requirements information includes at least one of the following: the type of function to be updated, the component to be generated to implement the function to be updated, the triggering method of the function to be updated, the data interaction method of the function to be updated, the component to be utilized that matches the reusable component and the component to be generated that does not have a matching component; the reusable component is the component to be generated that has a matching component; the component to be utilized includes: the generated component and the component in the component library referenced by the specified project;

[0049] Step 2: Input the obtained functional requirements information and information to be utilized into the fifth language model to generate code for the functions to be updated that match the project type and conform to the requirements description text.

[0050] In this approach, the requirement description text and the information to be utilized can be input into the third language model to obtain functional requirement information that conforms to the requirement description text. For example, a text prompt containing the requirement description text and the information to be utilized (which can be called a requirement text prompt) can be input into the third language model, and the requirement text prompt can instruct the third language model to analyze the requirement description text and the information to be utilized to obtain functional requirement information that conforms to the requirement description text.

[0051] The following is an example of a text prompt for a requirement:

[0052] Prompt (text prompt) = f"""

[0053] Analyze the user's front-end development needs and understand them in the context of the project:

[0054] User requirement: {user_input (user input)}

[0055] Project context:

[0056] Technology stack (i.e., project type): {project_context['tech_stack']}

[0057] Existing components (i.e., components that have already been generated): {list(project_context['components'].keys())}

[0058] UI (User Interface) framework (i.e., the component library referenced by the specified project): {project_context['ui_framework']}

[0059] Code style (i.e., code style information): {project_context['code_style']}

[0060] Please analyze and output:

[0061] 1. Requirement type (page / component / function / style)

[0062] 2. List of required UI components

[0063] 3. Business Logic Requirements

[0064] 4. Data Interaction Requirements

[0065] 5. Reusable existing components

[0066] 6. Components that need to be created

[0067] Output JSON (a data format): {{"requirementType":"page|component|feature|style","uiComponents":[{{"type":"search","description":"search box","priority":"high"}}],"businessLogic":[{{"action":"search","trigger":"input change","api":"searchAPI"}}],"dataInteraction":{{"apis":["getUserList","searchUsers"],"stateManagement":"reactive data"}}, "reusableComponents (existing reusable components):[{{"name":"UserCard","match":0.95,"reason":"perfectly meets user display requirements"}}],"newComponents (new components to be created):[{{"name":"UserSearchBar","type":"search"}}]}}"""

[0068] In this example, the user's input request could be: "I need a user list page that includes a search box, a list of user cards, a pagination component, and the ability to edit user information by clicking on a user card."

[0069] Here is an example of code-generated text suggestions:

[0070] prompt=f"""

[0071] Generate front-end code based on requirements and project context:

[0072] Requirements analysis (i.e., functional requirements information): {json.dumps(requirements,indent=2)}

[0073] Project context:

[0074] Technology stack (i.e., project type): {project_context['tech_stack']}

[0075] Code style (i.e., code style information): {json.dumps(project_context['code_style'],indent=2)}

[0076] UI framework (i.e., the component library referenced by the specified project): {project_context['ui_framework']}

[0077] Available components (i.e., components that have already been generated): {json.dumps(reusable_components,indent=2)}

[0078] Code generation requirements:

[0079] 1. Strictly adhere to the project's coding style.

[0080] 2. Prioritize using the component with the highest existing matching score.

[0081] 3. Use the UI framework in the project.

[0082] 4. Includes necessary business logic

[0083] """

[0084] The type of functionality to be updated can also be called the requirement type, which can be a page, component, function (i.e., JS function functionality), or style (e.g., display effect). The components to be generated are the components used to implement the functionality to be updated; this can also be called the list of required UI components. For example, if the functionality to be updated is a user list page, the components to be generated could be a search box, a user card list, and a pagination component.

[0085] A reusable component is a component to be generated that has matching components to be utilized. Utilized components include: already generated components and components from the component library referenced by the specified project. Correspondingly, a component to be utilized that matches a reusable component can also be called a reusable existing component. A matching component to a generated component means that the component to be utilized can implement the functionality required by the generated component. A generated component can have one or more matching components to be utilized. For each reusable component, the functional requirements information can also include a matching score for each matching component to be utilized. The closer the functionality implemented by the component to be utilized is to the functionality required by the reusable component, the higher the matching score.

[0086] If a component to be generated does not have a matching component to be used, it is not possible to directly reuse the existing component to implement the component to be generated. Therefore, it is necessary to create a new component. Thus, the component to be generated can also be called a component that needs to be created.

[0087] The triggering method for the function to be updated can also be called the business logic requirement. It can represent the front-end interaction method to implement the function to be updated. For example, the business logic requirement can include: the type of operation required to implement the function to be updated, the triggering method of the function to be updated, and the back-end API (Application Programming Interface) to be called to implement the function to be updated.

[0088] The data interaction method of the function to be updated can also be called the data interaction requirement. The data interaction requirement can represent the backend data interaction method to implement the function to be updated. For example, the data interaction requirement can include: the backend API that needs to perform data interaction to implement the function to be updated and the state management mode of data interaction.

[0089] The types of information included in the functional requirements information can vary depending on the specific function to be updated. For example, if implementing the updated function does not require the use of components, the functional requirements information may not include a list of required UI components, reusable existing components, or components that need to be newly created.

[0090] After obtaining the functional requirements information, the functional requirements and the information to be utilized can be input into the fifth language model to generate code for the updated function that matches the project type and conforms to the requirements description text. The third and fifth language models can be the same language model or different language models. For example, text hints containing functional requirements and the information to be utilized (which can be called code generation text hints) can be input into the fifth language model, and the code generation text hints can instruct the fifth language model to analyze the functional requirements and the information to be utilized so that the fifth language model can generate code for the updated function that matches the project type and conforms to the requirements description text.

[0091] Based on this approach, the third language model can be used to analyze and obtain rich functional requirement information from the requirement description text and the information to be utilized. Then, the fifth language model can be used to generate code for the updated functions that match the project type and conform to the requirement description text, based on the rich functional requirement information and the information to be utilized. This further ensures that the generated code for the updated functions conforms to the requirement description text, thus reducing the manual cost of code generation, improving the efficiency of code generation, and ensuring the validity of the generated code. Furthermore, code generation can be combined with the actual component library of the specified project (including generated components and referenced component libraries), enabling intelligent reuse of existing components and maintaining a certain degree of consistency in code style between the generated code and the project files of the specified project.

[0092] In Method 2, the requirement description text and the information to be utilized can be input into the third language model, so that the third language model can analyze the functional requirement information that matches the requirement description text, and generate the code of the updated function that matches the project type and matches the requirement description text based on the analysis results and the information to be utilized.

[0093] For example, a text prompt containing a requirement description and information to be utilized can be input into a third-party language model. This text prompt can instruct the third-party language model to analyze the functional requirement information that matches the requirement description text, and generate the code for the function to be updated based on the analysis results and the information to be utilized. The analysis results can be the same as the functional requirement information in Method 1.

[0094] In one embodiment, the information to be utilized further includes: code style information characterizing the code style of the project files for the specified project; and the generated code for the function to be updated conforms to the code style characterized by the code style information. See also Figure 2 , Figure 2 This is a schematic diagram illustrating the process of obtaining code style information in the code generation method provided in this application embodiment. The code style information is obtained through the following steps:

[0095] Step S201: Obtain the code style file representing the code file in the project file of the specified project, and the rule configuration file used to represent the code formatting rules;

[0096] Step S202: Input the file to be analyzed and the rule configuration file into the fourth language model to obtain code style information.

[0097] In the embodiments of the present application, the information to be utilized may further include: code style information characterizing the code style of the project files of a specified project. For example, the code style information may include: code formatting rules, naming conventions (such as variable naming conventions, component naming conventions), common code patterns and structures, API calls, and state management patterns. For instance, the code formatting rules may include: indentation, space usage, brace positions, blank line separation, operator spaces, etc.; the naming conventions may include: camelCase, kebab-case, PascalCase.

[0098] The common code patterns and structures can represent the code templates and architectural ways that repeatedly appear in the project files and have specific functions and organizations, and can reflect the development specifications and best practice ways of the project. For example, for page-level components, the common code patterns and structures may include: a standard three-part structure, namely, <template> + <script (JS behavior)> + <style>; the layout patterns of the header component, content area, recommended area, and pop-up layer; using the head() method to configure SEO (Search Engine Optimization), that is, optimizing the search engine crawling and page performance by dynamically setting the page header information (such as title, description, keywords, etc.); and using Mixins (a code reuse pattern) to reuse logic. For the state management pattern, the common code patterns and structures may include: Vuex (a state management pattern and library) modularization, where each page can correspond to an independent store / module.js (the core file for Vuex modular management); using a standard data flow, that is, actions → mutations → state → getters; using mapState (an auxiliary function) or mapActions (an auxiliary function) to simplify operations. For the conditional rendering pattern, the common code patterns and structures may include: controlling the component display based on business states (such as trainStatus, haveRight); using v-if (a conditional rendering directive) for conditional rendering and v-show (a conditional rendering directive) to control the display and hiding; and performing unified empty state and error state handling. The API calls and state management patterns may include: API request management functions, state management libraries, and route definitions.

[0099] The system can pre-obtain the code style files representing the project files in a specified project, as well as the rule configuration files representing the code formatting rules. For example, if the size of the project files (also known as project source files) does not exceed a preset threshold, the files to be analyzed can be the complete project source files. If the size of the project source files exceeds the preset threshold, code from files involving code rules (such as CSS (Cascading Style Sheets) or Vue files) can be randomly sampled to obtain the files to be analyzed. The rule configuration files can include configuration files for ESLint (a code style guide tool) and Prettier (a code formatting tool).

[0100] Both the file to be analyzed and the rule configuration file can reflect the code style of the project's files. Therefore, by inputting these two files into the fourth language model, code style information can be obtained. For example, a text prompt containing the file to be analyzed and the rule configuration file can be input into the fourth language model, instructing it to analyze these files and obtain code style information.

[0101] Here is an example of code style information output by the fourth major language model:

[0102] {

[0103] "codeStyle (code style, i.e. code formatting rules)": {

[0104] "indent":2,

[0105] "quotes":"single",

[0106] "semicolon (semicolon):false,

[0107] "trailingComma":"es5 (a JavaScript standard)"},

[0108] "namingConventions":{

[0109] "variables": "camelCase (camel case)"

[0110] "components": "PascalCase"

[0111] "files":"kebab-case (hyphen-separated naming)"},

[0112] "patterns (development patterns, i.e., API calls and state management)":{

[0113] "apiCalls (API calls)": "useRequest composable (an API request management function)",

[0114] "stateManagement": "Pinia (a state management library)"

[0115] "routeDefinition": "file-based routing"

[0116] }

[0117] Furthermore, in the process of generating code for the updated functionality that matches the project type and conforms to the requirement description text by utilizing the third language model and combining attribute information and component library identifiers, code style information can also be incorporated. That is, the third language model, combined with code style information, attribute information, and component library identifiers, can be used to generate code for the updated functionality that conforms to the code style represented by the code style information, matches the project type, and conforms to the requirement description text.

[0118] Based on the above processing, code style information representing the code style of the project files for a specified project can be obtained using large language model analysis. Furthermore, the large language model, combined with project information, attribute information, and code style information, can be used to generate the code for the feature to be updated. While ensuring that the generated code for the feature to be updated matches the project type and conforms to the requirements description text, it can be further guaranteed that the generated code for the feature to be updated is consistent with the code style of the project files for the specified project. This reduces the manual cost of code generation, improves the efficiency of code generation, and ensures the validity of the generated code.

[0119] In one embodiment, see Figure 3 , Figure 3 This is a schematic diagram illustrating the process of obtaining project information in the code generation method provided in this application embodiment. The project information is obtained through the following steps:

[0120] Step S301: Obtain the latest file directory structure of the specified project files;

[0121] Step S302: Extract the dependencies of the specified project from the package configuration file of the specified project;

[0122] Step S303: Input the file directory structure and key configuration information into the first language model to obtain project information;

[0123] The key configuration information includes dependencies.

[0124] In this embodiment, the file directory structure of the latest project files for a specified project can be obtained. For example, the directory can be recursively scanned to obtain a file_tree (file tree, i.e., file directory structure). For instance, the `os.path.isdir` function from the `os` (Operating System) package in Python can be used to determine whether each file path in the project files is a directory. If it is a directory, subdirectories are processed recursively; otherwise, a file node representing the file corresponding to that file path is added to the file tree. This process continues until all file paths in the project files have been processed, resulting in the final file tree, i.e., the file directory structure of the latest project files for the specified project.

[0125] The package configuration file for a specified project can be `package.json` (a core configuration file for the project), used to record project metadata (such as name and version), manage dependencies (such as third-party libraries, i.e., component libraries referenced by the project), and define script commands (such as startup or build commands). Correspondingly, the dependencies of a specified project can be extracted from its package configuration file. That is, `package.json` can be parsed to read the dependencies.

[0126] Key configuration information can include dependencies. The file directory structure and key configuration information can be input into the first language model to obtain project information. For example, a text hint containing the file directory structure and key configuration information (which can be called a project analysis text hint) can be input into the first language model, and the project analysis text hint can instruct the first language model to analyze the file directory structure and key configuration information to obtain project information.

[0127] The file directory structure represents the type and directory structure of a specified project, while key configuration information containing dependencies represents the component libraries referenced by the specified project. This ensures that when processing the file directory structure and key configuration information using the primary language model, the model can analyze and obtain relevant project structure information, namely, the project type and the identifiers of the component libraries referenced by the specified project. This guarantees accurate project information, and consequently, ensures the accuracy of the code generated for the updated functionality. In other words, it reduces the manual cost of code generation, improves code generation efficiency, and ensures the validity of the generated code.

[0128] In one embodiment, the key configuration information further includes: basic configuration information extracted from the base configuration file of the specified project, and / or, environment configuration information extracted from the environment configuration file of the specified project.

[0129] In this embodiment, each project type has a corresponding basic configuration file. For example, for a project of type Vue, its corresponding basic configuration file could be vue.config.js. Basic configuration information may include: the common path of resources, the output directory for the build package, and the local development server identifier. Basic configuration information can be extracted from the basic configuration file of a specified project using regular expressions. For example, if the basic configuration file for a specified project is vue.config.js, the basic configuration information can be extracted using the following regular expression:

[0130] .

[0131] Each project has an environment configuration file; for example, the file extension for environment configuration files can include .env and .env.production. The system can read the environment configuration file of a specific project, parse the environment variable configuration, and obtain the environment configuration information. Both environment configuration files and base configuration files can be configured when the project is created.

[0132] Key configuration information can also include basic configuration information and environment configuration information, thus encompassing richer data. Consequently, the primary language model can combine this richer key configuration information to analyze and obtain project information. This further ensures the accuracy of the project information obtained, thereby guaranteeing the accuracy of the code generated for the updated features. In this way, the manual cost of code generation can be reduced, the efficiency of code generation improved, and the validity of the generated code guaranteed.

[0133] For example, the `def llm_analyze_project_structure(project_info)` function can be used to trigger the invocation of the first language model to perform project structure analysis.

[0134] The following is an example of a project analysis text prompt:

[0135] prompt=f"""

[0136] Analyze the following front-end project structure to identify the technology stack and architectural pattern (i.e., identify project information):

[0137] File structure (i.e., file directory structure): {project_info['file_tree']}

[0138] Configuration file (i.e., key configuration information): {project_info['configs']}

[0139] Please output the analysis results in JSON format, including:

[0140] 1. Project type (Vue / React / Angular)

[0141] 2. Version Information

[0142] 3. Build tools

[0143] 4. UI framework (i.e., the component library referenced by the specified project)

[0144] 5. Catalog Standards

[0145] 6. Naming Conventions

[0146] Output format: {{

[0147] "projectType":"Vue3",

[0148] "version (version information)":"3.2.0",

[0149] "buildTool": "Vite (a project build tool)"

[0150] "uiFramework (UI framework)":["Element Plus"],

[0151] "directoryStructure":{{}},

[0152] "namingConvention":"PascalCase"}}

[0153] """

[0154] The above analysis results may also omit items 2, 3, 5, and 6.

[0155] Taking the largest language model, GPT-4, as an example, the following function can be used to call the largest language model and obtain the results returned by it:

[0156] response=llm_client.chat.completions.create(

[0157] model="GPT-4",

[0158] messages=[{"role":"user","content":prompt}],

[0159] temperature=0.1,

[0160] response_format={"type":"json_object"})

[0161] return json.loads(response.choices[0].message.content).

[0162] The following is an example of item information output by a major language model:

[0163] {"projectType":"Vue3",

[0164] "framework":"Vue 3.x",

[0165] "buildTool":"Vite",

[0166] "cssFramework":"Tailwind CSS",

[0167] "uiLibrary":["Element Plus","Ant Design Vue"],

[0168] "directoryStructure":{

[0169] "components":"src / components",

[0170] "views (pages)":"src / views",

[0171] "utils (utility functions / files)":"src / utils",

[0172] "apis (API-related wrapper files)":"src / apis"},

[0173] "namingConvention":"PascalCase",

[0174] "styleGuide (coding style)":"composition-api (a coding style)"}.

[0175] In one embodiment, files can be categorized based on their file extensions within a specified project, resulting in file_categories (file classification results). For example, a file with the extension .vue can be identified as a Vue file (i.e., a component code file); a file with the extension .config.js can be identified as a configuration file, such as "vue.config.js" or "webpack.config.js"; a file with the extensions .css, .scss, or .less can be identified as a stylesheet file; a file with the extensions .ts, .tsx, or .dts can be identified as a TypeScript file; a file with the extensions .js or .jsx can be identified as a JavaScript file; and a file with the extensions .jpg, .png, or .json can be identified as a static resource file.

[0176] The project type of a specified project can be determined based on the file classification results and feature file detection rules. For example, the feature file detection rules are as follows:

[0177] detection_rules (feature file detection rules) = {

[0178] "vue" (the rules corresponding to vue):[

[0179] lambda files: any("vue.config.js" in f for f in files), # Check if the base configuration file for Vue exists.

[0180] lambda files: len(files)>0, # Check if Vue component files exist.

[0181] lambda files: any("vue-router" in f for f in files) # Check if a route signature file exists.

[0182] "react" (the rules corresponding to react):[

[0183] lambda files: any("react-app" in f for f in files), # Check if the base configuration file for React exists.

[0184] lambda files: any(f.endswith(".jsx") for f in files), # Check if files with the .jsx extension exist.

[0185] lambda files: any(f.endswith(".tsx") for f in files)], # Check if files with the .tsx extension exist.

[0186] "angular" (the rules corresponding to angular):[

[0187] lambda files: any("angular.json" in f for f in files), # Check if the Angular base configuration file exists.

[0188] lambda files: any(".component.ts" in f for f in files), # Check if files with the .component.ts extension exist.

[0189] lambda files: any("main.ts" in f for f in files) # Check if the file "main.ts" exists.

[0190] }

[0191] For all files within a specified project's project files, under the respective rules for Vue, React, and Angular, each fulfilled criterion increases the feature score (also known as the framework feature score) for that project type. The project type with the highest feature score is ultimately determined as the specified project type. Furthermore, when analyzing project information using the primary language model, the obtained project type can also be input into the primary language model. For example, project analysis text hints can also include the obtained project type.

[0192] In one embodiment, see Figure 4 , Figure 4 This is a flowchart illustrating the process of obtaining attribute information in the code generation method provided in this application embodiment. The attribute information is obtained through the following steps:

[0193] Step S401: From the component code file of the generated component, filter out the parts that represent the properties of the generated component to obtain the component meta information;

[0194] Step S402: Input the component code to be used and the component meta-information from the generated component code file into the second language model to obtain attribute information.

[0195] Among them, attribute information is used to represent the functionality of the generated component.

[0196] In this embodiment, the portion representing the attributes of the generated component can be filtered from the component code file of the generated component to obtain component meta-information. For example, the portion representing the attributes of the generated component may include: the name, format, internal methods, and triggering events of the generated component. The component code to be utilized and the component meta-information from the component code file of the generated component can be input into a second language model to obtain attribute information. Component meta-information helps the second language model understand the functionality of the generated component represented by the component code to be utilized. For example, a text hint (which can be called a component analysis text hint) containing the component code to be utilized and the component meta-information can be input into the second language model, and the component analysis text hint can instruct the second language model to analyze the component code to be utilized and the component meta-information to obtain attribute information.

[0197] In this way, it can be ensured that the attribute information output by the second language model can represent the functionality of the generated components, that is, valid attribute information can be obtained. This, in turn, ensures the accuracy of the subsequent third language model in generating code for the updated functionality using the attribute information. In other words, it can reduce the manual cost of code generation, improve the efficiency of code generation, and guarantee the validity of the generated code.

[0198] In one implementation, the component code to be utilized can be all the component code in the component code file of the generated component.

[0199] In another implementation, the component code to be used is: the code in the component code file of the generated component, excluding the code indicated by the specified element tag; the specified element tag includes at least one of the following: native HTML tags, built-in tags corresponding to the item type of the specified item, and slot tags.

[0200] In this implementation, the code indicated by the specified element tag (also known as the filter exclusion) is unrelated to the functionality of the generated component. This code can be common code found in the component code files of all generated components. For example, an XML (Extensible Markup Language) parser can be used to traverse all element tags in the component code files of the generated component to identify the specified element tag and filter out the code other than that indicated by the specified element tag, thus obtaining the component code to be used. The code other than that indicated by the specified element tag can include: kebab-case tags containing hyphens (e.g., ...). <my-component>The code indicated by ) and the PascalCase label with the first letter capitalized (e.g., <button>The code indicated by ).

[0201] When the project type is Vue, the generated component code files are the Vue files. For each Vue file, it can be parsed to separate the template, script, and style sections. Furthermore, the tags within the template section of the Vue file can be iterated. For example, the following regular expression can be used to separate them:

[0202] .

[0203] The specified element tags include at least one of the following: native HTML tags, built-in tags corresponding to the item type of the specified item, and slot tags. Built-in tags corresponding to the item type of the specified item are the tags containing the code of the built-in components within the item type of the specified item. For example, native HTML tags may include: 、 Taking a project of type Vue as an example, the built-in tags for Vue can include: <router-link> 、 <transition>Slot labels can be <slot>.

[0204] Based on the above processing, code irrelevant to the functionality of the generated components can be filtered out from the component code files, resulting in the usable component code. This reduces the amount of usable component code that the second language model needs to analyze, and also reduces irrelevant information within it. Consequently, this improves the efficiency of the second language model in obtaining attribute information and reduces interference from irrelevant information, ensuring the validity of the obtained attribute information. Furthermore, it ensures the accuracy of the subsequent third language model in generating code for the updated functionality using the attribute information. In other words, it reduces the manual cost of code generation, improves efficiency, and guarantees the validity of the generated code.

[0205] In one implementation, the component code file of the generated component can be input into a sixth language model to extract the parts representing the attributes of the generated component, thereby obtaining the component meta-information. The sixth language model can be any of the first to fifth language models in the above embodiments, or it can be any other language model.

[0206] In another implementation, step S401 may include: converting the component code file of the generated component into an abstract syntax tree; extracting the part representing the attributes of the generated component from the obtained abstract syntax tree to obtain component meta-information.

[0207] In this implementation, the component code file of the generated component can be converted into an Abstract Syntax Tree (AST). For example, ESPRIMA (a code parser) can be used to parse the code and generate an AST. Taking a Vue file as an example, the script section of the Vue file can be converted into an AST. The JSX option can be enabled to allow ESPRIMA to handle JSX / Vue-specific syntax. If parsing problems are encountered when using ESPRIMA due to certain code declarations (e.g., the use of certain special syntax or syntax extensions specific to third-party libraries), virtual wrappers can be used to solve the problem. That is, virtual wrappers can be added to resolve the parsing issues of exported declarations.

[0208] Furthermore, the components representing the properties of the generated component can be extracted from the obtained abstract syntax tree to obtain component meta-information. For example, the abstract syntax tree can be traversed to extract information using props, emits (custom events), and methods. For props, array / object format prop declarations can be parsed to obtain the prop properties of the generated component; for events, custom event declarations can be parsed from the emits option to obtain the name of the custom event and the function required to implement the custom event; for slots, the usage of this.$slots.xxx can be extracted from $slots within the render function to obtain the slot name; for methods, the method name and the location of this.$emit call can be extracted from the methods option to obtain the name of the method triggered by this.$emit.

[0209] The following is an example of a component analyzing text prompts:

[0210] prompt=f"""

[0211] Analyze the following Vue / React components to understand their functionality and use cases:

[0212] Component code (i.e., the code of the component to be used): ```{component_code}```

[0213] Extracting information from the AST (i.e., component metadata): {json.dumps(component_info,indent=2)}

[0214] Please analyze and output:

[0215] 1. Component Main Function Description 2. Use Cases 3. Component Type Classification (Display / Interactive / Container) 4. Usage Complexity Rating 5. Recommended Usage Output JSON Format: {{"description":"Component Function Description","category (Component Type)":"display (Display)|interactive (Interactive)|container (Container)","complexity":"low (Low)|medium (Medium)|high (High)"useCases (Usage Scenarios)":["Usage Scenarios 1","Usage Scenarios 2"],"recommendedUsage":"Recommended Usage"}}

[0216] Example input:<!--src / components / UserCard.vue-->

[0217] <template>

[0218]

[0219] <img:src="avatar":alt="name" / >

[0220] <h3> {{name}}< / h3>

[0221] {{email}}

[0222] <el-button@click="handleEdit"> edit

[0223]

[0224] < / template>

[0225] <script setup>

[0226] defineProps({

[0227] name:String,

[0228] email:String,

[0229] avatar:String})

[0230] defineEmits(['edit'])

[0231] const handleEdit=()=>{

[0232] emit('edit')}

[0233] < / script>

[0234] Example output: {

[0235] "componentName":"UserCard",

[0236] "filePath (file path)":"src / components / UserCard.vue",

[0237] "type":"display",

[0238] "description":"User information display card component",

[0239] "props":[{"name":"name","type":"String","required":true,"description":"User Name"},

[0240] {"name":"email","type":"String","required":true,"description":"User email"},

[0241] {"name":"avatar","type":"String","required":true,"description":"User avatar URL"}],

[0242] "events":[{"name": "edit", "description": "Edit button click event"}],

[0243] "dependencies":["Element Plus"],

[0244] "usageExample (usage example)":"<UserCard:name=\"user.name\":email=\"user.email\":avatar=\"user.avatar\"@edit=\"handleEdit\" / > "

[0245] }

[0246] In one embodiment, the information to be utilized is obtained from a preset cache space; the method further includes:

[0247] When a new component is added to a specified project, the component's code file and the second language model are used to perform component function analysis, obtain the attribute information of the new component, and store the obtained attribute information in a preset cache space.

[0248] In this embodiment, after obtaining the information to be utilized, the information can be stored in a preset cache space. When a new component is added to a specified project, the component's code file and the second language model are used to perform component function analysis, obtain the attribute information of the new component, and store the obtained attribute information in the preset cache space. For the specific method of performing component function analysis on the component's code file, please refer to the relevant descriptions of steps S401 and S402 in the above embodiments. When a generated component in a specified project is deleted, the attribute information corresponding to that generated component can be deleted from the cache.

[0249] Since the project information and code style information of a specified project change infrequently, the latest project information and code style information can be determined periodically according to a preset cycle, and the cache updated accordingly. The method for determining the latest project information can be found in the relevant descriptions of steps S301-S303 in the above embodiments. The method for determining the latest code style information can be found in the relevant descriptions of steps S201 and S202 in the above embodiments.

[0250] Based on the above processing, the latest information to be utilized can be recorded in a preset cache space. Correspondingly, when code for an updated feature needs to be generated, the information to be utilized can be retrieved from the preset cache space. This allows for quick acquisition of the information needed to generate the updated feature code, further improving code generation efficiency. Furthermore, regarding attribute information, when a new component is added to a specified project, attribute information can be retrieved only for the new component, eliminating the need to retrieve attribute information for all already generated components. In other words, incremental caching can be implemented, reducing the overhead of redundant calculations and further ensuring a lower cost for code generation.

[0251] A file that records information to be used in a pre-defined cache space can be called an information file. The hash value of an information file can be calculated. For example, a hash calculator object `hasher` can be created using `hashlib.sha256()`, initially empty. The information file is read in chunks, and the `update()` method of `hasher` is called for each chunk to calculate its hash value. After processing all chunks, `hexdigest()` is called to generate the final hash value. Subsequently, when using the information to be used, the hash value can be used to determine whether the information file has changed.

[0252] The following is an example of a cache structure for information files:

[0253] {

[0254] "projectHash (file hash value)": "abc123...",

[0255] "lastUpdate (last update time)":"2024-03-15T10:30:00Z",

[0256] "components":{

[0257] "UserCard":{

[0258] "hash":"def456...",

[0259] "lastAnalyzed (last analysis time)":"2024-03-15T10:25:00Z",

[0260] "metadata":{ / *Component analysis results* / }

[0261] }

[0262] },

[0263] "incrementalChanges":[{

[0264] "file":"src / components / NewComponent.vue (the path to the new component's code file)",

[0265] "action": "added",

[0266] "timestamp": "2024-03-15T10:28:00Z"

[0267] }]

[0268] }

[0269] In one embodiment, see Figure 5 , Figure 5 This is a schematic diagram illustrating the framework for obtaining information to be utilized in the code generation method provided in this application embodiment. The project analysis engine, deployed with the first major language model in the above embodiments, can be used to analyze and obtain project information by combining project files (i.e., project files of a specified project), configuration files (i.e., environment configuration files and basic configuration files in the above embodiments), and dependency information (i.e., dependencies) in the project file system. That is, steps S301-S303 in the above embodiments are executed. The component recognition engine, deployed with the second major language model in the above embodiments, can be used to obtain attribute information. That is, steps S401 and S402 in the above embodiments are executed. The code style analyzer, deployed with the fourth major language model in the above embodiments, can be used to obtain code style information. That is, steps S201 and S202 in the above embodiments are executed. Project files, configuration files, and dependency information can be stored in the data source layer (i.e., the preset storage space in the above embodiments). Correspondingly, project files, configuration files, and dependency information can be obtained from the data source layer to analyze and obtain project information using the obtained project files, configuration files, and dependency information.

[0270] And project information can be stored in the cache management layer (i.e., the preset cache space in the above embodiments), thus obtaining a cache sub-area that stores project information (i.e. Figure 5 In the project structure cache), attribute information is stored in the cache management layer, which allows us to obtain the cache sub-area containing the attribute information (i.e., Figure 5 The component metadata cache in the cache layer, and the code style information stored in the cache layer, can be used to obtain the cache sub-area that stores the code style information (i.e., Figure 5 (Code style caching in the project). Incremental caching can be implemented through an incremental update manager. That is, when a new component is added to a specified project, the component's code file and the second major language model are used to analyze the component's functionality, obtain its attribute information, and store this attribute information in the corresponding cache sub-area of ​​the preset cache space. Correspondingly, when project information, attribute information, and code style information are needed, the required information can be retrieved from the corresponding cache sub-area of ​​the preset cache space.

[0271] In one embodiment, see Figure 6 , Figure 6 This is a schematic diagram illustrating the framework of a code generation method provided in this application embodiment. When an update function for a specified project needs to be implemented, the user can input a requirement description text describing the update function for the specified project, i.e., user requirement input. The user input triggers a code generation request. Correspondingly, the code generation request instructs a requirement intent analyzer deployed with the third language model described in the above embodiments to analyze the requirement description text in conjunction with cached project information, component information, and code style information (i.e., the information to be utilized in the above embodiments), obtaining functional requirement information including component recommendations (i.e., reusable existing components in the above embodiments) and usage examples (i.e., recommended usage methods in the above embodiments). This is step one in the above embodiments. The obtained functional requirement information and the cached information to be utilized can be input into a code generation engine deployed with the fifth language model described in the above embodiments to generate code for the update function that matches the project type and conforms to the requirement description text (i.e., code generation result). This is step two in the above embodiments.

[0272] Figure 6 The user input and code generation requests can be called the user interaction layer, while the code generation results, component recommendations, and usage examples can be called the output layer. Figure 5 The project analysis engine, component identification engine, code style analyzer, and Figure 6 The demand intent analyzer and code generation engine in the code can be considered part of the core processing layer.

[0273] As can be seen, this application provides a context-sensitive, knowledge-based code generation method that can intelligently select custom components, public components, and utility functions in a specified project based on the project context (i.e., the latest project files) and efficiently generate the corresponding front-end code. Specifically, it can intelligently analyze the project structure (i.e., project information), automatically identify component interfaces (i.e., attribute information), and code style (i.e., code style information) through AIGC (Artificial Intelligence Generated Content) to establish a "digital profile" of the specified project. When a user submits a request, it can perform context-aware code generation based on the actual situation of the specified project, ensuring that the generated code conforms to project specifications.

[0274] Based on the same inventive concept, this application provides a code generation apparatus, see [link to relevant documentation]. Figure 7 , Figure 7 This is a schematic diagram of a code generation apparatus provided in an embodiment of this application. The apparatus includes:

[0275] The data acquisition module 701 is used to acquire information to be utilized, as well as a description text describing the requirements for the updated functions of a specified project;

[0276] The information to be utilized includes: project information containing the project type of the specified project and the component library identifier referenced by the specified project, as well as attribute information of the components already generated in the specified project; the project information is obtained by analyzing the structure of the specified project using the latest project file and the first major language model; the attribute information is obtained by analyzing the component functions using the component code files of the generated components in the project file and the second major language model.

[0277] The code generation module 702 is used to generate code for the function to be updated that matches the project type and conforms to the requirement description text by using the third language model, combined with the attribute information and the component library represented by the component library identifier.

[0278] Based on the code generation apparatus provided in this application embodiment, the project structure of the project (i.e., the specified project) that needs to update its functionality can be analyzed in advance using a large language model (i.e., the first large language model) to obtain project information. Furthermore, the component function analysis of the component code files of the generated components in the specified project can be performed using a large language model (i.e., the second large language model) to obtain attribute information. The project information may include the project type of the specified project and the component library identifier referenced by the specified project; the attribute information may represent the functionality of the generated components. That is, the context of the specified project can be analyzed in advance to obtain usable information containing project information and attribute information. When a user needs to update the functionality of the specified project and needs to generate code for the updated functionality, the requirement description text describing the updated functionality can also be obtained.

[0279] Furthermore, the third language model can be used, combined with attribute information and component library identifiers, to generate code for the updated functionality that matches the project type and conforms to the requirement description text. In other words, the large language model can be used to process the user information and requirement description text to generate code for the updated functionality that meets user needs and matches the project type of the specified project. Thus, project information and attribute information can be obtained through large language model analysis, and the required code can be generated by combining the large language model with user requirements, project information, and attribute information. This eliminates the need for manual maintenance of the knowledge base, reducing the manual cost of code generation, and the high efficiency of large language model analysis also improves code generation efficiency.

[0280] In one embodiment, the information to be utilized further includes: code style information characterizing the code style of the project files of the specified project; the generated code for the function to be updated conforms to the code style characterized by the code style information;

[0281] The code style information is obtained through the following steps:

[0282] Obtain the code style file representing the code file in the project file of the specified project, and the rule configuration file representing the code formatting rules;

[0283] The file to be analyzed and the rule configuration file are input into the fourth language model to obtain the code style information.

[0284] In one embodiment, the project information is obtained through the following steps:

[0285] Get the latest file directory structure of the specified project files;

[0286] Extract the dependencies of the specified project from the package configuration file of the specified project;

[0287] The file directory structure and key configuration information are input into the first language model to obtain the project information; wherein, the key configuration information includes the dependencies.

[0288] In one embodiment, the key configuration information further includes: basic configuration information extracted from the base configuration file of the specified project, and / or, environment configuration information extracted from the environment configuration file of the specified project.

[0289] In one embodiment, the attribute information is obtained through the following steps:

[0290] From the component code file of the generated component, the parts representing the attributes of the generated component are filtered out to obtain the component meta information;

[0291] The component code to be used and the component meta-information in the component code file of the generated component are input into the second language model to obtain the attribute information; wherein, the attribute information is used to represent the function of the generated component.

[0292] In one embodiment, the component code to be utilized is: other code in the component code file of the generated component, excluding the code indicated by the specified element tag; the specified element tag includes at least one of the following: native HTML tags, built-in tags corresponding to the project type of the specified project, and slot tags.

[0293] In one embodiment, the step of using a third language model, combining the attribute information and the component library represented by the component library identifier to generate code for the function to be updated that matches the project type and conforms to the requirement description text includes:

[0294] The requirement description text and the information to be utilized are input into a third language model to obtain functional requirement information that conforms to the requirement description text. The obtained functional requirement information includes at least one of the following: the type of the function to be updated, the component to be generated to implement the function to be updated, the triggering method of the function to be updated, the data interaction method of the function to be updated, the component to be utilized that matches the reusable component, and the component to be generated that does not have a matching component. The reusable component is the component to be generated that has a matching component. The component to be utilized includes: already generated components and components in the component library referenced by the specified project.

[0295] The obtained functional requirements information and the information to be utilized are input into the fifth language model to generate code for the function to be updated that matches the project type and conforms to the requirement description text.

[0296] In one embodiment, the information to be utilized is obtained from a preset cache space; the method further includes:

[0297] When a new component is added to the specified project, the component's function is analyzed using the component code file of the new component and the second major language model to obtain the attribute information of the new component, and the obtained attribute information is stored in the preset cache space.

[0298] This application also provides an electronic device, such as... Figure 8 As shown, it includes a processor 801, a communication interface 802, a memory 803, and a communication bus 804. The processor 801, communication interface 802, and memory 803 communicate with each other via the communication bus 804.

[0299] Memory 803 is used to store computer programs;

[0300] When processor 801 executes a program stored in memory 803, it performs the following steps:

[0301] Obtain the information to be utilized, as well as a description text describing the required updated features for the specified project;

[0302] The information to be utilized includes: project information containing the project type of the specified project and the component library identifier referenced by the specified project, as well as attribute information of the components already generated in the specified project; the project information is obtained by analyzing the structure of the specified project using the latest project file and the first major language model; the attribute information is obtained by analyzing the component functions using the component code files of the generated components in the project file and the second major language model.

[0303] Using the third language model, combined with the attribute information and the component library represented by the component library identifier, code for the function to be updated that matches the project type and conforms to the requirement description text is generated.

[0304] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not indicate that there is only one bus or one type of bus.

[0305] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0306] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0307] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0308] In another embodiment provided in this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements any of the code generation methods described in the above embodiments.

[0309] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the code generation methods described in the above embodiments.

[0310] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0311] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0312] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, electronic devices, storage media, and program products are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0313] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.< / slot> < / transition> < / router-link> < / button>

Claims

1. A code generation method, characterized in that, The method includes: Obtain the information to be utilized, and a description text describing the requirements for the updated functions of the specified project; wherein, the information to be utilized includes: project information containing the project type of the specified project and the component library identifier referenced by the specified project, and attribute information of the components already generated in the specified project; the project information is obtained by analyzing the structure of the specified project using the latest project file and the first major language model; the attribute information is obtained by analyzing the component function using the component code file of the generated components in the project file and the second major language model; Using the third language model, combined with the attribute information and the component library represented by the component library identifier, code for the function to be updated that matches the project type and conforms to the requirement description text is generated.

2. The method according to claim 1, characterized in that, The information to be utilized also includes: code style information that characterizes the code style of the project files of the specified project; and the generated code for the function to be updated conforms to the code style characterized by the code style information. The code style information is obtained through the following steps: Obtain the code style file representing the code file in the project file of the specified project, and the rule configuration file representing the code formatting rules; The file to be analyzed and the rule configuration file are input into the fourth language model to obtain the code style information.

3. The method according to claim 1 or 2, characterized in that, The project information was obtained through the following steps: Get the latest file directory structure of the specified project files; Extract the dependencies of the specified project from the package configuration file of the specified project; The file directory structure and key configuration information are input into the first language model to obtain the project information; wherein, the key configuration information includes the dependencies.

4. The method according to claim 3, characterized in that, The key configuration information also includes: basic configuration information extracted from the base configuration file of the specified project, and / or, environment configuration information extracted from the environment configuration file of the specified project.

5. The method according to claim 1 or 2, characterized in that, The attribute information is obtained through the following steps: From the component code file of the generated component, the parts representing the attributes of the generated component are filtered out to obtain the component meta information; The component code to be used and the component meta-information in the component code file of the generated component are input into the second language model to obtain the attribute information; wherein, the attribute information is used to represent the function of the generated component.

6. The method according to claim 5, characterized in that, The component code to be used is: the code in the component code file of the generated component, excluding the code indicated by the specified element tag; the specified element tag includes at least one of the following: native Hypertext Markup Language (HTML) tags, built-in tags corresponding to the project type of the specified project, and slot tags.

7. The method according to claim 1 or 2, characterized in that, The process of generating code for the function to be updated, which matches the project type and conforms to the requirement description text, by utilizing the third language model, combining the attribute information and the component library represented by the component library identifier, includes: The requirement description text and the information to be utilized are input into a third language model to obtain functional requirement information that conforms to the requirement description text. The obtained functional requirement information includes at least one of the following: the type of the function to be updated, the component to be generated to implement the function to be updated, the triggering method of the function to be updated, the data interaction method of the function to be updated, the component to be utilized that matches the reusable component, and the component to be generated that does not have a matching component. The reusable component is the component to be generated that has a matching component. The component to be utilized includes: already generated components and components in the component library referenced by the specified project. The obtained functional requirements information and the information to be utilized are input into the fifth language model to generate code for the function to be updated that matches the project type and conforms to the requirement description text.

8. The method according to claim 1 or 2, characterized in that, The information to be utilized is obtained from a preset cache space; the method further includes: When a new component is added to the specified project, the component's function is analyzed using the component code file of the new component and the second major language model to obtain the attribute information of the new component, and the obtained attribute information is stored in the preset cache space.

9. A code generation device, characterized in that, The device includes: The data acquisition module is used to acquire information to be utilized, as well as text describing the requirements for the updated functions of a specified project. The information to be utilized includes: project information containing the project type of the specified project and the component library identifier referenced by the specified project, as well as attribute information of the components already generated in the specified project; the project information is obtained by analyzing the structure of the specified project using the latest project file and the first major language model; the attribute information is obtained by analyzing the component functions using the component code files of the generated components in the project file and the second major language model. The code generation module is used to generate code for the function to be updated that matches the project type and conforms to the requirement description text by utilizing the third language model, combining the attribute information and the component library represented by the component library identifier.

10. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method described in any one of claims 1-8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method described in any one of claims 1-8.