Code updating method, code generating method, task processing method and code interpreter based on large model

Through the large model-based code update method and code sandbox, the deficiencies in error handling and complex task processing of code interpreters in the existing technology are solved, efficient and accurate code generation is achieved, and programming difficulty is reduced.

CN118519660APending Publication Date: 2024-08-20BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410797752.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-08-20

AI Technical Summary

Technical Problem

Existing code interpreters lack an effective code error correction mechanism in handling code execution errors, which limits development efficiency. Moreover, the code instructions generated when facing complex tasks are uneven and cannot meet high-standard application requirements.

Method used

Using a code update method based on a large model, by receiving running feedback information from the test environment, generating session information and updating the code until the target code that can run normally is obtained, combined with the code sandbox and error reflection module, iterative updates and corrections of the code are achieved .

Benefits of technology

It effectively improves the quality and efficiency of code generation, takes into account the efficiency and accuracy of code generation, and lowers the programming threshold, allowing users without a deep programming background to complete complex programming tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118519660A_ABST
    Figure CN118519660A_ABST
Patent Text Reader

Abstract

The invention provides a code updating method, a code generating method, a task processing method and a code interpreter based on a large model, and relates to the technical field of artificial intelligence, in particular to the technical fields of deep learning, natural language processing, software engineering and large models. According to the specific implementation scheme, operation feedback information from a test environment is received, the operation feedback information is used for representing an operation result of a code in the test environment, and the code is generated based on a user intention by using a large language model; in response to the operation feedback information representing a code operation error, obtaining session information based on an error state of the code; and updating the code by using the session information to obtain an updated code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to the field of deep learning, natural language processing, software engineering, and large model technology, and more specifically to a code updating method, a code generation method, a task processing method, and a code interpreter based on a large model. Background Art

[0002] With the continuous development of big models, their application in professional fields is becoming more and more extensive. For example, in the field of software engineering, code big models can generate high-quality code based on the user's context and needs, thereby meeting the requirements on the code. Summary of the invention

[0003] The present invention provides a code updating method, a code generating method, a task processing method and a code interpreter based on a large model.

[0004] According to one aspect of the present disclosure, a large model-based code update method is provided, comprising: receiving operation feedback information from a test environment, the operation feedback information is used to indicate the operation result of the code in the test environment, the code is generated based on the user intention using a large language model; in response to the operation feedback information indicating that the code runs incorrectly, based on the error state of the code, obtaining session information; and updating the code using the session information to obtain updated code.

[0005] According to another aspect of the present disclosure, a code generation method is provided, comprising: in response to a code generation request, generating initial code based on intent information included in the code generation request; and in a test environment, iteratively updating the currently running code based on an error status of the currently running code to obtain a target code, wherein in a first code update round, the currently running code is the initial code.

[0006] According to another aspect of the present disclosure, a task processing method is provided, comprising: in response to a task processing request, parsing a task text of a target task included in the task processing request to obtain intent information; generating an initial code based on the intent information; in a test environment, iteratively updating the currently running code based on an error status of the currently running code to obtain a target code, wherein, in a first code update round, the currently running code is the initial code; and running the target code in a production environment to execute the target task.

[0007] According to another aspect of the present disclosure, a code interpreter is provided, including: a code sandbox configured to provide a test environment, the code sandbox configured to receive code, run the code in the test environment, and generate running feedback information of the code, wherein the code is generated by a large language model; an error reflection module configured to receive the running feedback information, obtain session information based on the error state of the code in response to the running feedback information indicating that the code runs incorrectly, and send the session information to the large language model, wherein the large language model is configured to generate updated code based on the session information and the code.

[0008] According to another aspect of the present disclosure, a code updating device based on a large model is provided, including: a receiving module, used to receive operation feedback information from a test environment, the operation feedback information is used to indicate the operation result of the code in the test environment, and the code is generated based on the user intention using a large language model; a first processing module, used to obtain session information based on the error state of the code in response to the operation feedback information indicating that the code runs incorrectly; and a first updating module, used to update the code using the session information to obtain an updated code.

[0009] According to another aspect of the present disclosure, a code generation device is provided, including: a first generation module, used to generate initial code in response to a code generation request based on intent information included in the above code generation request; and a second update module, used to iteratively update the above currently running code in a test environment based on an error status of the currently running code to obtain a target code, wherein in a first code update round, the above currently running code is the above initial code.

[0010] According to another aspect of the present disclosure, a task processing device is provided, including: a parsing module, used to parse the task text of the target task included in the task processing request in response to the task processing request to obtain intent information; a second generation module, used to generate initial code based on the intent information; a third update module, used to iteratively update the currently running code in a test environment based on the error status of the currently running code to obtain the target code, wherein in the first code update round, the currently running code is the initial code; and a second processing module, used to run the target code in a production environment to execute the target task.

[0011] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method as described above.

[0012] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method as described above.

[0013] According to another aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program implements the method described above when executed by a processor.

[0014] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0016] Figure 1 An exemplary system architecture to which the method and apparatus according to the embodiments of the present disclosure can be applied is schematically shown.

