Code generation method, code generation device and computing device cluster

By building a user-specific code base on the cloud management platform, the problem of mismatch between code and user writing habits and business areas in the existing technology is solved, and more efficient code generation and better user experience is achieved.

CN120215930APending Publication Date: 2025-06-27SHENZHEN HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510152471.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-11
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

In existing code generation technology, the code base covers a wide range, resulting in the generated code not matching the user's writing habits and business areas, affecting the user experience.

Method used

By building the first code library and the second code library on the cloud management platform, the first code library filters common code based on the third-party library information used by the user, and the second code library builds business field code snippets based on the user's historical code to ensure that the generated code meets user habits and business needs.

Benefits of technology

It improves the matching degree of code and user business, reduces the number of codes to be searched, saves search time, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120215930A_ABST
    Figure CN120215930A_ABST
Patent Text Reader

Abstract

The invention provides a code generation method, a code generation device and a computing equipment cluster. The method comprises the steps of obtaining a code generation request input by a user; one or more code snippets conforming to the code generation request are obtained from at least one code library, the at least one code library comprises a first code library, and the first code library is constructed according to information of a third-party library used by the user; and generating a target code according to the one or more code snippets, and sending the target code to the user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular, to a code generation method, a code generation device, and a cluster of computing devices. Background Art

[0002] With the continuous development of computers and the Internet, many traditional industries have also started software development to achieve certain functions through software. Among them, the speed and quality of software development play a crucial role. When developing software, developers can use code generation technology to assist in development, thereby improving development efficiency and reducing development costs.

[0003] Generally, code generation technology searches in existing code libraries to find code snippets required by users. However, these code libraries are usually open-source and gather codes from different business fields and various application scenarios. Due to the wide coverage, code libraries can provide rich codes, but there are also certain problems. In specific implementations, the codes provided to users may not fully match the users' writing habits and / or business fields, seriously affecting the users' experience. Summary of the Invention

[0004] This application provides a code generation method, a code generation device, and a cluster of computing devices, which can provide codes matching the users' business, thereby enhancing the users' experience.

[0005] In a first aspect, this application provides a code generation method. This method is applied to a cloud management platform, which is used to manage infrastructure. The infrastructure includes multiple regions, and each region of the multiple regions includes at least one computing node. The method includes: obtaining a code generation request input by a user; obtaining one or more code snippets that meet the code generation request from at least one code library, where the at least one code library includes a first code library, and the first code library is constructed according to information about third-party libraries used by the user; generating target code according to the one or more code snippets, and sending the target code to the user.

[0006] In the above solution, the cloud management platform constructs the first code library according to the information about third-party libraries used by the user, which not only makes the codes in the first code library conform to the users' writing habits and business fields, but also can reduce the number of codes to be searched, thereby saving search time.

[0007] In a possible implementation manner, before obtaining the code generation request input by the user, the method further includes: screening multiple general codes according to the information about third-party libraries used by the user to obtain the screened general codes, where the information about third-party libraries used by the user is obtained by performing dependency analysis on multiple historical codes of the user; constructing the first code library according to the screened general codes.

[0008] In a possible implementation, multiple general codes are screened according to the information of the third-party libraries used by the user to obtain the screened general codes, including: obtaining the screened general codes from the multiple general codes according to the similarity between the information of the third-party libraries used by the user and the information of the third-party libraries on which the multiple general codes depend.

[0009] In a possible implementation, at least one code library further includes a second code library. Before obtaining the code generation request input by the user, the method further includes: constructing the second code library according to multiple historical codes, where the second code library includes code segments in multiple business domains, and obtaining one or more code segments from at least one code library, including: obtaining one or more code segments from the code segments in the business domain that matches the business identifier of the user.

[0010] In the above solution, the cloud management platform constructs the second code library according to the historical codes of the user. The codes in the second code library fully conform to the user's writing habits and the user's business domain, and can provide better code generation services to the user.

[0011] In a possible implementation, the information of the third-party library includes one or more of the name of the third-party library, the version number of the third-party library, and the name of the application programming interface (API) called in the third-party library.

[0012] In a possible implementation, the method further includes: determining at least one code library accessible to the user from the multiple code libraries according to the identity information of the user and the access permission information of the multiple code libraries.

[0013] In the above solution, through permission control, on the one hand, it can avoid the leakage of code knowledge in different fields, and on the other hand, it can enable the user to generate codes in the most relevant fields.

[0014] In a possible implementation, generating the target code according to one or more code segments includes: inputting the one or more code segments into a code generation model to obtain the target code.

[0015] In a second aspect, the present application further provides a code generation device. The device is applied to a cloud management platform, and the cloud management platform is used to manage infrastructure. The infrastructure includes multiple regions, and each region of the multiple regions includes at least one computing node. The device includes: an acquisition module, a search module, and a generation module.

[0016] Among them, the acquisition module is used to acquire the code generation request input by the user.

