Code editing method and apparatus, device, and storage medium

By identifying and constructing contextual information for code edit requests, the accuracy of generative models in processing code edit requests in large code repositories is improved. This solves the problem that generative models cannot effectively extract context, and enables more accurate code editing.

WO2025222808A1PCT designated stage Publication Date: 2025-10-30DOUYIN VISION CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/132498
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-04-25
Filing Date
2024-11-15
Publication Date
2025-10-30

AI Technical Summary

Technical Problem

Generative models are unable to effectively extract contextual information closely related to user questions when dealing with large code repositories, resulting in insufficient accuracy in processing code editing requests.

Method used

By determining the first set of context information associated with the code editing request, target information is constructed, a second set of context information is determined from the first set of context information based on the target information, and prompt information for the target model is constructed to process the code editing request.

Benefits of technology

It improves the accuracy of code editing request processing by collecting and sorting contextual information in the code repository to construct prompts for reasoning, helping generative models better understand the user's coding intent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024132498_30102025_PF_FP_ABST
    Figure CN2024132498_30102025_PF_FP_ABST
Patent Text Reader

Abstract

The embodiments of the present disclosure relate to a code editing method and apparatus, a device, and a storage medium. The method provided herein comprises: based on a received code editing request, determining a first group of context information associated with a code editing request; constructing target information corresponding to the code editing request, wherein the target information at least represents an editing scenario of the code editing request; based on the target information, determining a second group of context information from among the first group of context information; and constructing prompt information of a target model based on the second group of context information, so as to process the code editing request by using the target model. In this way, the embodiments of the present disclosure allow for information collected from a code repository to be sorted and concatenated according to user coding intent, ultimately constructing prompt information for reasoning, so as to process the code editing request of the user, thereby improving the accuracy of code editing request processing.
Need to check novelty before this filing date? Find Prior Art

Description

Methods, apparatus, devices and storage media for code editing

[0001] This application claims priority to Chinese Patent Application No. 202410509498.8, filed on April 25, 2024, entitled "Method, Apparatus, Device and Storage Medium for Code Editing", the entire contents of which are incorporated herein by reference. Technical Field

[0002] The exemplary embodiments disclosed herein relate generally to the field of computers, and in particular to methods, apparatus, devices and computer-readable storage media for code editing. Background Technology

[0003] With the development of computer technology, generative artificial intelligence has been applied to various aspects of people's lives. For example, some code development applications (such as integrated development platforms, IDEs) can utilize generative artificial intelligence to perform various types of code editing operations, thereby improving the efficiency of code editing. Summary of the Invention

[0004] In a first aspect of this disclosure, a method for code editing is provided. The method includes: determining a first set of context information associated with a received code editing request; constructing target information corresponding to the code editing request, the target information at least characterizing the editing scenario of the code editing request; determining a second set of context information from the first set of context information based on the target information; and constructing prompt information for a target model based on the second set of context information, so as to process the code editing request using the target model.

[0005] In a second aspect of this disclosure, an apparatus for code editing is provided. The apparatus includes: a first determining module configured to determine a first set of context information associated with a received code editing request; a first constructing module configured to construct target information corresponding to the code editing request, the target information at least characterizing the editing scenario of the code editing request; a second determining module configured to determine a second set of context information from the first set of context information based on the target information; and a second constructing module configured to construct prompt information for a target model based on the second set of context information, so as to process the code editing request using the target model.

[0006] 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.

[0007] 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.

[0008] 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 according to a first aspect of this disclosure.

[0009] 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

[0010] 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:

[0011] Figure 1 shows a schematic diagram of an example environment in which embodiments of the present disclosure may be implemented;

[0012] Figure 2 shows a flowchart of the process of editing example code according to some embodiments of the present disclosure;

[0013] Figure 3 shows a schematic structural block diagram of an example code editing apparatus according to some embodiments of the present disclosure; and

[0014] Figure 4 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] To optimize the performance of generative models when processing large code repositories, it is necessary to provide them with contextual information closely related to the user's question. However, due to the limited context window length of generative models, the entire code repository cannot be directly provided as context. How to extract code context more accurately and effectively remains a challenging problem.

[0021] Embodiments of this disclosure propose a code editing scheme. According to this scheme, a first set of context information associated with a received code editing request can be determined; target information corresponding to the code editing request can be constructed, the target information at least characterizing the editing scenario of the code editing request; a second set of context information can be determined from the first set of context information based on the target information; and prompt information for the target model can be constructed based on the second set of context information, so as to utilize the target model to process the code editing request.

[0022] In this way, embodiments of this disclosure can collect contextual information from the code repository, sort and concatenate it according to the user's coding intent, and finally construct prompt information for reasoning to process the user's code editing request, thereby improving the accuracy of code editing request processing.