[0017] Figure 2 The flowchart of the code updating method based on the large model according to the embodiment of the present disclosure is schematically shown.

[0018] Figure 3 The following is a schematic diagram schematically showing a code update process according to an embodiment of the present disclosure.

[0019] Figure 4 The flowchart of a code updating method based on a large model according to another embodiment of the present disclosure is schematically shown.

[0020] Figure 5 The flowchart of the code generation method according to the embodiment of the present disclosure is schematically shown.

[0021] Figure 6 The flowchart of the task processing method according to the embodiment of the present disclosure is schematically shown.

[0022] Fig. 7A The schematic diagram shows an architecture diagram of a code interpreter according to an embodiment of the present disclosure.

[0023] Figure 7BThe schematic diagram shows an architecture diagram of a code interpreter according to another embodiment of the present disclosure.

[0024] Figure 8 A block diagram of a code updating device based on a large model according to an embodiment of the present disclosure is schematically shown.

[0025] Fig. 9 The block diagram of a code generating device according to an embodiment of the present disclosure is schematically shown.

[0026] Fig.10 The block diagram of a task processing device according to an embodiment of the present disclosure is schematically shown.

[0027] Fig.11 A schematic block diagram of an example electronic device that can be used to implement embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0028] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0029] Code interpreters can be tools that assist large language models in code generation. Code interpreters are mainly designed to solve the problem that non-professional programmers find it difficult to directly perform programming and data processing. It translates natural language requirements into executable code, allowing users without a deep programming background to perform complex programming tasks. Code interpreters can effectively lower the threshold for programming, allowing more users to easily perform operations such as data processing, code editing, and image conversion, thereby improving work efficiency and creativity. Code interpreters have been widely used in scenarios such as data analysis and visualization, automation and scripting, image and video processing, website and application development, scientific computing and simulation, technical support and troubleshooting.

[0030] However, current code interpreters have certain defects that affect the quality and efficiency of code generation. For example, there is a lack of effective code error correction mechanism in the handling of code execution errors, which limits the improvement of development efficiency. For another example, when faced with complex tasks, such as complex merged header quantity query and analysis tasks, the code instructions generated by the code interpreter are uneven and cannot meet high-standard application requirements.

[0031] In view of this, an embodiment of the present disclosure provides a code updating method, a code generating method, a task processing method and a code interpreter based on a large model. The code updating method based on a large model includes: receiving operation feedback information from a test environment, the operation feedback information is used to indicate the operation result of the code in the test environment, and the code is generated based on the user's intention using a large language model; in response to the operation feedback information indicating that the code runs incorrectly, based on the error state of the code, obtaining session information; and updating the code using the session information to obtain updated code.

[0032] Figure 1 An exemplary system architecture to which the method and apparatus according to the embodiments of the present disclosure can be applied is schematically shown.

[0033] It should be noted that Figure 1 The examples shown are only examples of system architectures to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but do not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios. For example, in another embodiment, the exemplary system architecture to which the methods and devices of the embodiments of the present disclosure can be applied may include a terminal device, but the terminal device may implement the methods and devices provided by the embodiments of the present disclosure without interacting with the server.

[0034] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.

[0035] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as knowledge reading applications, web browser applications, search applications, instant messaging tools, email clients and / or social platform software, etc. (only as examples).

[0036] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0037] The server 105 may be a server that provides various services, such as a background management server (only an example) that provides support for the content browsed by the user using the terminal devices 101, 102, and 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to the user request) to the terminal device.

[0038] It should be noted that the method provided in the embodiment of the present disclosure can generally be executed by the terminal device 101, 102, or 103. Accordingly, the apparatus provided in the embodiment of the present disclosure can also be set in the terminal device 101, 102, or 103.

[0039] Alternatively, the method provided in the embodiment of the present disclosure may also be generally performed by the server 105. Accordingly, the apparatus provided in the embodiment of the present disclosure may generally be arranged in the server 105. The method provided in the embodiment of the present disclosure may also be performed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the apparatus provided in the embodiment of the present disclosure may also be arranged in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.

[0040] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0041] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision, disclosure and application of user personal information involved comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.

[0042] In the technical solution of the present disclosure, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.

[0043] Figure 2 The flowchart of the code updating method based on the large model according to the embodiment of the present disclosure is schematically shown.

[0044] like Figure 2 As shown, the method includes operations S210 to S230.

[0045] In operation S210, operation feedback information is received from a test environment.

[0046] In operation S220, in response to the running feedback information indicating that the code runs in error, session information is obtained based on the error state of the code.

[0047] In operation S230, the code is updated using the session information to obtain an updated code.

[0048] The test environment may be an environment for developing and testing the code. The selection and configuration of the test environment may be related to the requirements of the code. For example, the test environment may be loaded with an operating system suitable for running the code, and the test environment may be configured with environment components required for running the code under the operating system. The test environment may be provided by a separate electronic device for testing, or the test environment may be provided by a virtual machine, which is not limited here.