[0017] Among them, the search module is used to obtain one or more code snippets that meet the code generation request from at least one code library. The at least one code library includes a first code library, and the first code library is constructed according to the information of the third-party libraries used by the user.

[0018] Among them, the generation module is used to generate target code according to one or more code snippets and send the target code to the user.

[0019] In a possible implementation manner, before obtaining the code generation request input by the user, the obtaining module is further used to: screen multiple general codes according to the information of the third-party libraries used by the user to obtain the screened general codes, where the information of the third-party libraries used by the user is obtained by performing dependency analysis on multiple historical codes of the user; construct the first code library according to the screened general codes.

[0020] In a possible implementation manner, the obtaining module is further used to: obtain the screened general codes from the multiple general codes according to the similarity between the information of the third-party libraries used by the user and the information of the third-party libraries on which the multiple general codes depend.

[0021] In a possible implementation manner, the at least one code library further includes a second code library. Before obtaining the code generation request input by the user, the obtaining module is further used to: construct the second code library according to multiple historical codes, and the second code library includes code snippets in multiple business domains. The search module is further used to: obtain one or more code snippets from the code snippets in the business domain that matches the business identifier of the user.

[0022] In a possible implementation manner, the information of the third-party library includes one or more of the name of the third-party library, the version number of the third-party library, and the name of the application programming interface (API) called in the third-party library.

[0023] In a possible implementation manner, the search module is further used to: determine at least one code library accessible to the user from the multiple code libraries according to the identity information of the user and the access permission information of the multiple code libraries.

[0024] In a possible implementation manner, the generation module is further used to: input one or more code snippets into a code generation model to obtain the target code.

[0025] In a third aspect, the present application further provides a computing device cluster. The cluster may include at least one computing device, and each computing device includes a processor and a memory. The processor of the at least one computing device is used to execute the instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method provided in the first aspect or any possible implementation manner of the first aspect.

[0026] Fourthly, the present application further provides a computer-readable storage medium. The computer-readable storage medium includes computer program instructions. When the computer program instructions are run by a cluster of computing devices, the cluster of computing devices is enabled to execute the method provided in the above first aspect or any one of the possible implementation manners of the first aspect.

[0027] Fifthly, the present application further provides a computer program product. The computer program product includes computer program instructions. When the computer program instructions are executed by a cluster of computing devices, the cluster of computing devices executes the method provided in the above first aspect or any one of the possible implementation manners of the first aspect.

[0028] Any of the above provided apparatuses, clusters of computing devices, computer storage media, or computer program products are all used to execute the method provided above. Therefore, the beneficial effects that can be achieved by them can refer to the beneficial effects of the corresponding solutions in the corresponding methods provided above, which will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 is a schematic structural diagram of a code generation system provided by an embodiment of the present application;

[0030] Figure 2 and Figure 3 is a schematic diagram of constructing a first code library by a cloud management platform provided by an embodiment of the present application;

[0031] Figure 4 and Figure 5 is a schematic diagram of constructing a second code library by a cloud management platform provided by an embodiment of the present application;

[0032] Figure 6 is a schematic diagram of a code processing flow of a cloud management platform provided by an embodiment of the present application;

[0033] Figure 7 is a flowchart of a code generation method provided by an embodiment of the present application;

[0034] Figure 8 is a schematic diagram of a code generation scenario provided by an embodiment of the present application;

[0035] Figure 9a and Figure 9b is a schematic diagram of a code generation process provided by an embodiment of the present application;

[0036] Figure 10 is a schematic diagram of a cloud management platform performing permission control provided by an embodiment of the present application;

[0037] Figure 11 is a schematic diagram of a code generation device provided by an embodiment of the present application;

[0038] Figure 12 is a schematic structural diagram of a computing device provided by an embodiment of the present application;

[0039] Figure 13 and Figure 14 is a schematic structural diagram of a computing device cluster provided by an embodiment of the present application. Detailed implementation manners

[0040] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.

[0041] In the description of the embodiments of the present application, words such as "exemplary", "for example", or "for illustration" are used to represent examples, illustrations, or explanations. Any embodiment or design solution described as "exemplary", "for example", or "for illustration" in the embodiments of the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary", "for example", or "for illustration" is intended to present related concepts in a specific manner.

[0042] In the description of the embodiments of the present application, the term "and / or" only describes the association relationship of associated objects and indicates that three relationships may exist. For example, A and / or B may represent: A exists alone, B exists alone, and A and B exist simultaneously. In addition, unless otherwise specified, the meaning of the term "plural" refers to two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals.

[0043] In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly indicating the technical features indicated. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. The terms "include", "comprise", "have" and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0044] Before introducing the embodiments of the present application, the technical terms mentioned in the embodiments of the present application will be explained below.

