CN-121996220-A - Code generation method, device and system based on large model
Abstract
The application provides a code generation method, a code generation device, an electronic device, a computer readable medium and a program product based on a large model. The method comprises the steps of determining phase related knowledge corresponding to a development phase from a development methodology knowledge base for each development phase in a preset development flow, and executing a phase task corresponding to the development phase according to the phase related knowledge and a task result of a previous phase of the development phase through an artificial intelligence large model until the preset development flow is completed, so as to generate project codes of target projects. The application combines the artificial intelligent large model, the preset development flow and the development methodology knowledge base, and improves the efficiency of the whole code development flow and the code development quality.
Inventors
- Luo Xuting
Assignees
- 上海哔哩哔哩科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260107
Claims (20)
- 1. A large model-based code generation method, wherein the method comprises: for each development stage in a preset development flow, determining stage related knowledge corresponding to the development stage from a development methodology knowledge base; And executing a stage task corresponding to the development stage according to the stage related knowledge and a task result of a previous stage of the development stage through an artificial intelligence large model until the preset development flow is completed, and generating a project code of a target project.
- 2. The method of claim 1, wherein the determining, from a development methodology knowledge base, phase-related knowledge corresponding to the development phase comprises: Determining basic attributes of the development stages from a stage attribute configuration file, wherein the stage attribute configuration file comprises basic attributes of each development stage in the preset development flow; determining initial related knowledge corresponding to the development stage from the development methodology knowledge base according to the retrieval prompt in the basic attribute; and combining the basic attribute and the initial related knowledge to obtain the stage related knowledge.
- 3. The method of claim 2, wherein the determining the base attributes of the development phase from a phase attribute profile comprises: calling an attribute screening tool registered in a scheduling server by adopting a model context protocol, determining basic attributes of the development stage from the stage attribute configuration file, and The determining initial related knowledge corresponding to the development stage from the development methodology knowledge base according to the retrieval prompt in the basic attribute comprises the following steps: And calling a knowledge screening tool registered in the scheduling server by adopting the model context protocol, and determining initial related knowledge corresponding to the development stage from the development methodology knowledge base according to the retrieval prompt.
- 4. The method of claim 2, wherein the determining initial relevant knowledge corresponding to the development stage from the development methodology knowledge base according to the retrieval hint comprises: According to a hierarchical search strategy for representing search modes with different priorities, determining a target index of the initial related knowledge from index data according to the search prompt, wherein the index data represents indexes of chapters of files in the development methodology knowledge base; And determining the initial related knowledge from the development methodology knowledge base according to the target index.
- 5. The method of claim 1, wherein the performing, by the artificial intelligence large model, a stage task corresponding to the development stage based on the stage-related knowledge and a task result of a preceding stage of the development stage, comprises: Determining an artificial intelligent large model corresponding to the development stage according to the stage related knowledge; and executing the stage tasks corresponding to the development stage according to the stage related knowledge and the task results of the previous stage through the artificial intelligence large model corresponding to the development stage.
- 6. The method of claim 5, wherein the development phase is a project plan design phase, the phase related knowledge is a project plan design specification, the task results of the prior phase are demand documents of a development demand validation phase, and And executing the stage task corresponding to the development stage according to the stage related knowledge and the task result of the previous stage, wherein the stage task comprises the following steps: and generating the project plan of the target project according to the requirement document by referring to the project plan design specification.
- 7. The method of claim 6, wherein the generating a project plan for the target project from the demand document comprises: determining a target technical architecture to be adopted by the target project according to the technical resource data of the demand document and the history project, carrying out function division on the target project, and determining a module blueprint of each divided functional module; determining a data model corresponding to an interface between each functional module and a routing table representing a mapping relationship between an interface component corresponding to the target item and a page access path according to the module blueprint and the demand document; Generating a structure diagram and a module topological diagram of the target item according to the target technical structure, the module blueprint and the routing table; generating a test strategy document for representing the test strategy of each functional module according to the module blueprint, the data model and the project acceptance standard in the requirement document; Determining a module scheduling plan of each functional module according to the module blueprint; And combining the target technical architecture, the data model corresponding to the interface, the routing table, the architecture diagram, the module topological diagram, the test strategy document and the module scheduling plan to obtain a project scheme of the target project.
- 8. The method of claim 7, wherein the determining a target technical architecture to be adopted by the target project according to the technical resource data of the requirement document and the history project, and performing functional partitioning on the target project, determining a module blueprint of each partitioned functional module includes: determining constraint priorities between development constraint entries in the requirements document; And determining the target technical architecture according to the constraint priority and the technical resource data, performing functional division on the target item, and determining a module blueprint of each functional module.
- 9. The method of claim 8, wherein the generating the architecture diagram and the module topology diagram of the target item from the target technology architecture, the module blueprint, and the routing table comprises: Generating the architecture diagram and the module topology diagram according to the target technology architecture, the module blueprint, the routing table and the constraint priority, and The generating a test policy document representing the test policy of each functional module according to the module blueprint, the data model and the project acceptance criteria in the requirement document comprises: And generating the test strategy document according to the module blueprint, the data model, the project acceptance standard and the constraint priority.
- 10. The method of any of claims 6-9, wherein the development stage is a test case generation stage, the stage-related knowledge generates specifications for test cases, the task results of the prior stage are the project plan and the requirements document, and And executing the stage task corresponding to the development stage according to the stage related knowledge and the task result of the previous stage, wherein the stage task comprises the following steps: Generating a specification by referring to the test case, and generating a test scene example by combining verification points characterized by project acceptance standards in the requirement document according to the project scheme; And generating test cases of the functional modules and test cases of main flows in the target items according to the test scene examples.
- 11. The method of claim 10, wherein the combining verification points characterized by project acceptance criteria in the requirements document according to the project plan generates a test scenario example, comprising: According to the project scheme, combining verification points characterized by project acceptance criteria in the requirement document to generate an initial scene example; and supplementing element positioning identification and test environment data in the initial scene example according to the scaffold foundation code of the target project, so as to obtain the test scene example.
- 12. The method of claim 10, wherein the generating, according to the test scenario example, the test case of each of the functional modules and the test case of the main flow in the target item includes: generating a test template according to the test scene example; and generating test cases of the functional modules and the test cases of the main flow according to the project scheme and the test template.
- 13. The method of any of claims 10-12, wherein the development phase is a test case validation phase, the phase-related knowledge is an acceptance specification of the test case, the task result of the prior phase is the test case, and And executing the stage task corresponding to the development stage according to the stage related knowledge and the task result of the previous stage, wherein the stage task comprises the following steps: Displaying acceptance specifications of the test cases; And adjusting the test case according to the received adjustment operation.
- 14. The method of claim 13, wherein the adjusting the test case according to the received adjustment operation comprises: According to the test case perfecting operation, adjusting attribute data of the test case; and supplementing the test cases in the scene to be supplemented indicated by the test scene supplementing operation.
- 15. The method of any of claims 13-14, wherein the development phase is a functional module development phase, the phase related knowledge is a functional module development specification, the task results of the prior phase are the requirements document, the project plan, and test cases corresponding to each of the functional modules, and And executing the stage task corresponding to the development stage according to the stage related knowledge and the task result of the previous stage, wherein the stage task comprises the following steps: Determining a target functional module to be developed according to the module scheduling plan; And referring to the function module development specification, generating a module function code of the target function module according to the requirement document, the project scheme and the test case corresponding to the target function module.
- 16. The method of claim 15, wherein the generating module function code of the target function module according to the requirement document, the project plan, and the test case corresponding to the target function module includes: Generating an initial function code of the target function module according to the requirement document, the technical scheme and the test case related to the target function module; And iteratively executing the initial function code based on a test running process of a test case corresponding to the target function module, an analysis process of a module test result and a code repairing process of the initial function code based on the module analysis result until a first preset ending condition is reached, so as to obtain the module function code.
- 17. The method of claim 16, wherein the executing the initial function code is based on a test run of a test case corresponding to the target function module, comprising: For the test operation in the test case corresponding to the target functional module, determining a target test tool which is registered in a test server and corresponds to the test operation; And calling the target test tool by adopting the model context protocol, and executing the test operation.
- 18. The method of any of claims 15-17, wherein the development phase is a main flow development phase of the target project, the phase related knowledge is a main flow development specification, the task results of the preceding phase are test cases corresponding to the module function code and the main flow, and And executing the stage task corresponding to the development stage according to the stage related knowledge and the task result of the previous stage, wherein the stage task comprises the following steps: Generating an integrated code corresponding to the main flow according to the module function code and the test case corresponding to the main flow by referring to the main flow development specification; and combining the module function code and the integrated code to obtain the project code.
- 19. The method of claim 18, wherein the generating the integrated code corresponding to the main flow from the module function code and the test case corresponding to the main flow comprises: Generating an initial code corresponding to the main flow according to the module function code and the test case corresponding to the main flow; And iteratively executing the initial integrated code to obtain the integrated code based on a test operation process of the test case corresponding to the main flow, an analysis process of an integrated test result and a code repairing process based on the integrated analysis result until a second preset ending condition is reached.
- 20. The method of claim 6, wherein the development phase is a development demand clarification phase preceding the development demand validation phase, the phase-related knowledge is a demand clarification class specification, and And executing the stage task corresponding to the development stage according to the stage related knowledge and the task result of the previous stage, wherein the stage task comprises the following steps: and analyzing development demand data of the target project by referring to the demand clarification specification, and determining an initial demand document of the target project and a problem to be confirmed in an analysis process.
Description
Code generation method, device and system based on large model Technical Field The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a system, an electronic device, a computer readable medium, and a program product for generating a code based on a large model. Background With the development of LLM (Large Language Model ), a variety of "AI (ARTIFICIAL INTELLIGENCE, artificial intelligence) -assisted programming" tools have emerged in the industry, such as code complement tools that convert natural language requirements into code fragments, tools that automatically generate unit tests using models. Currently, most auxiliary programming schemes only cover one of the entire programming phases, such as demand summaries or code completions, without a unified multi-phase collaborative process. This section is intended to provide a background or context to the embodiments of the application that are recited in the claims. The description herein is not to be taken as an admission of prior art as including in this section. Disclosure of Invention Aspects of the present application provide a large model-based code generation method, apparatus, system, electronic device, computer readable storage medium, and program product, which can solve the problem that the existing auxiliary programming scheme only focuses on a single development stage but cannot cooperate in multiple stages, and improve the efficiency and code development quality of the whole code development flow. According to one aspect of the application, a code generation method based on a large model is provided, and the code generation method comprises the steps of determining phase related knowledge corresponding to a development phase from a development methodology knowledge base for each development phase in a preset development flow, executing a phase task corresponding to the development phase through an artificial intelligent large model according to the phase related knowledge and a task result of a previous phase of the development phase until the preset development flow is completed, and generating a project code of a target project. The application further provides a code generating device based on the large model, which comprises a knowledge determining unit and a stage developing unit, wherein the knowledge determining unit is configured to determine stage related knowledge corresponding to a development stage from a development methodology knowledge base for each development stage in a preset development process, and the stage developing unit is configured to execute stage tasks corresponding to the development stage until the preset development process is completed according to the stage related knowledge and task results of a previous stage of the development stage through the artificial intelligence large model, so as to generate project codes of target projects. The application further provides a code generation system based on the large model, which comprises a user side, a server side and an artificial intelligence large model, wherein the user side is used for receiving a project development request, the server side is used for determining phase related knowledge corresponding to a development phase from a development methodology knowledge base for each development phase in a preset development flow, and executing a phase task corresponding to the development phase according to the phase related knowledge and a task result of a previous phase of the development phase through the artificial intelligence large model until the preset development flow is completed, so that a project code of a target project represented by the project development request is generated. In another aspect of the application, an electronic device is provided that includes at least one processor and a memory communicatively coupled to the at least one processor, wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the large model-based code generation method as described above. In another aspect of the application, a computer readable storage medium having stored thereon computer program instructions executable by a processor to implement a large model based code generation method as shown above is provided. In another aspect of the application, a computer program product is provided, comprising a computer program which, when executed by a processor, implements a large model based code generation method as shown above. According to the scheme provided by the embodiment of the application, the phase related knowledge corresponding to the development phase is determined from the development methodology knowledge base through each development phase in the preset development flow, the phase task corresponding to the development phase is executed through the artificial intelligence big model according to the phase related knowledge