[0049] The code running in the test environment may refer to the code generated based on the user's intention using the large language model. The user's intention may include the operating system when the code is running, the type of programming language of the code to be generated, the function that the code needs to implement, the input interface information of the code, the output interface information of the code, etc. The various types of information included in the user's intention can be written into a prompt word template to obtain a prompt word text, and the prompt word text is input into the large language model to obtain the code output by the large language model. Optionally, the code running in the test environment may also be the code compiled by the developer based on his needs, which is not limited here.

[0050] The operation feedback information can be used to indicate the operation result of the code in the test environment, for example, indicating that the code runs normally in the test environment, indicating that the code runs incorrectly in the test environment, etc. Optionally, the operation feedback information can also include other information used to characterize the code operation status, such as error codes, etc., which are not limited here.

[0051] The error status of the code can be used to indicate the complexity of the problem faced by the code, and the method for determining the complexity is not limited here. For example, the complexity of the problem faced by the code can be determined based on the number of error messages contained in the running feedback information. The more error messages there are, the more complex the problem faced by the code. For another example, the complexity of the problem faced by the code can be determined based on the number of times the code is updated. Each updated code can be put into the test environment for testing again. The process from the code running in the test environment and an error to updating the code using the generated session information to obtain the updated code can be regarded as an update process for the code. The more times the code is updated, the more difficult it is for the large language model to solve the problem faced by the code, that is, the problem faced by the code is more complex than the large language model.

[0052] The large language model can be subordinate to a dialogue system, and the session information can be represented as text information directly input into the dialogue system. In the dialogue system, the session information can be concatenated with the required context information to obtain the text that should actually be input into the large language model. Optionally, the session information can be generated based on the error state of the code, simulating the way of manual questioning.

[0053] The large language model can be used to update the code based on the session information to obtain updated code. The large language model can refer to a large model configured with a code generation plug-in or a code generation tool, and the selection and configuration of the code generation plug-in or the code generation tool are not limited here.

[0054] According to the embodiments of the present disclosure, the code generated by using the large language model can be tested in a test environment, and when it is confirmed that the code is running with an error, session information is constructed based on different error states of the code, and the code is updated based on the session information using the large language model. When the code is in different error states, session information of different text sizes can be constructed, thereby taking into account both the efficiency and accuracy of code generation and effectively improving the practicality of code generation.

[0055] Reference below Figure 3~Figure 4 , combined with specific embodiments Figure 2 The method shown is further explained.

[0056] Figure 3 The following is a schematic diagram schematically showing a code update process according to an embodiment of the present disclosure.

[0057] like Figure 3 As shown, the code update process can be executed in an electronic device, and a virtual machine 301 can be configured in the electronic device, and the virtual machine 301 can be used to provide a test environment. Using a large language model 302, code 303 can be generated based on user intent. Afterwards, the code 303 can be updated iteratively until a target code 304 that can run normally is obtained.

[0058] In each code update round, the code 303 can be sent to the virtual machine 301. The virtual machine 301 can run the code 303 and output the running result of the code 303 as the running feedback information 305. The processor in the electronic device can parse the running feedback information 305. When it is determined that the running feedback information 305 indicates that the code runs normally, the processor can output the code 303 as the target code 304. The target code 304 can be represented as a code that can run normally and meets the user's intention. When the processor determines that the running feedback information 305 indicates that the code runs incorrectly, it can determine the error state 306 of the code 303. Based on the different states represented by the error state 306, different session information 307 can be generated. The session information 307 can be used as at least a part of the input text of the large language model 302, and input into the large language model 302 to obtain the updated code. The updated code can be sent to the virtual machine 301 as the code 303 in the next code update round for running test.

[0059] The error status of the code can be defined based on various parameters generated during the execution of the code update process, which is not limited here.

[0060] The method for defining the error state of the code is not limited here. For example, the error state of the code can be defined by a binary method, and the error state of the code can be divided into a first state and a second state. The first state can indicate that the problem faced by the code is a simple problem, and the second state can indicate that the problem faced by the code is a complex problem.

[0061] For example, a counter may be configured, and the counter may be used to measure the number of rounds of code updates, and the value of the counter is represented as the number of times the code has been updated. The error state of the code may be defined based on the number of times the code has been updated. For the code of the current code update round, when the number of times the code has been updated is less than or equal to a preset value, it may be determined that the error state of the code is represented as a first state. When the number of times the code has been updated is greater than the preset value, it is determined that the error state of the code is represented as a second state.

[0062] The preset value can be set according to the specific application scenario, for example, it can be set to 1, 2, etc., and is not limited here.

[0063] The counter can update its count value at the end of each code update round. For example, in response to updating the code using error reflection information, the count value of the counter can be adjusted based on the self-increment strategy, that is, the number of times the code has been updated. The counter can be implemented using a counting register, or the counter can be represented as a preset counting variable, which is not limited here. The self-increment strategy can be represented, for example, as incrementing the count value based on a set step size, and the set step size can be, for example, 1.