[0045] Code generation technology is the specific implementation of retrieval augmented generation (RAG) technology in software development. Specifically, code generation technology is implemented based on a code search model and a code generation model. The code search model searches for similar code required by the user in a code library, and then the code generation model generates code that meets the user's needs based on the retrieved similar code. Code generation technology can understand the user's code requirements and provide the required code for the user. In the case of applying code generation technology, the efficiency of user software development is greatly improved. In specific application scenarios, code generation technology can be implemented as an application plugin, and the application plugin can provide different functions for the user, including but not limited to: code completion, generating code according to comments, generating code according to method names or function names, generating test code, etc. Code completion means that the application plugin automatically completes the code according to the user's current context code, and the completed code can include declarations and implementations of functions, variables, classes, etc. Generating code according to comments means that the code comments describe the functions that the user needs to implement, and the application plugin generates the corresponding code according to the code comments. Generating code according to method names or function names means that when the user enters a method name or a function name, the application plugin can generate the code implementation of the method name or the function name. Generating test code means that the application plugin can generate test code according to the user's test request to ensure the correctness and stability of the newly written code.

[0046] A third-party library refers to the party to which the application programming interface (API) used by the code to implement certain functions or business logics belongs. The information of the third-party library can specifically include one or more of the name of the third-party library, the version number of the third-party library, and the name of the API called in the third-party library.

[0047] Currently, the code library used by code generation technology has gathered codes from different business domains and multiple business domains. Among them, a business domain refers to the specific industry or scenario that the code serves. Due to the wide coverage, the code library can provide rich codes, but it also brings some problems. On the one hand, since the code library has codes from different business domains, it may lead to the retrieved code not being fully matched with the user's programming habits and / or the current business domain, affecting the user experience. On the other hand, due to the large number of codes in the code library, the retrieval time will increase and the code generation efficiency is also low.

[0048] Therefore, the embodiments of this application provide a code generation method, which can solve the above problems.

[0049] The code generation method provided by the embodiments of the present application is applied to a cloud management platform, which is used to manage infrastructure. The infrastructure includes multiple regions, and each region of the multiple regions includes at least one computing node. In this method, the cloud management platform pre-constructs a code library according to the information of third-party libraries used by the user. Then, the cloud management platform can search in these code libraries to obtain reference codes that meet the user's code generation request, generate target codes according to the code generation request and the reference codes, and send the target codes to the user. The cloud management platform constructs the code library according to the information of third-party libraries used by the user, which not only makes the codes in the code library conform to the user's writing habits and business fields, but also can reduce the number of codes to be searched, thus saving the search time.

[0050] The application scenarios of the embodiments of the present application will be introduced below with reference to the accompanying drawings.

[0051] Figure 1 is a schematic structural diagram of a code generation system provided by the embodiments of the present application. As Figure 1 shown, the code generation system includes a cloud management platform and infrastructure. Among them, the cloud management platform is used to manage the infrastructure, and the infrastructure may include at least one region. Each region includes at least one computing node and / or storage node.

[0052] In the code generation system as Figure 1 shown, the cloud management platform can provide code production services, data import services, and code generation services. In the code production service, the cloud management platform can process multiple historical codes and multiple general codes provided by the user and provide initial codes for constructing a code library to the data import service. In the data import service, the cloud management platform can construct at least one of the above-mentioned code libraries according to the initial codes. The at least one code library is deployed to the infrastructure. The cloud management platform can provide the required codes to the user based on the at least one code library.

[0053] In order to make the technical solutions of the present application clearer and easier to understand, the following will be combined with Figure 2 and Figure 4 to introduce two solutions for the cloud management platform to construct a code library.

[0054] Figure 2 is a flowchart of a code library construction method provided by the embodiments of the present application. In the Figure 2 shown method, at least one code library includes a first code library, which is constructed according to general codes and historical codes provided by the user. As Figure 2 shown, the method may include S201 to S203. The process of the cloud management platform constructing the first code library will be described below.

[0055] S201. The code production service performs dependency analysis on multiple historical codes provided by the user to obtain information about the third-party libraries used by the user.

[0056] The user can provide multiple historical codes to the cloud management platform. The user can log in to the client of the cloud management platform using their own account and upload multiple historical codes on the code upload interface. In addition, to save the resource consumption caused by code upload, the user can also enter the code repository address of the multiple historical codes in the code upload interface, and the cloud management platform obtains the multiple historical codes based on this code repository address.

[0057] Based on the above, the code may use API interfaces in third-party libraries to implement certain functions or business logics. Therefore, the code production service can perform dependency analysis on each historical code to obtain information about the third-party libraries relied on by each historical code. Then, the code production service organizes the information about the third-party libraries relied on by each historical code to remove duplicate information, thereby obtaining the information about the third-party libraries used by the user. Specifically, the code production service can call a third-party library analysis tool to analyze each historical code to obtain information about the third-party libraries relied on by each historical code. Among them, this third-party library analysis tool can be built into the cloud management platform.

