Method and apparatus for generating code content, device, and storage medium
By acquiring and correcting errors in the code generated by the generative model, and using reference information to generate high-quality code, the problem of generative model-generated content not meeting user expectations is solved, and more accurate code generation is achieved.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- BEIJING ZITIAO NETWORK TECH CO LTD
- Filing Date
- 2024-12-25
- Publication Date
- 2026-07-02
AI Technical Summary
Generative models may generate code with incorrect formatting, data, and logic, resulting in content that does not meet user expectations.
By acquiring the code content generated by the first model, identifying its errors, and using reference information and the second model to correct them, high-quality code content is generated.
It improves the quality of generated code content, reduces the generation of misleading information, and ensures that the generated code better meets user expectations.
Smart Images

Figure CN2024142514_02072026_PF_FP_ABST
Abstract
Description
A method, apparatus, device, and storage medium for generating code content. Technical Field
[0001] The exemplary embodiments disclosed herein generally relate to the field of computers, and particularly to a method, apparatus, device, and computer-readable storage medium for generating code content. Background Technology
[0002] When using generative models to generate code, users typically need to provide system prompts and questions to the model so that it can generate results based on the input. However, due to factors such as variations in the capabilities of generative models, instruction compliance issues, token window limitations, and inadequate user prompts, the content generated by the generative model may not meet the user's expectations. For example, the generated content may contain incorrect formatting, incorrect data, or flawed logic. Addressing these issues is crucial to improving the quality of code generated by generative models. Summary of the Invention
[0003] In a first aspect of this disclosure, a method for generating code content is provided. The method includes: acquiring first code content generated by a first model based on a code processing request; determining a first error associated with the first code content; acquiring reference information associated with the first error; and providing a second model with the code processing request, the reference information, and the first code content to generate second code content for the code processing request.
[0004] In a second aspect of this disclosure, an apparatus for generating code content is provided. The apparatus includes: a first acquisition module configured to acquire first code content generated by a first model based on a code processing request; a first determination module configured to determine a first error associated with the first code content; a second acquisition module configured to acquire reference information associated with the first error; and a first providing module configured to provide the code processing request, the reference information, and the first code content to a second model to generate second code content in response to the code processing request.
[0005] In a third aspect of this disclosure, an electronic device is provided. The device includes at least one processing unit; and at least one memory coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit. When executed by the at least one processing unit, the instructions cause the device to perform the method of the first aspect.
[0006] In a fourth aspect of this disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program that can be executed by a processor to implement the method of the first aspect.
[0007] In a fifth aspect of this disclosure, a computer program product is provided. The computer program product includes computer-executable instructions that, when executed by a processor, implement the method of the first aspect.
[0008] It should be understood that the content described in this content section is not intended to limit the key or essential features of the embodiments of this disclosure, nor is it intended to restrict the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0009] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. In the drawings, the same or similar reference numerals denote the same or similar elements, wherein:
[0010] Figure 1 shows a schematic diagram of an example environment in which embodiments of the present disclosure may be implemented;
[0011] Figure 2 shows a flowchart of an example process for generating code content according to some disclosed embodiments;
[0012] Figure 3 illustrates an example system diagram for generating code content according to some embodiments of the present disclosure;
[0013] Figure 4 shows a schematic structural block diagram of an example apparatus for generating code content according to some embodiments of the present disclosure; and
[0014] Figure 5 shows a block diagram of an electronic device capable of implementing several embodiments of the present disclosure. Detailed Implementation
[0015] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0016] It should be noted that the headings of any section / subsection provided herein are not limiting. Various embodiments are described throughout this document, and embodiments of any type may be included under any section / subsection. Furthermore, embodiments described in any section / subsection may be combined in any way with any other embodiments described in the same section / subsection and / or different sections / subsections.
[0017] In the description of embodiments of this disclosure, the term "comprising" and similar terms should be understood as open-ended inclusion, i.e., "including but not limited to". The term "based on" should be understood as "at least partially based on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The term "some embodiments" should be understood as "at least some embodiments". Other explicit and implicit definitions may also be included below. The terms "first", "second", etc., may refer to different or the same objects. Other explicit and implicit definitions may also be included below.
[0018] The embodiments of this disclosure may involve user data, data acquisition, and / or use. All of these aspects comply with applicable laws, regulations, and relevant provisions. In the embodiments of this disclosure, all data collection, acquisition, processing, manipulation, forwarding, and use are conducted with the user's knowledge and confirmation. Accordingly, in implementing the embodiments of this disclosure, the type, scope of use, and usage scenarios of any data or information that may be involved should be communicated to the user and their authorization obtained in accordance with relevant laws and regulations through appropriate means. The specific methods of notification and / or authorization may vary depending on the actual situation and application scenario, and the scope of this disclosure is not limited in this respect.
[0019] In this specification and the embodiments, any processing of personal information will be carried out only under the premise of legality (such as obtaining the consent of the personal information subject, or being necessary for the performance of a contract), and will only be carried out within the scope stipulated or agreed upon. A user's refusal to process personal information other than that necessary for basic functions will not affect the user's use of basic functions.
[0020] As mentioned above, when using generative models to generate code, users typically need to provide system prompts and questions to the model so that it can generate results based on the input. However, due to factors such as variations in the capabilities of generative models, instruction compliance issues, token window limitations, and inadequate user prompts, the content generated by the generative model may not meet the user's expectations. For example, the generated content may contain incorrect formatting, incorrect data, or flawed logic. Solving these problems is key to improving the quality of code generated by generative models.
[0021] Embodiments of this disclosure propose a scheme for generating code content. The scheme includes: obtaining first code content generated by a first model based on a first request; determining a first error included in the first code content based on a first execution result corresponding to the first code content; generating reference information associated with the first error based on the first execution result; and providing the reference information and the first code content to a second model to generate second code content for the first request.
[0022] In this way, embodiments of the present disclosure can construct reference information associated with the first error, enabling the second model to generate second code content for the first request based on the reference information, thereby effectively improving the quality of the generated code content.
[0023] The following section provides a detailed description of various example implementations of this scheme, with reference to the accompanying drawings.
[0024] Example Environment
[0025] Figure 1 illustrates a schematic diagram of an example environment 100 in which embodiments of the present disclosure can be implemented. As shown in Figure 1, the example environment 100 may include an electronic device 110.
[0026] In this example environment 100, electronic device 110 may be, for example, a server, which may support the operation of development tool 120. Development tool 120, also known as an integrated development environment (IDE), provides developers with various tools and functions needed to write, debug, and run code.
[0027] In environment 100 of Figure 1, if application 120 is active, electronic device 110 can use application 120 to present interface 150 for supporting the generation of code content.
[0028] In some scenarios, development tool 120 can be deployed on suitable terminal devices. Examples of terminal devices may include, but are not limited to, any type of mobile terminal, fixed terminal, or portable terminal, including mobile phones, desktop computers, laptop computers, notebook computers, netbook computers, tablet computers, media computers, multimedia tablets, handheld computers, portable gaming terminals, VR / AR devices, personal communication system (PCS) devices, personal navigation devices, personal digital assistants (PDAs), audio / video players, digital cameras / camcorders, positioning devices, television receivers, radio receivers, e-book devices, gaming devices, or any combination of the foregoing, including accessories and peripherals of these devices or any combination thereof.
[0029] Additionally, as shown in Figure 1, development tool 120 can also utilize model 150 to handle user requests within the application. As an example, development tool 120 can support users initiating requests such as code generation, code explanation, and code modification via dialogue.
[0030] As shown in the figure, the development tool 120 can receive natural language text 130 input by the user and can use the model 150 to generate response content 140 for the natural language text 130. For example, the development tool 120 can present the code content generated by the model 150 based on the natural language text 130.
[0031] Electronic device 110 can be, for example, a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks, and big data and artificial intelligence platforms. Electronic device 110 can also include, for example, computing systems / servers, such as mainframes, edge computing nodes, computing devices in cloud environments, and so on.
[0032] It should be understood that the structure and function of the various elements in environment 100 are described for illustrative purposes only and do not imply any limitation on the scope of this disclosure.
[0033] The following description will continue with reference to the accompanying drawings, which will provide some exemplary embodiments of this disclosure.
[0034] Example process
[0035] Figure 2 shows a flowchart of an example process 200 for generating code content according to some embodiments of the present disclosure. Process 200 can be implemented at electronic device 110. Process 200 will now be described with reference to Figure 1.
[0036] As shown in Figure 2, in box 210, electronic device 110 acquires first code content generated by a first model based on a code processing request. As an example, Figure 3 illustrates a system 300 for generating code content according to some embodiments of this disclosure. System 300 may be used, for example, to generate user-instructed code content via a model 150 associated with development tool 120. Electronic device 110 may invoke acquisition unit 310 to acquire a code processing request input by the user through development tool 120. The code processing request may, for example, include natural language text 130 input by the user through development tool 120. Such natural language text 130 may, for example, include prompts or user questions input by the user through development tool 120. Prompts may, for example, be “You are a senior software development engineer, especially skilled in development using Python.” User questions may, for example, be “Please write a bubble sort algorithm implemented in Python.”
[0037] After the electronic device 110 receives the code processing request through the acquisition unit 310, the electronic device 110 can input the code processing request into the first model 320 to generate the first code content. The first model 320 may be, for example, a language model.
[0038] In code content generation scenarios, language models encounter numerous problems during the generation process due to subjective or objective factors. For example, language models are easily misled by prompts or user instructions, leading to the fabrication of non-existent facts, knowledge, or logic. Furthermore, user-input prompts may contain errors, unclear logic, or poor execution. These issues all affect the quality of the content generated by the language model. Therefore, detecting errors in the content generated by the language model is crucial for improving the quality of the generated code content. Continuing to refer to Figure 2, in box 220, the electronic device 110 determines a first error associated with the first code content. As an example, as shown in Figure 3, after obtaining the first code content, the electronic device 110 can invoke the error-checking unit 330 to perform error detection on the first code content to determine the first error associated with it. The error-checking unit 330 can be implemented as any suitable code checker; the type of code checker can be selected by those skilled in the art according to their needs, and this disclosure does not impose any limitations on this.
[0039] In some embodiments, the electronic device 110 can determine the error category corresponding to the first error through the error checking unit 330. Specifically, the electronic device 110 can use a code checker to determine the first error associated with the first code content. The first error includes at least one of the following: syntax error, compilation error, runtime error, and code logic error. As an example, after obtaining the first code content, the electronic device 110 can determine the code checker corresponding to the programming language corresponding to the first code content. Further, the electronic device 110 can use the code checker to determine the error type corresponding to the first code content.
[0040] Among the various error types corresponding to the first error, a syntax error indicates that the syntax structure of the first code content does not conform to the normal syntax structure. A compilation error indicates a syntax or semantic error detected by the compiler during the compilation of the first code content into an executable file or bytecode. Compilation errors include: type errors, scope errors, macro definition errors, etc.
[0041] Runtime errors indicate errors that occur during execution after the initial code has been successfully compiled. Runtime errors include: null pointer exceptions, array out-of-bounds exceptions, type conversion errors, etc.
[0042] A logical error indicates that there is an incorrect condition judgment, incorrect loop logic, etc. in the first code content.
[0043] In some embodiments, the electronic device 110 may also determine whether the output result matches a reference result based on the output result of the first code content, thereby determining whether there is an error in the first code content. Specifically, the electronic device 110 may execute the first code content to output a result. Further, the electronic device 110 may determine a first error associated with the first code content in response to a mismatch between the output result and the reference result.
[0044] As an example, electronic device 110 compiles and executes the first code content to obtain the output result of the first code content. Such output result may be, for example, the calculation result of the algorithm corresponding to the first code content, such as the sorting result of bubble sort. After obtaining the output result by executing the first code content, electronic device 110 can obtain the reference result associated with the first code content.
[0045] The reference result can be determined by the electronic device 110 from the code processing request, i.e., the reference result has been specified by the user when entering the prompt words and user question. In some scenarios, the electronic device 110 can generate test cases associated with the first code content using a language model. Further, the electronic device 110 can determine the reference result through the test cases. In some scenarios, the reference result can also be the expected output result. The expected output result can be, for example, an output result specified by the user, i.e., it is included in the code processing request. The expected output result can also be obtained by the electronic device 110 predicting the first code content using an appropriate prediction model.
[0046] Once the reference result is acquired or determined by the electronic device 110, the electronic device 110 can match the output result with the reference result. When the output result does not match the reference result, the electronic device 110 can determine that there is an error in the first code content. By using an inspector to perform multi-dimensional error detection on the first code content and combining it with a language model to generate test cases, the accuracy and effectiveness of the detection results can be improved.
[0047] Referring again to Figure 2, in box 230, electronic device 110 can acquire reference information associated with the first error. As an example, as shown in Figure 3, electronic device 110 can input the first error into feedback unit 340 to generate reference information associated with the first error. The reference information could be, for example, targeted repair suggestions generated by feedback unit 340 based on the first error. Targeted repair suggestions could be, for example, information such as repair cases or related knowledge. Feedback unit 340 can be implemented as a Retrieval-augmented Generation (RAG) model. The RAG model is a technique that combines information retrieval and language modeling, aiming to enhance the performance of language models through external knowledge bases.
[0048] In some embodiments, the electronic device 110 may obtain at least a portion of the information from an external knowledge base (i.e., an information repository) based on the first error. The reference information includes at least one of the following: a description of the first error, a repair example of the first error, and knowledge information associated with the first error.
[0049] As an example, when generating reference information, electronic device 110 can retrieve information related to the first error from an external knowledge base (i.e., information base) through feedback unit 340. Such information could include, for example, a repair example for the first error, or knowledge information associated with the first error. Furthermore, feedback unit 340 can also obtain descriptive content associated with the first error, which could include, for example, the error code and error type of the first error. Finally, feedback unit 340 can generate reference information based on the descriptive content of the first error, the repair example for the first error, and the knowledge information associated with the first error, to instruct subsequent models to repair the first error based on the reference information.
[0050] For example, the target code portion corresponding to the first error in the first code content is "for range(n)in i". Electronic device 110 can then generate corresponding reference information based on this error. The reference information may include, for example, text prompts and code examples. Text prompts may include, for example, "Syntax error: range(n) uses incorrect parentheses. English parentheses should be used instead of Chinese parentheses during code editing," or "Logical error: the logic of 'for range(n)in i' is reversed; i should usually be the loop variable." Code examples may include, for example, "for i in range(n)".
[0051] In this way, electronic device 110 can use reference information to optimize the generation results of subsequent models, thereby improving the accuracy of the generated content and reducing the generation of misleading information.
[0052] Referring again to Figure 2, in box 240, electronic device 110 provides a code processing request, reference information, and first code content to the second model to generate second code content in response to the code processing request. As an example, as shown in Figure 3, after the reference information associated with the first error is obtained, electronic device 110 can construct the input sequence of the second model 350 based on the reference information, the code processing request, and the first code content. After obtaining the input sequence constructed from the reference information, the code processing request, and the first code content, the second model 350 can correct the first code content based on the reference information using correction unit 360 to generate the second code content. In some scenarios, correction unit 360 can be deployed inside the second model 350.
[0053] Alternatively or concurrently, the first model and the second model may be the same model or different models. When the first model and the second model are different models, the second model may be a model determined by the electronic device 110 based on the programming language of the first code content. Generating code content using a model that matches the programming language of the first code content can effectively improve the quality of the generated content.
[0054] In some embodiments, to improve the generation quality of the second code content, the second model can be a model selected by the electronic device 110 based on the programming language of the first code content. Specifically, the electronic device 110 can determine the programming language corresponding to the first code content. Further, the electronic device 110 can determine the second model corresponding to the programming language. As an example, the electronic device 110 can identify the programming language corresponding to the first code content based on information such as the syntax structure, keywords, and comment style of the first code content. This identification process can be implemented by the electronic device 110 through a pre-trained programming language classification model, or it can be implemented by the electronic device 110 by comparing feature libraries of different programming languages.
[0055] Because different programming languages have significant differences in syntax rules and data structures, electronic device 110 needs to determine the corresponding second model based on the programming language of the first code content. This ensures that the second code content generated from the second model is more accurate.
[0056] In some embodiments, to ensure the accuracy of the generated code content, the electronic device 110 can also perform a second round of error checking on the second code content. Specifically, the electronic device 110 can identify a second error associated with the second code content. Further, the electronic device 110 can generate additional reference information associated with the second error. Finally, the electronic device 110 can provide the additional reference information to the second model to generate a third code content for the code processing request. As an example, as shown in FIG3, after the second code content is generated, the electronic device 110 can input the second code content to the error checking unit 330 to start the second round of error checking. The specific error checking process and error repair process are similar to the process described above, and will not be repeated here. Through multiple rounds of error checking and error repair, the quality of the generated code content can be effectively improved.
[0057] In some embodiments, the electronic device 110 may provide the second code content as a response to a code processing request in response to the second code content meeting preset conditions. For example, after the second code content is generated, the electronic device 110 may detect whether the second code content meets preset conditions. Preset conditions may include, for example, that the output of the second code content matches a reference result, that the time complexity of the second code content is less than a first preset value, or that the space complexity of the second code content is less than a second preset value. Specific preset conditions can be set by those skilled in the art according to their needs, and this disclosure does not impose any limitations on this. When the second code content meets the preset conditions, the electronic device 110 may present the second code content as a response to the code processing request to the user.
[0058] In this way, embodiments of the present disclosure can construct reference information associated with the first error, enabling the second model to generate second code content for the first request based on the reference information, thereby effectively improving the quality of the generated code content.
[0059] Example devices and equipment
[0060] Embodiments of this disclosure also provide corresponding apparatus for implementing the methods or processes described above. Figure 4 shows a schematic structural block diagram of an example apparatus 400 for generating code content according to certain embodiments of this disclosure. Apparatus 400 may be implemented as or included in electronic device 110. The various modules / components in apparatus 400 may be implemented by hardware, software, firmware, or any combination thereof.
[0061] As shown in Figure 4, the device 400 includes: a first acquisition module 410 configured to acquire first code content generated by a first model based on a code processing request; a first determination module 420 configured to determine a first error associated with the first code content; a second acquisition module 430 configured to acquire reference information associated with the first error; and a first providing module 440 configured to provide a code processing request, reference information, and the first code content to a second model to generate second code content for the code processing request.
[0062] In some embodiments, the apparatus 400 further includes a generation module configured to determine a second error associated with the second code content; generate additional reference information associated with the second error; and provide the additional reference information to the second model to generate third code content for a code processing request.
[0063] In some embodiments, the first determining module 420 is further configured to: use a code inspector to determine a first error associated with the first code content, the first error including at least one of the following: syntax error, compilation error, runtime error, and code logic error.
[0064] In some embodiments, the first determining module 420 is further configured to: execute the first code content to determine the output result; and in response to a mismatch between the output result and a reference result, determine a first error associated with the first code content.
[0065] In some embodiments, the reference information includes at least one of the following: a description of the first error; an example of how to fix the first error; and knowledge information associated with the first error.
[0066] In some embodiments, at least part of the reference information is retrieved from a database based on a first error.
[0067] In some embodiments, the apparatus 400 further includes a third determining module configured to determine a programming language corresponding to the first code content; and to determine a second model corresponding to the programming language.
[0068] In some embodiments, the apparatus 400 further includes a second providing module configured to provide the second code content as response content to a code processing request in response to the second code content meeting preset conditions.
[0069] The modules included in device 400 can be implemented in various ways, including software, hardware, firmware, or any combination thereof. In some embodiments, one or more modules may be implemented using software and / or firmware, such as machine-executable instructions stored on a storage medium. In addition to or as an alternative to machine-executable instructions, some or all of the units in device 400 may be implemented at least partially by one or more hardware logic components. By way of example and not limitation, exemplary types of hardware logic components that may be used include field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.
[0070] Figure 5 shows a block diagram of an electronic device 500 in which one or more embodiments of the present disclosure may be implemented. It should be understood that the electronic device 500 shown in Figure 5 is merely exemplary and should not constitute any limitation on the functionality and scope of the embodiments described herein. The electronic device 500 shown in Figure 5 can be used to implement the electronic device 110 discussed above.
[0071] As shown in Figure 5, the electronic device 500 is in the form of a general-purpose electronic device. Components of the electronic device 500 may include, but are not limited to, one or more processors or processing units 510, memory 520, storage devices 530, one or more communication units 540, one or more input devices 550, and one or more output devices 560. The processing unit 510 may be a physical or virtual processor and is capable of performing various processes according to programs stored in the memory 520. In a multiprocessor system, multiple processing units execute computer-executable instructions in parallel to improve the parallel processing capability of the electronic device 500.
[0072] Electronic device 500 typically includes multiple computer storage media. Such media can be any accessible media that is accessible to electronic device 500, including but not limited to volatile and non-volatile media, removable and non-removable media. Memory 520 can be volatile memory (e.g., registers, cache, random access memory (RAM)), non-volatile memory (e.g., read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory), or some combination thereof. Storage device 530 can be removable or non-removable media and can include machine-readable media, such as flash drives, disks, or any other media that can be used to store information and / or data and can be accessed within electronic device 500.
[0073] Electronic device 500 may further include additional removable / non-removable, volatile / non-volatile storage media. Although not shown in FIG. 5, disk drives for reading from or writing to removable, non-volatile disks (e.g., "floppy disks") and optical disk drives for reading from or writing to removable, non-volatile optical disks may be provided. In these cases, each drive may be connected to a bus (not shown) via one or more data media interfaces. Memory 520 may include computer program product 525 having one or more program modules configured to perform various methods or actions of various embodiments of the present disclosure.
[0074] Communication unit 540 enables communication with other electronic devices via a communication medium. Additionally, the functionality of components of electronic device 500 can be implemented using a single computing cluster or multiple computing machines capable of communicating via communication connections. Therefore, electronic device 500 can operate in a networked environment using logical connections to one or more other servers, network personal computers (PCs), or another network node.
[0075] Input device 550 can be one or more input devices, such as a mouse, keyboard, trackball, etc. Output device 560 can be one or more output devices, such as a monitor, speaker, printer, etc. Electronic device 500 can also communicate with one or more external devices (not shown) via communication unit 540 as needed. These external devices include storage devices, display devices, etc., and can communicate with one or more devices that enable user interaction with electronic device 500, or with any device that enables electronic device 500 to communicate with one or more other electronic devices (e.g., network card, modem, etc.). Such communication can be performed via input / output (I / O) interface (not shown).
[0076] According to an exemplary implementation of this disclosure, a computer-readable storage medium is provided that stores computer-executable instructions thereon, wherein the computer-executable instructions are executed by a processor to implement the methods described above. According to an exemplary implementation of this disclosure, a computer program product is also provided, which is tangibly stored on a non-transitory computer-readable medium and includes computer-executable instructions, which are executed by a processor to implement the methods described above.
[0077] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatuses, devices, and computer program products implemented according to this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0078] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processing unit of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0079] Computer-readable program instructions can be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions that execute on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0080] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction, which contains one or more executable instructions for implementing the specified logical function. In some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0081] Various implementations of this disclosure have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed implementations. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described implementations. The terminology used herein is chosen to best explain the principles, practical applications, or improvements to technology in the market, or to enable others skilled in the art to understand the various implementations disclosed herein.
Claims
1. A method for generating code content, comprising: Obtain the first code content generated by the first model based on the code processing request; Identify the first error associated with the first code content; Obtain reference information associated with the first error; as well as The code processing request, the reference information, and the first code content are provided to the second model to generate second code content in response to the code processing request.
2. The method according to claim 1, further comprising: Identify a second error associated with the content of the second code; Generate additional reference information associated with the second error; as well as The additional reference information is provided to the second model to generate third code content for the code processing request.
3. The method of claim 1, wherein determining the first error associated with the first code content comprises: The code inspector is used to identify the first error associated with the first code content, and the first error includes at least one of the following: syntax error, compilation error, runtime error, and code logic error.
4. The method of claim 1, wherein determining the first error associated with the first code content comprises: Execute the first code to determine the output. as well as In response to the mismatch between the output and the reference result, the first error associated with the first code content is determined.
5. The method of claim 1, wherein the reference information includes at least one of the following: The description of the first error; Example of fixing the first error; Knowledge information associated with the first error.
6. The method of claim 1, wherein at least a portion of the reference information is retrieved from the information database based on the first error.
7. The method according to claim 1, further comprising: Determine the programming language corresponding to the first code content; as well as Determine the second model corresponding to the programming language.
8. The method according to claim 1, further comprising: In response to the second code content meeting preset conditions, the second code content is provided as a response to the code processing request.
9. An apparatus for generating code content, comprising: The first acquisition module is configured to acquire the first code content generated by the first model based on the code processing request; The first determining module is configured to determine a first error associated with the first code content; The second acquisition module is configured to acquire reference information associated with the first error; as well as A first providing module is configured to provide the code processing request, the reference information, and the first code content to a second model to generate second code content in response to the code processing request.
10. An electronic device, comprising: At least one processing unit; as well as At least one memory, coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, which, when executed by the at least one processing unit, cause the electronic device to perform the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program stored thereon, the computer program being executable by a processor to implement the method according to any one of claims 1 to 8.
12. A computer program product comprising computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the method according to any one of claims 1 to 8.