[0064] For another example, a debugging tool may be configured in the test environment, and the debugging tool may display various types of problems and the number of various types of problems generated during the running of the code. Accordingly, the running feedback information may include information related to the various types of problems and the number of various types of problems. The error state of the code may be defined based on the problem type information and problem quantity information contained in the running feedback information. When the problem type information included in the running feedback information indicates that there are no complex problems, and the problem quantity information indicates that the number of problems is less than a preset threshold, it can be determined that the error state of the code is represented as the first state. When the problem type information included in the running feedback information indicates that there are complex problems, and / or the problem quantity information indicates that the number of problems is greater than or equal to the preset threshold, it can be determined that the error state of the code is represented as the second state. The preset threshold can be set according to the specific application scenario and is not limited here.

[0065] For simpler problems, such as variable type definition errors, method or class call errors, etc., the large language model can generally generate code that can run well through a limited number of iterations. For more complex problems, such as class or method algorithm logic errors, the large language model generally requires more information and more iterations to solve the error. Optionally, for different error states of the code, session information of different text lengths can be created to adaptively use text of different sizes to correct the code based on problems of different complexities, thereby taking into account both the efficiency and accuracy of code generation.

[0066] According to an embodiment of the present disclosure, when the error state of the code is represented as the first state, obtaining session information based on the error state of the code may include the following operations:

[0067] Based on the error code included in the operation feedback information, current error information is determined; and based on the current error information and the tool calling information, session information is obtained.

[0068] The debugging tool configured in the test environment can translate the problems in the code running process into error codes. Each error code can be used to indicate a type of problem and the location of the problem in the code. For example, the error code can be expressed as: "Code: 001; Location: Line B in File A".

[0069] The electronic device may be configured with a relationship table, which may be used to record the relationship between the code in the error code and the error information template. The error information template may be a template used to describe a type of problem. For example, if the problem represented by the code 001 is a variable call error, the error information template corresponding to the code may be represented as "there is a variable call error problem in line X of file X". Based on the code in the error code, the corresponding error information template may be determined, and then the position information in the error code may be filled into the error information template to obtain the current error information.

[0070] The tool call information may include declaration text related to a specific tool. Using the declaration text, the large language model can implement the corresponding function by calling the specific tool. For example, the specific tool may include a code generation tool, a user intent analysis tool, etc. After obtaining the tool call information, the large language model can load the user intent analysis tool and the code generation tool respectively, use the user intent analysis tool to parse the text information input by the user, and reorganize the input prompt text of the model. The output features of the large language model for the input prompt text can be processed into a string of executable code through the code generation tool. By adding tool call information to the session information, the accuracy of code generation can be increased.

[0071] The current error information and tool call information can be filled into a template respectively to obtain session information.

[0072] According to an embodiment of the present disclosure, when the error state of the code is represented as the second state, obtaining session information based on the error state of the code may include the following operations:

[0073] Based on the error code included in the running feedback information, the current error information is determined, and the current error information represents the error information of the current code update round; and based on the current error information, the historical error information of the code, the historical session information of the code and the meta information of the code, the session information is obtained.

[0074] According to an embodiment of the present disclosure, historical error information may include error information of multiple historical code update rounds, historical session information may include session information of multiple historical code update rounds, and meta information includes at least one of code generation task information, model information and tool call information.

[0075] The code generation task information can be obtained based on the user's intention, that is, the code generation task information can include the operating system when the code is running, the type of programming language of the code to be generated, the functions that the code needs to implement, the input interface information of the code, the output interface information of the code, etc.

[0076] The model information may represent relevant information of the large language model used for code generation, including the version number of the large language model, information of plug-ins or tools that need to be loaded, and the like.

[0077] Optionally, when the meta information includes the tool calling information, when recording the session information of the historical update round, the tool calling information included in the session information may be deleted to reduce the overall text length of the session information.

[0078] According to an embodiment of the present disclosure, by adding the above meta information to the session information, the code generation effect of the current round can be effectively improved.

[0079] Optionally, among the multiple historical error messages, there may be error messages of lower importance, which cannot provide help for solving the problems faced by the code in the current code update round. The multiple historical error messages can be selectively screened to obtain more effective error messages, and the session information is generated based on the more effective error messages.

[0080] According to an embodiment of the present disclosure, obtaining session information based on current error information, historical error information of the code, historical session information of the code, and meta information of the code may include the following operations:

[0081] Based on the information selection strategy, target error information is selected from the historical error information of the code; and the current error information, the historical error information, the historical session information and the meta information are spliced ​​to obtain the session information.

[0082] The information selection strategy may be expressed as a method of selecting more effective error information from multiple historical error messages. Optionally, the method may include the most relevant selection, the most recent selection, etc., which are not limited here.

[0083] The most relevant selection can be expressed as selecting the error information with the strongest correlation with the error information in the current code update round from multiple historical error information as the target error information. For example, the similarity between the error information in the current code update round and the multiple historical error information can be calculated by keyword matching and vector feature matching, and the historical error information corresponding to the greatest similarity is determined as the target error information. For another example, based on the error code obtained in the current code update round, the error information corresponding to the error code is selected from multiple historical error information as the target error information.