[0058] The above information about the third-party libraries can include one or more of the identifier of the third-party library, the name of the called API, etc. Among them, the identifier of the third-party library can include one or more of the name and version identifier.

[0059] In some embodiments, as Figure 3 shown, after obtaining the information about the third-party libraries relied on by each historical code, the code production service can send a dependency information list to the user for the user to determine whether the third-party libraries in the dependency information list are safe and reliable. The dependency information list can include the information and / or usage frequency of each third-party library.

[0060] S202. The code production service filters multiple general codes according to the information about the third-party libraries relied on by each historical code to obtain the filtered general codes.

[0061] The code production service can obtain filtered general-purpose codes from multiple general-purpose codes according to the similarity between the information of third-party libraries relied on by multiple historical codes and the information of third-party libraries relied on by multiple general-purpose codes. Specifically, the code production service can calculate the similarity between the information of third-party libraries relied on by each historical code and the information of third-party libraries relied on by each general-purpose code, and then sort them according to the similarity, and select the top S general-purpose codes with the highest similarity from the sorting as the filtered general-purpose codes. Among them, S can be provided by the user to the cloud management platform. In addition, in some embodiments, the code production service can also use the general-purpose codes that meet the similarity threshold as the filtered general-purpose codes.

[0062] S203. The data import service processes the filtered general-purpose codes to obtain the first code library.

[0063] After the code production service obtains the filtered general-purpose codes, the data import service performs Figure 6 the code processing flow shown to obtain the first code library. The code processing flow of the data import service will be introduced later in combination with Figure 6 and will not be elaborated here.

[0064] Figure 4 is a flowchart of another method for constructing a code library provided by an embodiment of the present application. In the Figure 4 method shown, at least one code library includes a first code library and a second code library. The first code library is constructed after filtering multiple general-purpose codes according to general-purpose codes and historical codes provided by the user, and the second code library is constructed according to the historical codes provided by the user. As Figure 4 shown, the method may include S401 to S404. The process of the cloud management platform constructing the first code library and the second code library will be described below.

[0065] S401. The code production service performs dependency analysis on multiple historical codes provided by the user to obtain the information of third-party libraries used by the user.

[0066] S402. The code production service filters multiple general-purpose codes according to the information of third-party libraries relied on by each historical code to obtain filtered general-purpose codes.

[0067] S403. The data import service processes the filtered general-purpose codes to obtain the first code library.

[0068] The specific processes of the above S401 to S403 can refer to the above introduction of S201 to S203 and will not be elaborated here.

[0069] S404. The data import service processes multiple historical codes of the user to obtain the second code library.

[0070] After the code production service filters the general code, as Figure 4 shown, the historical code of the user can be provided to the data import service. The data import service performs Figure 6 the code processing flow shown to obtain the second code library. The code processing flow of the data import service will be described in combination with Figure 6 later and will not be elaborated here.

[0071] In some embodiments, the multiple historical codes provided by the user may include codes in different business domains. As Figure 5 shown, the historical code of the user may include the historical codes of business domains 1 to n. After the code production service provides the historical codes of business domains 1 to n to the data import service, the data import service can perform Figure 6 the code processing flow shown to obtain the second code library. In this case, the second code library includes codes in different business domains. Similarly, the code processing flow of the data import service will be described in combination with Figure 6 later and will not be elaborated here. The user uploads historical codes according to their business domain, and the cloud management platform can process the historical codes in different business domains, thereby constructing a second code library containing codes in different business domains. In this way, the cloud management platform can search in the business domain represented by the user's current business identifier, thereby improving the matching degree between the code and the user's business.

[0072] Figure 6 is a schematic diagram of the code processing flow of the data import service provided by the embodiments of the present application. In Figure 6 , the code processing flow may include code cleaning, code slicing, and index construction.

[0073] During the code cleaning process, the data import service can perform code cleaning on each code provided by the code production service according to the code cleaning rules to obtain the cleaned code. Among them, the code cleaning rules may include one or more of rules such as duplicate function filtering, ultra-short function filtering, and useless function filtering. Among them, ultra-short function filtering means filtering out functions with a function length less than the length threshold. Useless function filtering means filtering according to the pre-set function names. Useless function filtering aims to remove the codes that are no longer needed, thereby improving the code quality and maintainability. Useless functions may include, but are not limited to: constructor functions, get functions, and set functions, etc.

[0074] During the code slicing process, the data import service slices the code after code cleaning to obtain one or more code segments.

[0075] During the process of building an index, the data import service performs index calculation on the sliced code snippets to obtain the indexes of the code snippets, thus completing the construction of the code library. In some embodiments, the index calculation may include vectorizing the code snippets in each code library, and then constructing the indexes of the code snippets according to the vectorized representations of the code snippets. In a specific implementation, the data import service may perform vectorization through an embedding model.

[0076] After introducing the process of building a code library that conforms to user habits and business domains for the cloud management platform, the process of generating code for users by the cloud management platform will be introduced below.