[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 can run an application 120 that supports user interface interaction. Application 120 can be any suitable type of application for user interface interaction, examples of which may include, but are not limited to, code editing applications, applications with integrated IDEs, or other suitable applications such as browsers. User 140 can interact with application 120 via electronic device 110 and / or its attached devices.

[0027] In environment 100 of Figure 1, if application 120 is active, electronic device 110 can present interface 150 for support through application 120.

[0028] In some embodiments, electronic device 110 communicates with server 130 to provide services to application 120. Electronic device 110 can be 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 thereof, including accessories and peripherals of these devices or any combination thereof. In some embodiments, electronic device 110 can also support any type of user-facing interface (such as "wearable" circuitry).

[0029] Server 130 can be 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. Server 130 may include, for example, computing systems / servers such as mainframes, edge computing nodes, computing devices in a cloud environment, etc. Server 130 can provide backend services for applications 120 that support content presentation in electronic devices 110.

[0030] A communication connection can be established between server 130 and electronic device 110. This communication connection can be established via wired or wireless means. The communication connection may include, but is not limited to, Bluetooth, mobile network, Universal Serial Bus, and Wi-Fi connections; the embodiments of this disclosure are not limited in this respect. In the embodiments of this disclosure, server 130 and electronic device 110 can achieve signaling interaction through the communication connection between them.

[0031] 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.

[0032] Example process

[0033] Figure 2 shows a flowchart of an example code editing process 200 according to some embodiments of the present disclosure. Process 200 can be implemented at electronic device 110. Process 200 is described below with reference to Figure 1.

[0034] In box 210, electronic device 110 determines a first set of context information associated with the received code editing request.

[0035] In some embodiments, the code editing request received by the electronic device 110 may be natural language text input by the user. Such natural language text represents the user's intent, i.e., the user's desired action regarding files such as code in a code repository. Exemplarily, such actions may include, but are not limited to, code completion requests.

[0036] In other embodiments, the code editing request received by the electronic device 110 may also be a processing instruction from the user regarding a code snippet, such a processing instruction representing the user's processing intent. Exemplarily, such processing instructions may include, but are not limited to, instructions for interpreting, generating, editing, generating line-by-line comments, generating function comments, fixing code, and generating tests on code in a code repository.

[0037] In some embodiments, the electronic device 110 determines a code fragment associated with a code editing request from a code repository, and determines a first set of context information based on that code fragment. As an example, the electronic device 110 extracts a code fragment associated with the current code editing request from the code repository based on the user's click behavior in the code repository and text similarity to determine the first set of context information. Such text similarity could be, for example, the text similarity between the code fragment at the location where the user triggered the code editing request in the current code editing file and a code fragment in the code repository that has the user's click or editing behavior.

[0038] In some embodiments, the electronic device 110 acquires the current user's historical editing information within a preset time period (e.g., within 5 minutes) and determines a first set of context information based on this historical editing information. As an example, the electronic device 110 can collect the current user's historical editing information within a code repository and capture the current user's coding intent based on the current user's behavioral sequence information (e.g., the current user's clicks or edits on the code repository) to determine the first set of context information. The electronic device 110's capture of the coding intent corresponding to the code editing request can be determined based on a model.

[0039] In some embodiments, the electronic device 110 determines a set of symbols associated with the code editing request based on the editing location of the code editing request, and determines a first set of context information based on the definition information of the set of symbols. As an example, the electronic device 110 collects key symbols (e.g., hover symbol information) of the current user in the context of the code editing request based on the LSP protocol, and obtains the definition information of the key symbols in the code repository to determine the first set of context information.

[0040] Based on the above method, electronic device 110 can determine the first set of context information associated with the code editing request.

[0041] In box 220, electronic device 110 constructs target information corresponding to the code editing request, the target information at least characterizing the editing scenario of the code editing request.

[0042] In some embodiments, the electronic device 110 acquires a syntax tree (e.g., a tree sitter syntax tree) associated with a code development environment, which includes multiple nodes. Such nodes may include, but are not limited to, function names, function callers, and associated test functions. Based on this syntax tree, the electronic device 110 determines a set of target nodes associated with a code editing request, and constructs target information corresponding to the code editing request based on this set of target nodes.

[0043] In some embodiments, the electronic device 110 extracts target nodes and obtains user coding scenario information based on a tree sitter syntax tree structure, and generates a first set of tokens (e.g., related tokens) corresponding to the target information based on this information. As an example, when a code completion and editing request is triggered at a certain location in the current code file, the electronic device 110 will obtain a set of target nodes such as the current method call, the current if check variable, the function definition, and the class based on the syntax structure, thereby better reflecting the user's coding intent.

[0044] In some embodiments, the electronic device 110 may also extract the first set of tokens corresponding to the target information in the context adjacent to the location where the code file is triggered.

[0045] In box 230, electronic device 110 determines a second set of context information from a first set of context information based on target information.

[0046] In some embodiments, electronic device 110 determines a first set of tokens corresponding to target information and a second set of tokens corresponding to the first set of context information. As an example, electronic device 110 performs tree sitter parsing and normalization on the first set of context information to obtain the second set of tokens (e.g., a token sequence).

[0047] In some embodiments, the electronic device 110 determines the relevance between the first set of context information and the target information based on the first set of tokens and the second set of tokens, sorts the first set of context information based on the relevance (e.g., based on the BM25 sorting algorithm), and determines the second set of context information based on the sorted first set of context information, dynamically constructing the prompt information of the target model.

[0048] In box 240, electronic device 110 constructs a prompt message for the target model based on the second set of context information to utilize the target model to process the code editing request. For example, electronic device 110 can help the target model better understand the context of the code editing request by including the second set of context information in the constructed prompt message (also known as a prompt item).

[0049] In some embodiments, the electronic device 110 uses prompting information to perform supervised fine-tuning alignment on the target model. As an example, the electronic device 110 collects data containing contextual information to perform SFT alignment on the target model, making the target model more usable and further improving the effectiveness of code completion and other code editing requests.

[0050] In some embodiments, the target model receives the generated prompt information and processes it to obtain output information, which is then displayed on the user interface by the electronic device 110. For example, the electronic device 110 can provide corresponding code completion, code generation content, code modification content, code explanation content, etc., based on the output information of the target model, thereby completing the processing of the user's code editing request.

[0051] In this way, embodiments of this disclosure can collect contextual information from the code repository, sort and concatenate it according to the user's coding intent, and finally construct prompt information for reasoning to process the user's code editing request, thereby improving the accuracy of code editing request processing.

[0052] Example devices and equipment

[0053] Embodiments of this disclosure also provide corresponding apparatus for implementing the methods or processes described above. Figure 3 shows a schematic structural block diagram of an example code editing apparatus 300 according to certain embodiments of this disclosure. Apparatus 300 may be implemented as or included in electronic device 110. The various modules / components in apparatus 300 may be implemented by hardware, software, firmware, or any combination thereof.

[0054] As shown in Figure 3, the device 300 includes a first determining module 310, configured to determine a first set of context information associated with a received code editing request; a first constructing module 320, configured to construct target information corresponding to the code editing request, wherein the target information at least characterizes the editing scenario of the code editing request; a second determining module 330, configured to determine a second set of context information from the first set of context information based on the target information; and a second constructing module 340, configured to construct prompt information of the target model based on the second set of context information, so as to process the code editing request using the target model.

[0055] In some embodiments, the first determining module 310 is specifically configured to determine a code fragment associated with a code editing request from a code repository; and to determine a first set of context information based on the code fragment.

[0056] In some embodiments, the first determining module 310 is specifically configured to obtain the current user's historical editing information within a preset time period; and to determine a first set of context information based on the historical editing information.

[0057] In some embodiments, the first determining module 310 is specifically configured to determine a set of symbols associated with the code editing request based on the editing location of the code editing request; and to determine a first set of context information based on the definition information of the set of symbols.

[0058] In some embodiments, the first construction module 320 is specifically configured to obtain a syntax tree associated with a code development environment, the syntax tree including multiple nodes; determine a set of target nodes associated with a code editing request based on the syntax tree; and construct target information corresponding to the code editing request based on the set of target nodes.

[0059] In some embodiments, the second determining module 330 is specifically configured to determine a first set of tokens corresponding to the target information and a second set of tokens corresponding to the first set of context information; determine the relevance between the first set of context information and the target information based on the first set of tokens and the second set of tokens; and determine the second set of context information from the first set of context information based on the relevance.

[0060] In some embodiments, the second determining module 330 is specifically configured to sort the first set of context information based on relevance; and to determine the second set of context information based on the sorted first set of context information.

[0061] In some embodiments, the apparatus 300 further includes a processing module configured to perform supervised fine-tuning alignment of the target model using prompting information.

[0062] In some embodiments, a code editing request includes a code completion request.

[0063] The modules included in device 300 can be implemented in various ways, including software, hardware, firmware, or any combination thereof. In some embodiments, one or more units can 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 modules in device 300 can 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 can 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.

[0064] Figure 4 shows a block diagram of an electronic device 400 in which one or more embodiments of the present disclosure may be implemented. It should be understood that the electronic device 400 shown in Figure 4 is merely exemplary and should not constitute any limitation on the functionality and scope of the embodiments described herein. The electronic device 400 shown in Figure 4 can be used to implement the electronic device 110 of Figure 1.

[0065] As shown in Figure 4, electronic device 400 is in the form of a general-purpose electronic device. Components of electronic device 400 may include, but are not limited to, one or more processors or processing units 410, memory 420, storage device 430, one or more communication units 440, one or more input devices 450, and one or more output devices 460. Processing unit 410 may be a physical or virtual processor and is capable of performing various processes according to programs stored in memory 420. In a multiprocessor system, multiple processing units execute computer-executable instructions in parallel to improve the parallel processing capability of electronic device 400.

[0066] Electronic device 400 typically includes multiple computer storage media. Such media can be any accessible media that is accessible to electronic device 400, including but not limited to volatile and non-volatile media, removable and non-removable media. Memory 420 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 430 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 400.

[0067] Electronic device 400 may further include additional removable / non-removable, volatile / non-volatile storage media. Although not shown in FIG. 4, 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 420 may include computer program product 425 having one or more program modules configured to perform various methods or actions of various embodiments of the present disclosure.

[0068] Communication unit 440 enables communication with other electronic devices via a communication medium. Additionally, the functionality of components of electronic device 400 can be implemented using a single computing cluster or multiple computing machines capable of communicating via communication connections. Therefore, electronic device 400 can operate in a networked environment using logical connections to one or more other servers, network personal computers (PCs), or another network node.

[0069] Input device 450 can be one or more input devices, such as a mouse, keyboard, trackball, etc. Output device 460 can be one or more output devices, such as a monitor, speaker, printer, etc. Electronic device 400 can also communicate with one or more external devices (not shown) via communication unit 440 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 400, or with any device that enables electronic device 400 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).

[0070] 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.

[0071] 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.

[0072] 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.

[0073] 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.

[0074] 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.

[0075] Various implementations of this disclosure have been described above. The foregoing description is exemplary and not exhaustive, nor is it 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 code editing method, comprising: Based on the received code editing request, determine a first set of context information associated with the code editing request; Construct target information corresponding to the code editing request, wherein the target information at least characterizes the editing scenario of the code editing request; Based on the target information, a second set of context information is determined from the first set of context information; as well as Based on the second set of context information, prompt information for the target model is constructed to utilize the target model to process the code editing request.

2. The method of claim 1, wherein determining the first set of context information associated with the code editing request comprises: Identify the code snippet associated with the code editing request from the code repository; as well as Based on the code snippet, the first set of context information is determined.

3. The method of claim 1, wherein determining the first set of context information associated with the code editing request includes: Retrieve the current user's historical editing information within a preset time period; as well as Based on the historical editing information, the first set of context information is determined.

4. The method of claim 1, wherein determining the first set of context information associated with the code editing request comprises: Based on the editing location of the code editing request, determine a set of symbols associated with the code editing request; as well as Based on the definition information of the set of symbols, the first set of context information is determined.

5. The method according to claim 1, wherein constructing the target information corresponding to the code editing request includes: Obtain the syntax tree associated with the code development environment, the syntax tree including multiple nodes; Based on the syntax tree, a set of target nodes associated with the code editing request are determined; as well as Based on the set of target nodes, construct the target information corresponding to the code editing request.

6. The method according to claim 1, wherein determining the second set of context information from the first set of context information based on the target information comprises: Determine the first set of tokens corresponding to the target information and the second set of tokens corresponding to the first set of context information; Based on the first set of tokens and the second set of tokens, determine the relevance between the first set of context information and the target information; as well as Based on the relevance, the second set of context information is determined from the first set of context information.

7. The method of claim 6, wherein determining the second set of context information from the first set of context information based on the relevance comprises: Based on the relevance, the first group of context information is sorted; as well as The second set of context information is determined based on the sorted first set of context information.

8. The method according to claim 1, further comprising: Using the aforementioned prompts, supervised fine-tuning alignment is performed on the target model.

9. The method of claim 1, wherein the code editing request includes a code completion request.

10. A code editing device, comprising: The first determining module is configured to determine a first set of context information associated with the received code editing request based on the code editing request. The first construction module is configured to construct target information corresponding to the code editing request, wherein the target information at least characterizes the editing scenario of the code editing request; The second determining module is configured to determine a second set of context information from the first set of context information based on the target information; as well as The second building module is configured to build prompt information for the target model based on the second set of context information, so as to use the target model to process the code editing request.

11. 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 9.

12. 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 9.

13. 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 9.

Citation Information

Patent Citations

  • Code editing method and device, electronic equipment and medium

    CN113901290A

  • Code generation method and device based on syntax tree, electronic equipment and storage medium

    CN115016793A

  • Data processing method and device

    CN116306672A

  • Code file generation method and device, electronic equipment and storage medium

    CN117632101A

  • Code editing method and device, equipment and storage medium

    CN118349220A