[0084] The most recent selection may be expressed as selecting the historical error information closest in time as the target error information, that is, the error information of the historical code update round closest to the current code update round may be selected as the target error information from the error information of multiple historical code update rounds.

[0085] According to the embodiments of the present disclosure, by screening historical error information, the interference of noise information can be reduced and the accuracy of generated code can be improved.

[0086] After obtaining the session information, the code can be updated using the session information with the help of a large language model.

[0087] According to an embodiment of the present disclosure, updating the code using session information to obtain the updated code may include the following operations:

[0088] Filling the session information and the code into the prompt template to obtain the prompt text; and inputting the prompt text into the large language model so that the large language model uses the session information as the prompt information and generates new code based on the code to obtain the updated code.

[0089] For example, the prompt template may be expressed as: "Currently there is the following information: session information: message; code: code. Please correct the code according to the provided session information." The message field in the prompt template may be replaced with the session information, and the code field in the prompt template may be replaced with the code to obtain the prompt text.

[0090] Figure 4 The flowchart of a code updating method based on a large model according to another embodiment of the present disclosure is schematically shown.

[0091] like Figure 4 As shown, the method includes operations S401 to S410.

[0092] In operation S401 , code is run in a test environment.

[0093] In operation S402, it is determined whether the code is running normally. If it is determined that the code is running normally, operation S403 is performed. If it is determined that the code is running incorrectly, operation S404 is performed.

[0094] In operation S403, the code is determined to be a target code that meets the user's intention.

[0095] In operation S404, current error information is obtained from feedback information of the test environment.

[0096] In operation S405, it is determined whether the number of times the code has been updated is greater than a preset value. If it is determined that the number of times the code has been updated is greater than the preset value, operation S406 is performed. If it is determined that the number of times the code has been updated is less than or equal to the preset value, operation S408 is performed.

[0097] In operation S406, target error information is determined from the historical error information of each of the plurality of historical code update rounds.

[0098] In operation S407, the current error information, the target error information, the historical session information and the meta information are concatenated to obtain the session information. After operation S407 is completed, operation S409 may be performed.

[0099] In operation S408, the current error information is concatenated with the tool calling information to obtain session information.

[0100] In operation S409, the code is updated using the session information to obtain an updated code.

[0101] In operation S410, the error information and session information of the current code update round are recorded, and the number of times the code has been updated is incremented. After completing operation S410, the updated code can be used as the code of the next code update round, and operation S401 is performed.

[0102] According to the embodiments of the present disclosure, the code generated by using the large language model can be tested in a test environment, and when it is confirmed that the code is running with an error, session information is constructed based on different error states of the code, and the code is updated based on the session information using the large language model. When the code is in different error states, session information of different text sizes can be constructed, thereby taking into account both the efficiency and accuracy of code generation and effectively improving the practicality of code generation.

[0103] Figure 5 The flowchart of the code generation method according to the embodiment of the present disclosure is schematically shown.

[0104] like Figure 5 As shown, the method includes operations S510~S520.

[0105] In operation S510 , in response to a code generation request, initial code is generated based on intention information included in the code generation request.

[0106] In operation S510, in a test environment, the currently running code is iteratively updated based on an error status of the currently running code to obtain a target code.

[0107] According to an embodiment of the present disclosure, the currently running code may include the initial code, that is, in the first code update round, the currently running code is the initial code.

[0108] According to an embodiment of the present disclosure, iterative updating of the currently running code can be achieved using the large model-based code updating method as described above, which will not be described in detail here.

[0109] Figure 6 The flowchart of the task processing method according to the embodiment of the present disclosure is schematically shown.

[0110] like Figure 6 As shown, the method includes operations S610 to S640.

[0111] In operation S610 , in response to a task processing request, a task text of a target task included in the task processing request is parsed to obtain intent information.

[0112] In operation S620, an initial code is generated based on the intention information.

[0113] In operation S630, in a test environment, the currently running code is iteratively updated based on an error status of the currently running code to obtain a target code.

[0114] In operation S640, the target code is run in the production environment to perform the target task.

[0115] According to an embodiment of the present disclosure, the currently running code may include the initial code, that is, in the first code update round, the currently running code is the initial code.

[0116] According to an embodiment of the present disclosure, iterative updating of the currently running code can be achieved using the large model-based code updating method as described above, which will not be described in detail here.

[0117] The code updating method, code generating method and task processing method based on the large model described above can be implemented using a code interpreter. The following takes the implementation of the code updating method based on the large model using a code interpreter as an example to illustrate the architecture of the code interpreter.

[0118] Fig. 7A The schematic diagram shows an architecture diagram of a code interpreter according to an embodiment of the present disclosure.

[0119] like Fig. 7A As shown, the architecture of the code interpreter can be divided into three layers from top to bottom, wherein the first layer can be a code sandbox 710 , the second layer can be an error reflection module 720 , and the third layer can be a large language model 730 .

[0120] According to an embodiment of the present disclosure, the code sandbox 710 may be configured to provide a test environment. The code sandbox 710 may be configured to receive code, run the code in the test environment, and generate code operation feedback information. The code running in the code sandbox 710 may be generated by the large language model 730.