[0077] Figure 7 It is a flowchart of a code generation method provided by an embodiment of the present application. In this method, the cloud management platform can provide target code that meets the user's needs to assist the user in writing software. As Figure 7 shown, this method may include S701 to S703. This method may be executed by Figure 1 the code generation service shown. The following will introduce Figure 7 each step shown.

[0078] S701, obtain the user's code generation request.

[0079] In this embodiment, when the user is writing software, the user sends a code generation request to the cloud management platform, enabling the code generation service to obtain the code generation request. The code generation request may include one or more of context code, code comments, and function identifiers. Among them, the function identifier may include the name of the function and / or the input parameters of the function.

[0080] It should be noted that the specific process of the user triggering the code generation plugin in the embodiments of the present application is not specifically limited. For example, a code generation plugin may be deployed in the user's terminal device. When the user is writing software, the user may send a code generation request through the code generation plugin. The code generation plugin transmits the code generation request to the cloud management platform. In a specific implementation, the user may call the code generation plugin through an input component and provide a code generation request to it. For example Figure 9a as shown, the user may write a function comment and a function identifier in the terminal device through the input component, and then call the code generation plugin by pressing "Enter" to send a code generation request to the code generation plugin. For example Figure 9b as shown, the user may write context code in the terminal device through the input component, and then call the code generation plugin by pressing "Enter" to send a code generation request to the code generation plugin.

[0081] S702, obtain one or more code snippets that meet the code generation request from at least one code library.

[0082] After the code generation service receives the code generation request, as Figure 8 shown, the code generation request is vectorized by the code search module, and then, based on the vectorized representation of the code generation request, search is performed in at least one code library to obtain one or more code snippets. Figure 9a and Figure 9b An exemplary code snippet is shown. It can be understood that Figure 9a and Figure 9b the code snippets in are only given to illustrate the functions of the embodiments of the present application and should not be regarded as a limitation to the embodiments of the present application.

[0083] Among them, at least one code library may include the above-mentioned first code library and / or second code library. The construction processes of the first code library and the second code library may refer to the introduction of the embodiments shown in Figure 2 and Figure 4 above and will not be elaborated here.

[0084] In an alternative embodiment, the code generation service may control the access rights of users. For example Figure 10 as shown, the code generation service may perform permission control based on the user's identity information. Specifically, the code generation service may pre-set the access rights for multiple code libraries, and then, based on the user's identity information and the access rights of the multiple code libraries, determine at least one code library that the current user can access, and then perform a search in the determined code library. Among them, the multiple code libraries include a first code library, a second code library, and a third code library. Among them, the third code library may be obtained by the data import service performing a code processing process on multiple general codes. The code processing process performed on the multiple general codes may refer to the introduction of Figure 6 above and will not be elaborated here.

[0085] For example Figure 10 in the first possible case shown, when the user's identity information meets the access rights of the first code library, the code generation service searches in the first code library; for example Figure 10 in the second possible case shown, when the user's identity information meets the access rights of the third code library, the code generation service searches in the third code library; for example Figure 10 in the third possible case shown, when the user's identity information meets the access rights of the second code library, the code generation service searches in the second code library.

[0086] In some alternative embodiments, the historical codes provided by the user may include codes from different business domains. Thus, the second code library includes codes from different business domains. Accordingly, the code generation service can search in the codes of the business domain indicated by the user's current business identifier. In this case, the user may carry the user's business identifier in the code generation request. Further subdivision of different groups can be managed according to the domain in the second code library knowledge base, and codes more in line with the user's business domain can be provided to the user.

[0087] In some alternative embodiments, the code generation service can also set different access permissions for the codes from different business domains included in the second code library. That is, only members within the current business domain group have the permission to use the codes of that business domain. The above control can, on the one hand, prevent the leakage of code knowledge in different domains, and on the other hand, enable users to search in the most relevant domains to enhance code generation.

[0088] S703, Generate a target code based on one or more code snippets and send the target code to the user.

[0089] After obtaining the code snippets, the code generation service can input one or more code snippets and the code generation request into a code generation model to obtain the target code. For example Figure 9a and Figure 9b As shown, the code generation service can input the code snippets and the code generation request into the code generation model to obtain the target code.

[0090] In the case of obtaining multiple code snippets, the code generation service can also sort the code snippets according to their similarity to the code generation request, and determine the code snippet with the highest similarity among them to input into the code generation model. The similarity between the code snippet and the code generation request can include vector similarity or keyword similarity.

[0091] The above code generation model can be trained based on the code generation requests collected in advance and their corresponding code snippets and target codes. It should be noted that the embodiments of the present application do not specifically limit the structure and training process of the code generation model.