[0121] According to an embodiment of the present disclosure, the error reflection module 720 may be configured to receive operation feedback information, and in response to the operation feedback information indicating that the code is running incorrectly, obtain session information based on the error state of the code, and send the session information to the large language model 730. The large language model 730 may be configured to generate updated code based on the session information and the code. The updated code may be sent to the code sandbox 710 again for testing.

[0122] Optionally, the code interpreter may further include other functional modules so that the code interpreter can adaptively adjust the scale of the generated session information.

[0123] Figure 7B The schematic diagram shows an architecture diagram of a code interpreter according to another embodiment of the present disclosure.

[0124] like Figure 7B As shown, the first layer of the code interpreter may further include an error management module 740, and the second layer may further include a memory management module 750.

[0125] According to an embodiment of the present disclosure, the error management module 740 may be configured to record a plurality of error codes and error information corresponding to the error codes.

[0126] According to an embodiment of the present disclosure, the error reflection module 720 may be configured to, when the error state of the code is indicated as a first state, obtain the current error information corresponding to the error code included in the operation feedback information through the error management module 740, and obtain the session information based on the current error information and the tool call information. The first state may indicate that the number of times the code has been updated is less than or equal to a preset value.

[0127] According to an embodiment of the present disclosure, the memory management module 750 may be configured to record the meta information of the code, and record the error information and session information in the historical code update rounds, to obtain the historical error information and the historical session information.

[0128] According to an embodiment of the present disclosure, the error reflection module 720 may be configured to, when the error state of the code is indicated as the second state, obtain the current error information corresponding to the error code included in the operation feedback information through the error management module 740, obtain the meta information, the historical error information and the historical session information through the memory management module 750, and obtain the session information based on the current error information, the meta information, the historical error information and the historical session information. The second state indicates that the number of times the code has been updated is greater than a preset value.

[0129] According to the embodiments of the present disclosure, by utilizing the code interpreter, the efficiency of task processing can be effectively improved when executing tasks such as code generation and code correction.

[0130] Figure 8 A block diagram of a code updating device based on a large model according to an embodiment of the present disclosure is schematically shown.

[0131] like Figure 8 As shown, the large model-based code updating device 800 includes a receiving module 810 , a first processing module 820 and a first updating module 830 .

[0132] The receiving module 810 is used to receive operation feedback information from the test environment. The operation feedback information is used to indicate the operation result of the code in the test environment. The code is generated based on the user's intention using a large language model.

[0133] The first processing module 820 is configured to obtain session information based on the error state of the code in response to the running feedback information indicating that the code runs incorrectly.

[0134] The first updating module 830 is used to update the code using the session information to obtain the updated code.

[0135] According to an embodiment of the present disclosure, the error status of the code is determined based on the number of times the code has been updated.

[0136] According to an embodiment of the present disclosure, the large model-based code updating apparatus 800 further includes a first determining module and a second determining module.

[0137] The first determining module is used to determine that the error state of the code is represented as a first state when the number of times the code has been updated is less than or equal to a preset value.

[0138] The second determining module is used to determine that the error state of the code is represented as a second state when the number of times the code has been updated is greater than a preset value.

[0139] According to an embodiment of the present disclosure, the first processing module 820 includes a first processing submodule and a second processing submodule.

[0140] The first processing submodule is used to determine current error information based on an error code included in the operation feedback information when the error state of the code is represented as a first state.

[0141] The second processing submodule is used to obtain session information based on the current error information and tool calling information.

[0142] According to an embodiment of the present disclosure, the first processing module 820 includes a third processing submodule and a fourth processing submodule.

[0143] The third processing submodule is used to determine current error information based on the error code included in the operation feedback information when the error state of the code is represented as the second state, where the current error information represents error information of the current code update round.

[0144] The fourth processing submodule is used to obtain session information based on current error information, historical error information of the code, historical session information of the code and meta information of the code, wherein the historical error information includes error information of multiple historical code update rounds, the historical session information includes session information of multiple historical code update rounds, and the meta information includes at least one of code generation task information, model information and tool call information.

[0145] According to an embodiment of the present disclosure, the fourth processing submodule includes a first processing unit and a second processing unit.

[0146] The first processing unit is used to select target error information from historical error information of the code based on an information selection strategy.

[0147] The second processing unit is used to splice the current error information, the target error information, the historical session information and the meta information to obtain the session information.

[0148] According to an embodiment of the present disclosure, the first processing unit includes a first processing sub-unit and a second processing sub-unit.

[0149] The first processing sub-unit is used to select, from the respective error information of a plurality of historical code update rounds, the error information of the historical code update round closest to the current code update round as the target error information.

[0150] The second processing subunit is used to select error information corresponding to the error code from the respective error information of multiple historical code update rounds as target error information.

[0151] According to an embodiment of the present disclosure, the large model-based code updating apparatus 800 further includes an adjustment module.

[0152] The adjustment module is used for adjusting the number of times the code has been updated based on a self-increment strategy in response to updating the code using the error reflection information.