[0092] In some embodiments, the cloud management platform can pre-set different code generation models for different code libraries or combinations of code libraries. For example, the data import service of the cloud management platform can pre-set code generation model A, code generation model B, and code generation model C for the first code library, the second code library, and the third code library respectively, set code generation model D for the combination of the first code library and the second code library, and set code generation model E for the combination of the three code libraries. This can perform targeted code generation for different code libraries and combinations.

[0093] In some embodiments, the above-mentioned first code library and / or second code library can also be deployed on the user's local device. Compared with the third code library, the code snippets included in the first code library and the second code library are relatively few and do not occupy much storage space. Therefore, to save network resources, the first code library and / or the second code library, and the code generation model for the first code library and / or the second code library can be deployed on the user's local device. Among them, the user's local device can include the user's server.

[0094] In the above embodiments of the present application, the cloud management platform filters the general code according to the historical code provided by the user and / or constructs a code library based on the historical code, so that the code snippets in the first code library and the second code library can be constructed to conform to the user's habits and business fields. In this way, the target code generated by the cloud management platform for the user can be more in line with the user's habits and business fields, which can improve the user experience.

[0095] Based on Figure 2 、 Figure 4 and Figure 7 the methods shown, the embodiments of the present application also provide a code generation device.

[0096] Figure 11 FIG. is a schematic structural diagram of a code generation device 1100 provided by an embodiment of the present application. The code generation device 1100 can be used to execute Figure 2 、 Figure 4 and / or Figure 7 the steps in the methods shown.

[0097] As Figure 11 shown, the code generation device 1100 can include an acquisition module 1101, a search module 1102, and a generation module 1103.

[0098] Among them, the acquisition module 1101 is used to acquire a code generation request input by the user.

[0099] Among them, the search module 1102 is used to obtain one or more code snippets that meet the code generation request from at least one code library. The at least one code library includes a first code library, and the first code library is constructed according to the information of the third-party libraries used by the user.

[0100] Among them, the generation module 1103 is used to generate target code according to one or more code snippets and send the target code to the user.

[0101] In a possible implementation, before obtaining the code generation request input by the user, the obtaining module 1101 is further configured to: screen multiple general codes according to the information of the third-party libraries used by the user to obtain the screened general codes, where the information of the third-party libraries used by the user is obtained by performing dependency analysis on multiple historical codes of the user; construct a first code library according to the screened general codes.

[0102] In a possible implementation, the obtaining module 1101 is further configured to: obtain the screened general codes from the multiple general codes according to the similarity between the information of the third-party libraries used by the user and the information of the third-party libraries on which the multiple general codes depend.

[0103] In a possible implementation, at least one code library further includes a second code library. Before obtaining the code generation request input by the user, the obtaining module 1101 is further configured to: construct a second code library according to multiple historical codes, and the second code library includes code segments in multiple business domains. The searching module 1102 is further configured to: obtain one or more code segments from the code segments in the business domain that matches the business identifier of the user.

[0104] In a possible implementation, the information of the third-party library includes one or more of the name of the third-party library, the version number of the third-party library, and the name of the application programming interface (API) called in the third-party library.

[0105] In a possible implementation, the searching module 1102 is further configured to: determine at least one code library accessible to the user from the multiple code libraries according to the identity information of the user and the access permission information of the multiple code libraries.

[0106] In a possible implementation, the generating module 1103 is further configured to: input one or more code segments into a code generation model to obtain target codes.

[0107] Wherein, both the obtaining module 1101 and the searching module 1102 can be implemented by software or can be implemented by hardware. Exemplarily, next, taking the obtaining module 1101 as an example, the implementation manner of the obtaining module 1101 is introduced. Similarly, the implementation manners of the searching module 1102 and the generating module 1103 can refer to the implementation manner of the obtaining module 1101.

[0108] As an example of a software functional unit, the acquisition module 1101 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above computing instance may be one or more. For example, the acquisition module 1101 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers for running the code may be distributed in the same region or in different regions. Further, the multiple hosts / virtual machines / containers for running the code may be distributed in the same availability zone (AZ) or in different AZs, and each AZ includes one data center or multiple geographically proximate data centers. Usually, one region may include multiple AZs.

[0109] Similarly, the multiple hosts / virtual machines / containers for running the code may be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, one VPC is set within one region. For cross-region communication between two VPCs within the same region and between VPCs in different regions, a communication gateway needs to be set in each VPC, and the interconnection between VPCs is realized through the communication gateway.

[0110] As an example of a hardware functional unit, the acquisition module 1101 may include at least one computing device, such as a server, etc. Alternatively, the acquisition module 1101 may also be a device implemented by an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The above PLD may be implemented by a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0111] The multiple computing devices included in the obtaining module 1101 may be distributed in the same region or in different regions. The multiple computing devices included in the obtaining module 1101 may be distributed in the same availability zone (AZ) or in different AZs. Similarly, the multiple computing devices included in the obtaining module 1101 may be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Among them, the multiple computing devices may be any combination of computing devices such as servers, application-specific integrated circuits (ASICs), programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), and generic array logic (GALs).