[0153] According to an embodiment of the present disclosure, the first update module 830 includes a first update submodule and a second update submodule.

[0154] The first updating submodule is used to fill the session information and the code into the prompt template to obtain the prompt text.

[0155] The second updating submodule is used to input the prompt text into the large language model, so that the large language model uses the session information as prompt information, generates new code based on the code, and obtains updated code.

[0156] According to an embodiment of the present disclosure, the large model-based code updating apparatus 800 further includes a third determining module.

[0157] The third determination module is used to determine that the code is a target code that meets the user's intention in response to the running feedback information indicating that the code runs normally.

[0158] Fig. 9 The block diagram of a code generating device according to an embodiment of the present disclosure is schematically shown.

[0159] like Fig. 9 As shown, the code generating apparatus 900 includes a first generating module 910 and a second updating module 920 .

[0160] The first generating module 910 is used to generate initial code in response to a code generation request based on the intention information included in the code generation request.

[0161] The second update module 920 is used to iteratively update the currently running code based on the error status of the currently running code in the test environment to obtain the target code, wherein in the first code update round, the currently running code is the initial code.

[0162] According to an embodiment of the present disclosure, iterative updating of the currently running code can be achieved using the large model-based code updating method as described above, which will not be described in detail here.

[0163] Fig.10 The block diagram of a task processing device according to an embodiment of the present disclosure is schematically shown.

[0164] like Fig.10 As shown, the task processing device 1000 may include a parsing module 1010 , a second generating module 1020 , a third updating module 1030 and a second processing module 1040 .

[0165] The parsing module 1010 is used to respond to the task processing request, parse the task text of the target task included in the task processing request, and obtain the intention information.

[0166] The second generating module 1020 is used to generate an initial code based on the intention information.

[0167] The third update module 1030 is used to iteratively update the currently running code based on the error status of the currently running code in the test environment to obtain the target code, wherein in the first code update round, the currently running code is the initial code.

[0168] The second processing module 1040 is used to run the target code in the production environment to execute the target task.

[0169] According to an embodiment of the present disclosure, iterative updating of the currently running code can be achieved using the large model-based code updating method as described above, which will not be described in detail here.

[0170] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0171] According to an embodiment of the present disclosure, an electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method as described above.

[0172] According to an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method as described above.

[0173] According to an embodiment of the present disclosure, a computer program product includes a computer program, and when the computer program is executed by a processor, the computer program implements the method as described above.

[0174] Fig.11 A schematic block diagram of an example electronic device that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0175] like Fig.11 As shown, the electronic device 1100 includes a computing unit 1101, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1102 or a computer program loaded from a storage unit 1108 to a random access memory (RAM) 1103. In the RAM 1103, various programs and data required for the operation of the device 1100 can also be stored. The computing unit 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.

[0176] A number of components in the device 1100 are connected to an input / output (I / O) interface 1105, including: an input unit 1106, such as a keyboard, a mouse, etc.; an output unit 1107, such as various types of displays, speakers, etc.; a storage unit 1108, such as a disk, an optical disk, etc.; and a communication unit 1109, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1109 allows the device 1100 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0177] The computing unit 1101 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1101 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1101 performs the various methods and processes described above, such as code update methods, code generation methods, and task processing methods. For example, in some embodiments, the code update method, code generation method, and task processing method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 1108. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1100 via the ROM 1102 and / or the communication unit 1109. When the computer program is loaded into the RAM 1103 and executed by the computing unit 1101, one or more steps of the code update method, code generation method, and task processing method described above may be performed. Alternatively, in other embodiments, the computing unit 1101 may be configured to execute the code updating method, the code generating method, and the task processing method in any other appropriate manner (eg, by means of firmware).

[0178] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0179] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0180] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0181] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0182] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0183] A computer system may include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises through computer programs running on respective computers and having a client-server relationship to each other. The server may be a cloud server, a server in a distributed system, or a server combined with a blockchain.

[0184] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0185] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A code update method based on a large model, include: receiving operation feedback information from a test environment, wherein the operation feedback information is used to indicate an operation result of the code in the test environment, wherein the code is generated based on user intent using a large language model; In response to the running feedback information indicating that the code runs in error, obtaining session information based on the error state of the code; as well as The code is updated using the session information to obtain an updated code.

2. The method according to claim 1, in, The error status of the code is determined based on the number of times the code has been updated; The method further comprises: In a case where the number of times the code has been updated is less than or equal to a preset value, determining that the error state of the code is represented as a first state; and In a case where the number of times the code has been updated is greater than the preset value, determining that the error state of the code is represented as a second state.

3. The method according to claim 2, in, The obtaining session information based on the error state of the code includes: In a case where the error state of the code is represented as the first state, determining current error information based on the error code included in the operation feedback information; and The session information is obtained based on the current error information and the tool calling information.

4. The method according to claim 2, in, The obtaining session information based on the error state of the code includes: In a case where the error state of the code is represented as the second state, determining current error information based on the error code included in the operation feedback information, wherein the current error information represents error information of a current code update round; and Obtaining the session information based on the current error information, the historical error information of the code, the historical session information of the code and the meta information of the code; The historical error information includes the error information of each of multiple historical code update rounds, the historical session information includes the session information of each of the multiple historical code update rounds, and the meta information includes at least one of code generation task information, model information and tool call information.

5. The method according to claim 4, in, The obtaining the session information based on the current error information, the historical error information of the code, the historical session information of the code and the meta information of the code includes: Based on the information selection strategy, select target error information from the historical error information of the code; and The current error information, the target error information, the historical session information and the meta information are concatenated to obtain the session information.

6. The method according to claim 5, in, The information selection strategy is based on which target error information is selected from historical error information of the code, including: Selecting, from the respective error information of the plurality of historical code update rounds, the error information of the historical code update round closest to the current code update round as the target error information; or From the error information of each of the plurality of historical code update rounds, error information corresponding to the error code is selected as the target error information.

7. The method according to claim 2, further comprising: include: In response to updating the code using the error reflection information, the number of times the code has been updated is adjusted based on a self-increment strategy.

8. The method according to claim 1, in, The updating of the code by using the session information to obtain an updated code includes: Filling the session information and the code into a prompt template to obtain a prompt text; and The prompt text is input into a large language model so that the large language model uses the session information as prompt information and generates a new code based on the code to obtain the updated code.

9. The method according to claim 1, further comprising: include: In response to the running feedback information indicating that the code runs normally, the code is determined to be a target code that meets the user's intention.

10. A code generation method, include: In response to the code generation request, generating initial code based on the intent information included in the code generation request; as well as In a test environment, based on an error status of a currently running code, the currently running code is iteratively updated to obtain a target code, wherein in a first code update round, the currently running code is the initial code.

11. A task processing method, include: In response to the task processing request, parsing the task text of the target task included in the task processing request to obtain the intention information; Based on the intention information, generating an initial code; In a test environment, based on an error state of a currently running code, iteratively updating the currently running code to obtain a target code, wherein in a first code update round, the currently running code is the initial code; as well as The target code is run in a production environment to perform the target task.

12. A code interpreter, include: A code sandbox is configured to provide a test environment, wherein the code sandbox is configured to receive code, run the code in the test environment, and generate running feedback information of the code, wherein the code is generated by a large language model; The error reflection module is configured to receive the operation feedback information, obtain session information based on the error status of the code in response to the operation feedback information indicating that the code has an error, and send the session information to the large language model, wherein the large language model is configured to generate updated code based on the session information and the code.

13. The code interpreter according to claim 1, further comprising: include: an error management module, configured to record a plurality of error codes and error information corresponding to the error codes; The error reflection module is configured to, when the error state of the code is represented as the first state, obtain, through the error management module, current error information corresponding to the error code included in the operation feedback information, and obtain the session information based on the current error information and the tool call information; The first state indicates that the number of times the code has been updated is less than or equal to a preset value.

14. The code interpreter according to claim 1, further comprising: include: A memory management module is configured to record the meta information of the code, and record the error information and session information in the historical code update rounds, and obtain the historical error information and the historical session information; The error reflection module is configured to, when the error state of the code is indicated as the second state, obtain, through the error management module, current error information corresponding to the error code included in the operation feedback information, obtain, through the memory management module, the meta information, the historical error information and the historical session information, and obtain the session information based on the current error information, the meta information, the historical error information and the historical session information; The second state indicates that the code has been updated a number of times greater than a preset value.

15. A code updating device based on a large model, include: A receiving module, used to receive operation feedback information from a test environment, wherein the operation feedback information is used to indicate the operation result of the code in the test environment, wherein the code is generated based on user intent using a large language model; A first processing module is configured to obtain session information based on an error state of the code in response to the operation feedback information indicating that the code is running incorrectly; as well as The first updating module is used to update the code by using the session information to obtain an updated code.

16. A code generating device, include: A first generating module, configured to generate an initial code in response to a code generation request and based on the intention information included in the code generation request; as well as The second update module is used to iteratively update the currently running code based on the error status of the currently running code in a test environment to obtain the target code, wherein in the first code update round, the currently running code is the initial code.

17. A task processing device, include: A parsing module, configured to, in response to a task processing request, parse a task text of a target task included in the task processing request to obtain intent information; A second generating module, used for generating an initial code based on the intention information; A third updating module is used to iteratively update the currently running code based on the error status of the currently running code in the test environment to obtain a target code, wherein in a first code update round, the currently running code is the initial code; as well as The second processing module is used to run the target code in a production environment to execute the target task.

18. An electronic device, include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 11.

19. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-11.

20. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 11.

Citation Information

Cited By

  • Code processing method and device based on large model, electronic equipment and storage medium

    CN119597264A

  • API (Application Program Interface) automatic feedback system, method and equipment based on large language model

    CN119597626A

  • Code repairing method and device, computer program product and electronic equipment

    CN120315746A

  • Question analysis text difference diagnosis method and system based on dependency graph and sandbox

    CN122884813A