[0112] It should be noted that in other embodiments, the obtaining module 1101, the searching module 1102, and the generating module 1103 may be used to execute Figure 2 or Figure 4 or Figure 7 any steps in the method. The steps to be implemented by the obtaining module 1101, the searching module 1102, and the generating module 1103 can be specified as needed and are implemented by the obtaining module 1101, the searching module 1102, and the generating module 1103 respectively Figure 2 or Figure 4 or Figure 7 different steps in the method shown to implement all functions of the database management system.

[0113] This application also provides a computing device 1200. As shown in Figure 12 , the computing device 1200 includes: a bus 1201, a processor 1202, a memory 1203, and a communication interface 1204. The processor 1202, the memory 1203, and the communication interface 1204 communicate with each other through the bus 1201. The computing device 1200 may be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 1200.

[0114] The bus 1201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 12 only one line is shown in, but it does not mean that there is only one bus or one type of bus. The bus 1201 may include a path for transmitting information between various components of the computing device 1200 (for example, the memory 1203, the processor 1202, and the communication interface 1204).

[0115] The processor 1202 may include any one or more of processors such as a central processing unit (CPU), a graphics processing unit (GPU), a micro processor (MP), or a digital signal processor (DSP).

[0116] The memory 1203 may include a volatile memory, such as a random access memory (RAM). The processor 1202 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).

[0117] The executable program code is stored in the memory 1203, and the processor 1202 executes the executable program code to implement the functions of the foregoing acquisition module 1101, search module 1102, and generation module 1103 respectively, so as to implement Figure 2 、or Figure 4 、or Figure 7 the methods shown. That is, the memory 1203 stores instructions for executing Figure 2 、or Figure 4 、or Figure 7 the methods shown.

[0118] Alternatively, executable code is stored in the memory 1203, and the processor 1202 executes the executable code to implement the functions of the foregoing code generation device 1100 respectively, so as to implement Figure 2 、or Figure 4 、or Figure 7 the methods shown. That is, the memory 1203 stores instructions for executing Figure 2 、or Figure 4 、or Figure 7 the methods shown.

[0119] The communication interface 1204 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 1200 and other devices or a communication network.

[0120] The embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.

[0121] As Figure 13 shown, the computing device cluster includes at least one computing device 1200. Instructions for executing Figure 2 or Figure 4 or Figure 7 the method shown can be stored in the memory 1203 of one or more computing devices 1200 in the computing device cluster.

[0122] In some possible implementation manners, instructions for executing Figure 2 or Figure 4 or Figure 7 the method shown can also be separately stored in the memory 1203 of one or more computing devices 1200 in the computing device cluster. In other words, a combination of one or more computing devices 1200 can jointly execute the instructions for executing Figure 2 or Figure 4 or Figure 7 the method shown.

[0123] It should be noted that the memories 1203 in different computing devices 1200 in the computing device cluster can store different instructions, which are respectively used to execute partial functions of the code generation device 1100. That is, the instructions stored in the memories 1203 of different computing devices 1200 can implement the functions of one or more modules among the acquisition module 1101 and the search module 1102.

[0124] In some possible implementation manners, one or more computing devices in the computing device cluster can be connected through a network. Among them, the network can be a wide area network or a local area network, etc. Figure 14 shows a possible implementation manner. As Figure 14 shown, two computing devices 1200A and 1200B are connected through a network. Specifically, they are connected to the network through the communication interfaces in each computing device. In this type of possible implementation manners, the memory 1203 in the computing device 1200A stores instructions for executing the function of the acquisition module 1101. At the same time, the memory 1203 in the computing device 1200B stores instructions for executing the functions of the search module 1102 and the generation module 1103.

[0125] Figure 14The connection method between the computing device clusters shown can be considered according to the requirements of the database management method provided in this application. Therefore, it is considered to hand over the functions implemented by the switching module to the computing device 1200B for execution.

[0126] It should be understood that Figure 14 The functions of the computing device 1200A shown in can also be completed by multiple computing devices 1200. Similarly, the functions of the computing device 1200B can also be completed by multiple computing devices 1200.

[0127] This application embodiment also provides another computing device cluster. The connection relationship between the computing devices in this computing device cluster can be similarly referred to Figure 13 and Figure 14 The connection method of the described computing device cluster. The difference is that in one or more computing devices 1200 in this computing device cluster, the memory 1203 may store the same instructions for executing Figure 2 or Figure 4 or Figure 7 The instructions of the shown method.

[0128] In some possible implementation manners, in the memory 1203 of one or more computing devices 1200 in this computing device cluster, there may also be stored instructions for executing Figure 2 or Figure 4 or Figure 7 Part of the instructions of the shown method. In other words, the combination of one or more computing devices 1200 can jointly execute the instructions for executing Figure 2 or Figure 4 or Figure 7 The instructions of the shown method.

[0129] This application embodiment also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions that can run on a computing device or be stored in any available medium. When the computer program product runs on at least one computing device, it causes at least one computing device to execute Figure 2 or Figure 4 or Figure 7 The method shown.

[0130] This application embodiment also provides a computer-readable storage medium. The computer-readable storage medium may be any available medium that a computing device can store or a data storage device such as a data center containing one or more available media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid-state drive), etc. The computer-readable storage medium includes instructions, and the instructions direct the computing device to execute Figure 2 or Figure 4, or Figure 7 the method shown, or instruct the computing device to execute Figure 2 , or Figure 4 , or Figure 7 the method shown.

[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.

Claims

1. A code generation method, characterized in that: Applied to a cloud management platform, the cloud management platform is used to manage infrastructure, the infrastructure includes multiple areas, each of the multiple areas includes at least one computing node, the method includes: Get the code generation request input by the user; Obtaining one or more code snippets that meet the code generation request from at least one code library, wherein the at least one code library includes a first code library, and the first code library is constructed according to information of a third-party library used by the user; Generate target code according to the one or more code snippets, and send the target code to the user.

2. The method according to claim 1, characterized in that Before obtaining the code generation request input by the user, the method further includes: The plurality of common codes are screened according to information of a third-party library used by the user to obtain screened common codes, wherein the information of the third-party library used by the user is obtained by performing dependency analysis on a plurality of historical codes of the user; The first code library is constructed according to the filtered common codes.

3. The method according to claim 2, characterized in that The filtering of the plurality of common codes according to the information of the third-party library used by the user to obtain the filtered common codes includes: The filtered universal code is obtained from the plurality of universal codes according to the similarity between the information of the third-party library used by the user and the information of the third-party library on which the plurality of universal codes depend.

4. The method according to any one of claims 2 to 3, characterized in that: The at least one code library also includes a second code library. Before obtaining the code generation request input by the user, the method further includes: The second code base is constructed according to the plurality of historical codes, wherein the second code base includes code snippets of a plurality of business fields. The obtaining one or more code snippets from at least one code library includes: The one or more code snippets are obtained from code snippets of a business domain that matches the business identifier of the user.

5. The method according to any one of claims 1 to 4, characterized in that: The third-party library information includes one or more of the name of the third-party library, the version number of the third-party library, and the name of the application programming interface API in the third-party library.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: According to the identity information of the user and the access permission information of the multiple code repositories, the at least one code repositories accessible to the user is determined from the multiple code repositories.

7. The method according to any one of claims 1 to 6, characterized in that: Generating target code according to the one or more code snippets comprises: The one or more code snippets are input into a code generation model to obtain the target code.

8. A code generating device, characterized in that: Applied to a cloud management platform, the cloud management platform is used to manage infrastructure, the infrastructure includes multiple areas, each of the multiple areas includes at least one computing node, the device includes: An acquisition module is used to obtain a code generation request input by a user; A search module, configured to obtain one or more code snippets that meet the code generation request from at least one code library, wherein the at least one code library includes a first code library, and the first code library is constructed according to information of a third-party library used by the user; A generating module is used to generate a target code according to the one or more code snippets and send the target code to the user.

9. The device according to claim 8, characterized in that Before obtaining the code generation request input by the user, the obtaining module is further used to: The plurality of common codes are screened according to information of a third-party library used by the user to obtain screened common codes, wherein the information of the third-party library used by the user is obtained by performing dependency analysis on a plurality of historical codes of the user; The first code library is constructed according to the filtered common codes.

10. The device according to claim 9, characterized in that The acquisition module is also used for: The filtered universal code is obtained from the plurality of universal codes according to the similarity between the information of the third-party library used by the user and the information of the third-party library on which the plurality of universal codes depend.

11. The device according to any one of claims 9 to 10, characterized in that: The at least one code library further includes a second code library, and before obtaining the code generation request input by the user, the obtaining module is further used to: The second code base is constructed according to the plurality of historical codes, wherein the second code base includes code snippets of a plurality of business fields. The search module is also used to: The one or more code snippets are obtained from code snippets of a business domain that matches the business identifier of the user.

12. The device according to any one of claims 8 to 11, characterized in that: The third-party library information includes one or more of the name of the third-party library, the version number of the third-party library, and the name of the application programming interface API in the third-party library.

13. The device according to any one of claims 8 to 12, characterized in that: The search module is also used to: According to the identity information of the user and the access permission information of the multiple code repositories, the at least one code repositories accessible to the user is determined from the multiple code repositories.

14. The device according to any one of claims 8 to 13, characterized in that: The generation module is also used for: The one or more code snippets are input into a code generation model to obtain the target code.

15. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 7.

16. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device cluster, the computing device cluster executes the method according to any one of claims 1 to 7.

17. A computer-readable storage medium, characterized in that: The method comprises computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method according to any one of claims 1 to 7.