Method and electronic device for providing code by using generative artificial intelligence model

The method and electronic device leverage generative AI to generate code by optimizing user inputs and context information, addressing inefficiencies in existing technologies and achieving reliable code generation.

WO2025121614A1PCT designated stage expired Publication Date: 2025-06-12SAMSUNG ELECTRONICS CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/KR2024/014494
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-12-04
Filing Date
2024-09-25
Publication Date
2025-06-12

AI Technical Summary

Technical Problem

Existing technologies face challenges in efficiently generating code using generative artificial intelligence models, particularly in handling user inputs and context information effectively.

Method used

A method and electronic device that utilize a generative artificial intelligence model to provide code by obtaining user inputs, generating prompts, and selecting context information based on priority and length thresholds, thereby optimizing code generation.

Benefits of technology

The solution enables efficient and effective code generation by prioritizing context information and managing prompt length, resulting in reliable and efficient responses from the generative AI model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure KR2024014494_12062025_PF_FP_ABST
    Figure KR2024014494_12062025_PF_FP_ABST
Patent Text Reader

Abstract

Provided are an electronic device for providing a code by using a generative artificial intelligence model, and a method implemented by the electronic device. The method comprises the steps of: acquiring a user input corresponding to a first document; acquiring first context information available for code generation on the basis of the user input; generating a first prompt for code generation on the basis of the first context information and the user input; selecting second context information from the first context information according to priority information on the basis of the length of the first prompt; generating a second prompt corresponding to the first prompt on the basis of the second context information and the user input; transmitting the first prompt or the second prompt to a server; and receiving, from the server, a recommendation code generated via a generative artificial intelligence model on the basis of the first prompt or the second prompt, and providing same.
Need to check novelty before this filing date? Find Prior Art

Description

Method and electronic device for providing code using a generative artificial intelligence model

[0001] The present disclosure relates to a method and an electronic device utilizing a generative artificial intelligence model. Specifically, the present disclosure relates to a method and an electronic device for providing code using a generative artificial intelligence model.

[0002] Generative artificial intelligence (Generative AI) is a technology that learns the structure and patterns of large-scale data and generates new synthetic data based on the input data. It produces human-level results in various tasks involving text, images, voice, video, and music. For example, a GLM is a technology capable of performing various natural language processing tasks. A GLM is a text-based AI model that generates response text to user inquiries. A GLM may include a Large Language Model (LLM).

[0003] Recently, generative artificial intelligence has been widely used in technologies such as search functions, chatbots, and code generation.

[0004] In one embodiment of the present disclosure, a method for providing a code using a generative artificial intelligence model is provided. The method may include obtaining user input corresponding to a first document. The method may include obtaining first context information usable for code generation based on the user input. The method may include generating a first prompt for code generation based on the first context information and the user input. The method may include selecting second context information from among the first context information according to priority information based on the length of the first prompt. The method may include generating a second prompt corresponding to the first prompt based on the second context information and the user input. The method may include transmitting the first prompt or the second prompt to a server. The method may include receiving and providing a recommendation code generated by the generative artificial intelligence model based on the first prompt or the second prompt from the server.

[0005] In one embodiment of the present disclosure, an electronic device is provided that provides code using a generative artificial intelligence model. The electronic device may include at least one processor including a processing circuit, and a memory including one or more storage media storing at least one instruction. The at least one instruction may be individually or collectively executed by the at least one processor to enable the electronic device to obtain user input corresponding to a first document. The at least one instruction may be individually or collectively executed by the at least one processor to enable the electronic device to obtain first context information usable for code generation based on the user input. The at least one instruction may be individually or collectively executed by the at least one processor to enable the electronic device to generate a first prompt for code generation based on the first context information and the user input. The at least one instruction may be individually or collectively executed by the at least one processor to enable the electronic device to select second context information from among the first context information based on a length threshold of the first prompt and priority information. At least one of the instructions may be individually or collectively executed by at least one processor to cause the electronic device to generate a second prompt corresponding to the first prompt based on second context information and user input. At least one of the instructions may be individually or collectively executed by at least one processor to cause the electronic device to transmit the first prompt or the second prompt to a server. At least one of the instructions may be individually or collectively executed by at least one processor to cause the electronic device to receive and provide a recommendation code generated by a generative artificial intelligence model based on the first prompt or the second prompt from the server.

[0006] In one embodiment of the present disclosure, a computer-readable recording medium having recorded thereon a computer program for executing the above-described method on a computer is provided.

[0007] FIG. 1 is a diagram schematically illustrating a system for providing code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0008] FIG. 2 is a flowchart illustrating a method for providing code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0009] FIG. 3A is a diagram illustrating a prompt for a generative artificial intelligence model according to one embodiment of the present disclosure.

[0010] FIG. 3b is a diagram illustrating a prompt for a generative artificial intelligence model according to one embodiment of the present disclosure.

[0011] FIG. 4 is a diagram illustrating a user interface for providing code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0012] FIG. 5 is a block diagram of a system that provides code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0013] FIG. 6 is a diagram for explaining a process of extracting code information according to one embodiment of the present disclosure.

[0014] FIG. 7 is a diagram illustrating a process for searching code information according to one embodiment of the present disclosure.

[0015] FIG. 8 is a diagram illustrating a process of combining context information according to one embodiment of the present disclosure.

[0016] FIG. 9 is a diagram illustrating a process for summarizing a prompt according to one embodiment of the present disclosure.

[0017] FIG. 10 is a diagram illustrating a process of summarizing a prompt using a generative language model according to one embodiment of the present disclosure.

[0018] FIG. 11 is a diagram illustrating a prompt provided to a generative artificial intelligence model according to one embodiment of the present disclosure.

[0019] FIG. 12 is a flowchart illustrating a step of obtaining user input according to one embodiment of the present disclosure.

[0020] FIG. 13 is a diagram illustrating a prompt provided to a generative artificial intelligence model according to one embodiment of the present disclosure.

[0021] FIG. 14 is a flowchart illustrating steps for obtaining user input according to one embodiment of the present disclosure.

[0022] FIG. 15 is a flowchart illustrating a step of obtaining context information according to one embodiment of the present disclosure.

[0023] FIG. 16 is a flowchart illustrating steps for generating a summarized prompt according to one embodiment of the present disclosure.

[0024] FIG. 17a is a diagram illustrating a system for providing code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0025] FIG. 17b is a diagram illustrating a system that provides code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0026] FIG. 17c is a diagram illustrating a system for providing code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0027] FIG. 18 is a block diagram illustrating a configuration of an electronic device according to one embodiment of the present disclosure.

[0028] FIG. 19 is a block diagram illustrating the configuration of a server according to one embodiment of the present disclosure.

[0029] Embodiments of the present disclosure are described in detail herein with reference to the accompanying drawings, so that those skilled in the art can easily implement the present disclosure. However, the present disclosure may be embodied in various other forms and should not be construed as limited to the embodiments set forth herein. Embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings.

[0030] In this disclosure, the expression “at least one of a, b or c” may refer to “a”, “b”, “c”, “a and b”, “a and c”, “b and c”, “all of a, b and c”, or variations thereof.

[0031] The terms used in this disclosure are selected from widely used, common terms, taking into account the functions of the disclosure. However, these terms may vary depending on the intentions of those skilled in the art, precedents, the emergence of new technologies, etc. Furthermore, in certain cases, terms may be arbitrarily selected by the applicant, and in such cases, their meanings can be understood through the relevant description. Therefore, the terms used in this disclosure should not be defined simply as names of terms, but rather based on the meanings of the terms and the overall content of the disclosure.

[0032] In this disclosure, singular expressions may include plural expressions unless the context clearly dictates otherwise. Terms containing ordinal numbers, such as "first" or "second," used in this disclosure may be used to describe various components, but the components should not be limited by these terms. These terms are used solely to distinguish one component from another.

[0033] When a part of this disclosure is said to "include" a component, this does not exclude other components, but rather may include other components, unless otherwise specifically stated. In this disclosure, terms such as "part" and "module" may refer to a unit that processes at least one function or operation.

[0034] The expression "configured to" as used herein can be used interchangeably with, for example, "suitable for", "having the capacity to", "designed to", "adapted to", "made to", or "capable of", depending on the context. The term "configured to" does not necessarily mean something that is "specifically designed to" in terms of hardware. Alternatively, in some contexts, the expression "a system configured to" can mean that the system is "capable of" together with other devices or components. The expression "a module does" as used herein can be used interchangeably with "a module is configured to", depending on the context.

[0035] In the present disclosure, examples where one component is referred to as being "connected" or "connected" to another component should be understood to mean that the one component may be directly connected or directly connected to the other component, but may also be connected or connected via another component in between, unless otherwise specifically stated.

[0036] In one or more embodiments of the present disclosure, "transmitting" or "forwarding" data by a module may mean providing data to another module. A module may be connected to another module via wires or wirelessly. A module may provide data directly to another module, or may provide data through another module.

[0037] In one or more embodiments of the present disclosure, descriptions of technical contents that are well known in the technical field to which the present disclosure pertains and are not directly related to the present disclosure may be omitted. This is to more clearly convey the gist of the present disclosure without obscuring unnecessary descriptions. In the drawings, parts that are irrelevant to the description are omitted for clear description of the present disclosure, and similar parts are designated with similar reference numerals. In addition, the reference numerals used in each drawing are only for describing each drawing, and different reference numerals used in different drawings do not indicate different elements. The size of each component does not entirely reflect the actual size. The same or corresponding components in each drawing are given the same reference numerals.

[0038] The advantages and features of the present disclosure, and methods for achieving them, will become clearer with reference to the embodiments described below in detail with the accompanying drawings. However, the present disclosure is not limited to the embodiments disclosed below and may be implemented in various different forms. The disclosed embodiments are provided to ensure that the disclosure is complete and to fully inform those skilled in the art of the disclosure of the scope of the disclosure. An embodiment of the present disclosure may be defined according to the claims.

[0039] In one or more embodiments of the present disclosure, each block of the flowchart drawings and combinations of the flowchart drawings may be implemented by computer program instructions. The computer program instructions may be installed on a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus, and the instructions, when executed by the processor of the computer or other programmable data processing apparatus, may create means for performing the functions described in the flowchart block(s). The computer program instructions may also be stored in a computer-available or computer-readable memory that can direct a computer or other programmable data processing apparatus to implement the functions in a particular manner, and the instructions stored in the computer-available or computer-readable memory may also produce an article of manufacture that includes instruction means for performing the functions described in the flowchart block(s). The computer program instructions may also be installed on a computer or other programmable data processing apparatus.

[0040] In one or more embodiments of the present disclosure, each block in the flowchart diagram may represent a module, segment, or portion of code that includes one or more executable instructions for performing a specified logical function(s). In one embodiment, the functions described in the blocks may occur out of order. For example, two blocks depicted in succession may be executed substantially simultaneously or, depending on the function, may be executed in reverse order.

[0041] The terms 'unit' and 'module' used in one or more embodiments of the present disclosure may represent hardware components such as a Field Programmable Gate Array (FPGA) or an Application Specific Integrated Circuit (ASIC), and the 'unit' may perform a specific role. Meanwhile, the 'unit' may not be limited to hardware. The 'unit' may be configured to be on an addressable storage medium and may be configured to play one or more processors. In one embodiment, the 'unit' may include components such as software components, object-oriented software components, class components, and task components, processes, functions, properties, procedures, subroutines, segments of program code, drivers, firmware, microcode, circuits, data, databases, data structures, tables, arrays, and variables. The functionality provided by a specific component or a specific 'unit' may be combined to reduce the number of components or separated into additional components. In addition, in one embodiment, the 'unit' may include one or more processors.

[0042] FIG. 1 is a diagram schematically illustrating a system for providing code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0043] In one embodiment of the present disclosure, an electronic device (100) and a server (110) may provide a code recommendation service to a user (120) that provides code using a generative artificial intelligence (GAI) model. The code recommendation service of the present disclosure may provide the user (120) with a recommended code related to a code that the user (120) is writing or plans to modify. For example, the code recommendation service may allow the user (120) to input information related to a desired recommended code.

[0044] In one or more embodiments of the present disclosure, "generative artificial intelligence" may include artificial intelligence techniques that generate new text, images, etc. in response to input data (e.g., text, images, etc.). In one embodiment, the generative AI may generate output data corresponding to a request based on input data including a user's request.

[0045] In one or more embodiments of the present disclosure, a "generative AI model" may include an artificial intelligence model (e.g., a neural network model) that implements generative AI technology. The generative AI model may generate new data having similar characteristics to the input data or new data corresponding to the input data by learning the patterns and structures of training data. For example, the generative AI model may generate images using an image-to-image or text-to-image method. However, the present disclosure is not limited thereto, and the generative AI model may include various expressions representing the same / similar concepts. For example, the generative AI model may be referred to as a "creative model" or a "generative model," and is not limited to the examples described above.

[0046] According to one embodiment of the present disclosure, the electronic device (100) may obtain user input for code generation. For example, the user input may include a signal or input data for code generation input into the electronic device (100) by a user (120).

[0047] In one or more embodiments of the present disclosure, "user input" may include input data input by a user into an electronic device. In one embodiment, the user input may include an input signal obtained through an input / output device of the electronic device. For example, the electronic device may obtain a user input signal for generating a code through an input device (e.g., a keyboard). The input device may include, but is not limited to, a keyboard or a microphone. Meanwhile, the present disclosure is not limited thereto, and thus, the user input may include various expressions representing the same / similar concepts. The user input may be referred to as, for example, input data, an input signal, etc., and is not limited to the examples described above.

[0048] Referring to FIG. 1, the first interface (130) displays a code written by a user (120) in the electronic device (100). The electronic device (100) may provide a recommendation code related to the code included in the first interface (130) as well as a second interface (140). For example, the user (120) may be writing a code for a function called "fib" that uses "n" as a variable, as displayed in the first interface (130). The electronic device (100) may provide a recommendation code for the function called "fib", which is the input code, as displayed in the second interface (140). For example, the electronic device (100) may determine the purpose, intent, and / or function of the function based on the name of the function and the variables of the function, and generate and provide code related to the operation of the function. For example, the electronic device (100) may display a recommendation code on a display to provide code related to the operation of the corresponding function. The electronic device (100) may determine that the purpose of the function "fib(n)" is to calculate the value of the Fibonacci sequence according to the integer n, and may generate code related to the operation of the function "fib(n)". In one or more embodiments of the present disclosure, the code recommended by the electronic device (100) may be referred to as a target code. For example, "def fib(n)" is a target code of the electronic device (100), and the electronic device (100) may provide a recommended code corresponding to the target code.

[0049] The electronic device (100) can obtain context information for generating code. The context information may include code related to a target document. For example, the context information may include code or comments included in the target document, or code related to a document being written in an Integrated Development Environment (IDE) such as the target document. For example, the electronic device (100) may identify the comment "# Fibonacci sequence" in the first interface (130) as context information.

[0050] In one or more embodiments of the present disclosure, "context information" may include background information that may be referenced when a generative AI model performs its tasks. In one embodiment, the context information may include a description or related information regarding data generated by the generative AI model. However, the present disclosure is not limited thereto, and thus, the context information may include various expressions representing the same / similar concepts. The context information may be replaced with expressions such as "background," "condition," and "environment," and is not limited to the examples described above.

[0051] An electronic device (100) can use context information to generate a prompt for a generative AI model. The prompt can include information for code generation. The generative AI model can receive the prompt and output a code corresponding to the prompt.

[0052] In one or more embodiments of the present disclosure, a "prompt" may include input data for a generative AI model. In one embodiment, the prompt may include input data for initiating an interaction with the generative AI model. The prompt may include text input including one or more words and / or one or more sentences. In one embodiment, the prompt may include natural language text. The natural language text may include various information that the generative AI model can utilize to generate a response to the request. For example, the prompt may include at least one of context information, intent information, task information, or constraint information. Meanwhile, the present disclosure is not limited thereto, and the prompt may include various expressions representing the same / similar concepts. The prompt may be replaced with expressions such as, but not limited to, "Input", "Input Phrase", "User command", "Directive", "Instruction", "Task query", "Trigger sentence", "Message", etc.

[0053] In one embodiment of the present disclosure, the electronic device (100) may summarize a prompt based on the length of the prompt. For example, the electronic device (100) may summarize a prompt if the length of the prompt is longer than a threshold value. The electronic device (100) may summarize information contained in the prompt based on a priority. For example, the electronic device (100) may modify at least some of the information contained in the prompt to be shorter or delete some of the information. For example, the electronic device (100) may summarize a prompt based on determining that the prompt is longer than a threshold value. In one embodiment of the present disclosure, the prompt before being summarized may be referred to as a first prompt, and the summarized prompt may be referred to as a second prompt.

[0054] In the present disclosure, a "threshold value" may represent an upper limit of the length of a prompt. In one embodiment of the present disclosure, in an example where the length of the prompt is greater than the threshold, the generative AI model may not generate output data or may generate incorrect output data. In one embodiment, the length of the prompt may be determined in token units. A token may represent the smallest unit of a string that the generative AI model can understand. In one embodiment, the length of the string constituting the token may not be constant. Meanwhile, the present disclosure is not limited thereto, and thus, the threshold value may include various expressions representing the same / similar concept. The threshold value may include expressions such as, for example, a maximum, a maximum threshold level, or a predetermined value, and is not limited to the above-described examples.

[0055] In one embodiment of the present disclosure, an electronic device (100) may transmit a prompt to a server (110). The server (110) may generate a code corresponding to the prompt using a generative AI model. The electronic device (100) may receive information about the code from the server (110) and provide the code using the received information.

[0056] In one embodiment of the present disclosure, the electronic device (100) may be any type of device that provides a personalized code to a user's (120) actions. For example, the electronic device (100) may be implemented as any type and form of electronic device including a display. The electronic device (100) may include, but is not limited to, devices capable of displaying a code through a display, such as a smart TV, a smart phone, a tablet PC, a laptop PC, a glasses-type display, a head-mounted display (HMD), etc.

[0057] According to one embodiment of the present disclosure, the electronic device (100) may be implemented as various types and forms of electronic devices capable of being connected to a display via wired / wireless connection. For example, the electronic device (100) may include, but is not limited to, devices that are connected to a display via wired / wireless connection and capable of displaying a code on the display, such as a set-top box or a desktop PC.

[0058] In one embodiment of the present disclosure, the server (110) may be a device that generates code using a generative AI model. The server (110) may be a device capable of processing complex operations and tasks using large amounts of data, such as training, inference, management, and distribution of the generative AI model. According to one embodiment, the training of the generative AI model executed on the server (110) may be performed by another computing device. The server (110) may receive a prompt for code generation from an electronic device (100), which is a client device, and transmit information regarding the generated code to the electronic device (100).

[0059] In one embodiment of the present disclosure, the electronic device (100) and server (110) providing a code recommendation service may be referred to as a "code recommendation system." Alternatively, for convenience, they may simply be referred to as a "system." In one embodiment of the present disclosure, an embodiment in which a code is generated by the code recommendation system and provided to a user is described. However, the operations of the present disclosure do not necessarily have to be performed by the code recommendation system.

[0060] In one embodiment of the present disclosure, the operations of providing code can be independently performed by the electronic device (100). In this case, a generative AI model that generates code using a prompt can be stored in the electronic device (100). The electronic device (100) can perform the operations of the present disclosure using the generative AI model to generate code. In one embodiment, since the electronic device (100) has relatively low computing performance compared to the server (110), the generative AI model used by the electronic device (100) can be a lightweight AI model suitable for the computing performance of the electronic device (100).

[0061] In one embodiment of the present disclosure, the operations of providing codes may be independently performed by the server (110). In this case, the server (110) may only receive a request for code generation from the electronic device (100), perform the operations of the present disclosure to generate a code, and return the generated result to the electronic device (100).

[0062] In one embodiment of the present disclosure, the electronic device (100) may include a server. For example, the electronic device (100) may include a server that provides cloud computing services. That is, the electronic device (100) may perform operations, programs, and / or functions at the request of another electronic device (e.g., a client device), and transmit the results of the operations to the other electronic device for display. For example, the electronic device (100) may perform an operation that provides the code of the present disclosure and display the code through a display of the other electronic device.

[0063] In one embodiment of the present disclosure, the operations of providing code may be performed separately by multiple electronic devices. For example, among the operations of the present disclosure, "Operation A" may be performed by "electronic device A," and "Operation B" may be performed by "electronic device B." Examples of various implementation methods of the present disclosure, such as those described above, are self-evident, and therefore, for the sake of brevity, their description will be omitted herein.

[0064] Specific operations of the electronic device (100) to recommend a code based on the input of the user (120) will be described in more detail through the drawings and descriptions thereof described below.

[0065] FIG. 2 is a flowchart illustrating a method for providing code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0066] Referring to FIG. 2, operations for providing a code by an electronic device (100) are schematically described, and a detailed description of each operation will be described with reference to the drawings that follow.

[0067] In operation S210, the method may include an operation of obtaining a user input corresponding to a first document. For example, the electronic device (100) may obtain a user input for generating a code included in a target document. In one embodiment of the present disclosure, the target document may include a document including the code to be generated. In one embodiment of the present disclosure, the user input may include at least one of an input for modifying the code in the target document or a request regarding the code in the target document. An operation of obtaining a user input by an electronic device according to one embodiment of the present disclosure is described in detail with reference to FIGS. 4, 5, 12, and 14.

[0068] In operation S220, the method may include an operation of obtaining first context information for code generation. For example, the electronic device (100) may obtain context information available for code generation based on a user input.

[0069] In one embodiment of the present disclosure, context information may include, but is not limited to, at least one of information contained in a target document, information contained in a reference document, or information contained in a document created by another user within a group including the user of the target document. Information contained in a document may include code or comments.

[0070] In one embodiment of the present disclosure, the code may include text written in a programming language to cause an electronic device to perform a specific operation. In one embodiment of the present disclosure, a comment may refer to text that does not affect the operation of the electronic device. For example, a comment may be included in a document to aid understanding of the code. For example, a comment may include text that describes the operation of the code in a human language, rather than a programming language.

[0071] In one embodiment of the present disclosure, a reference document may include a document referenced by code in a target document. For example, if the code in a target document references code written in another document, the other document containing the referenced code may be referred to as a reference document.

[0072] In one embodiment of the present disclosure, the electronic device (100) can determine context information available for code generation based on at least one of a user input or a target document. The electronic device (100) can obtain the determined context information from at least one of the target document or a reference document.

[0073] In operation S230, the method may include generating a first prompt for code generation based on first context information and user input. For example, the electronic device (100) may generate the first prompt for code generation based on the context information and user input. In one embodiment of the present disclosure, the first prompt may include at least one of context information and user input. The first prompt according to one embodiment of the present disclosure is described in detail with reference to FIGS. 8 and 11 to 14.

[0074] In operation S240, the method may include an operation of selecting second context information from among the first context information according to priority information. For example, the electronic device (100) may select information for generating a second prompt, which is a summary of the first prompt, from among the context information according to priority information, based on the length of the first prompt being longer than a threshold value. For example, the electronic device (100) may select information to be used for generating the second prompt from among the context information in response to the length of the first prompt being longer than the threshold value. For example, the electronic device (100) may select information to be used for generating the second prompt from among the context information in response to the length of the first prompt being determined to be longer than the threshold value.

[0075] In one embodiment of the present disclosure, priority information may include an order regarding context information. For example, priority information may include at least one of an order regarding context information that is processed with priority when summarization is performed and a priority for context information that is not summarized. For example, a portion of the context information of a first prompt may not be summarized, and only the remaining context information may be summarized. For example, a first portion of the context information of the first prompt may not be summarized, and a second portion of the context information may be summarized. According to one embodiment of the present disclosure, priority information may indicate that a priority is set based on the importance of the context information. For example, the lower the importance of the context information, the higher the priority may be set. In this case, the priority may include an order among the context information to be summarized. The priority may include information regarding context information that is not summarized. According to one embodiment of the present disclosure, the priority may be referred to as a summary order, but is not limited thereto.

[0076] In operation S250, the method may include generating a second prompt corresponding to the first prompt based on second context information and user input. For example, the electronic device (100) may generate a second prompt that summarizes the first prompt based on the selected context information and user input. In one embodiment of the present disclosure, the electronic device (100) may summarize or delete the context information selected in operation S250.

[0077] In one embodiment of the present disclosure, the electronic device (100) may generate a second prompt by summarizing and / or deleting at least some of the context information included in the first prompt. In one embodiment of the present disclosure, the electronic device (100) may generate the second prompt from the first prompt using a generative AI model.

[0078] In operation S260, the method may include an operation of transmitting a first prompt or a second prompt. The electronic device (100) may transmit the first prompt or the second prompt to a server. For example, the server may be a device including a generative AI model for code generation.

[0079] In operation S270, the method may include an operation of obtaining a recommendation code generated using a generative artificial intelligence model based on a first prompt or a second prompt. For example, the electronic device (100) may receive and provide a code generated using the generative artificial intelligence model based on the first prompt or the second prompt from the server. For example, the server may input the first prompt or the second prompt into the generative AI model to generate a code. The electronic device (100) may provide the code generated by the generative AI model through a display.

[0080] In one embodiment of the present disclosure, the method for providing code does not necessarily have to include operations S210 to S270. At least some of operations S210 to S270 may be omitted or some additional steps may be included.

[0081] FIG. 3A is a diagram illustrating a prompt for a generative artificial intelligence model according to one embodiment of the present disclosure.

[0082] A prompt can refer to information provided to a generative AI model to obtain the user's intended response. The generative AI model can generate a response based on the information contained in the prompt.

[0083] In one embodiment of the present disclosure, a prompt may include a role. For example, the prompt may include the text "I am an AI programming assistant," which is associated with the role of the generative AI (e.g., a Q&A chatbot). The role of the generative AI may be set in various ways, including, but not limited to, a role such as a prompt engineer.

[0084] In one embodiment of the present disclosure, a prompt may include a task. The task may include information related to the goal of the generative AI. For example, the prompt may include text related to the task of the generative AI, such as "If the user asks for code or technical questions, I provide code suggestions and adhere to technical information." The task of the generative AI may be configured in various ways, including, but not limited to, a prompt summary.

[0085] In one embodiment of the present disclosure, a prompt may include constraints. The constraints may include specific requests for responses from a generative AI model. For example, the prompt may include the text "I will respond with "Unknown" if the category of question is not related to code or technical domains," which is a constraint of the generative AI. The constraints of the generative AI may be set in various ways, and may include, but are not limited to, limits on the length or complexity of a response.

[0086] In one embodiment of the present disclosure, the prompt may include an example. The example may include example information related to the user request. For example, the prompt may include text related to an example of an action of the generative AI, such as "Q: What is docker? A. Docker is a platform for developers and sysadmins to build, ship, and run distributed applications." Furthermore, for example, the prompt may include text related to an example of a constraint of the generative AI, such as "Q: How many people live in South Korea? A: Unknown."

[0087] In one embodiment of the present disclosure, the prompt may include a request. The user request may include information regarding a query requesting a response from the generative AI model. For example, the prompt may include text related to the user request from the generative AI model, such as "Q: What is dropout?"

[0088] In one embodiment of the present disclosure, a generative AI model can provide a response to a prompt. For example, the generative AI model can generate the response text "Dropout is a regularization technique used in deep learning to prevent overfitting" in response to a user's request.

[0089] Although FIG. 3a illustrates, by way of example, that the prompt only contains text written in human language, the prompt is not limited thereto and may include various types of natural language. For example, as described below in FIG. 3b , the prompt may include text written in a programming language.

[0090] FIG. 3b is a diagram illustrating a prompt for a generative artificial intelligence model according to one embodiment of the present disclosure.

[0091] In one embodiment of the present disclosure, the prompt may include a task. For example, the prompt may include the text "Translate Python code to C++ language:" related to the task of the generative AI. The generative AI model according to one embodiment of the present disclosure converting code written in a first programming language into code written in a second programming language may be referred to as a translation function.

[0092] In one embodiment of the present disclosure, the prompt may include an example. For example, the prompt may include text related to an example of the operation of the generative AI, such as "Python: print("hello world") C++: cout << "hello world / n";". That is, the prompt may include an example of how the Python code "print("hello world")" can be translated into the C++ language "cout << "hello world / n";".

[0093] In one embodiment of the present disclosure, the prompt may include a request. For example, the prompt may include text "Python: name = input() C++:" related to a user request from the generative AI model. That is, the prompt may include a user request to translate the Python code "name = input()" into the C++ language. In one embodiment of the present disclosure, the generative AI model may provide a response to the prompt. For example, the generative AI model may generate the response text "cin >> name;" in response to the user request.

[0094] The prompt is not limited to including only the information described in FIGS. 3A and 3B, and some information may be omitted or additional information may be included.

[0095] FIG. 4 is a diagram illustrating a user interface for providing code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0096] Referring to FIG. 4, a user interface (UI) providing code according to one embodiment of the present disclosure is illustrated. The UI may include a first UI (400) representing an integrated development environment. The first UI (400) may include at least one of a second UI (410) displaying code and a third UI (420) displaying chat. The user interface may be displayed through a display of the electronic device (100), but is not limited thereto, and may be displayed through various types of electronic devices including a display.

[0097] In one embodiment of the present disclosure, the first UI (400) may represent an integrated development environment (IDE). The IDE may refer to a program or service in which a user writes code. The first UI (400) may include a target document, a project including the target document, other documents included in the project, and the like. For example, the first UI (400) may include a target document "fib.py," a project "test_project" including the target document, and other documents included in the project "main.py."

[0098] In one embodiment of the present disclosure, the second UI (410) may display input obtained through the code input interface of FIG. 5. The third UI (420) may display input obtained through the chat input interface of FIG. 5. In one embodiment of the present disclosure, the code input interface may include an interface for obtaining input regarding a code. In one embodiment of the present disclosure, the chat input interface may include an interface for obtaining input regarding a chat. The code input interface and the chat input interface according to one embodiment of the present disclosure are described below with reference to FIG. 5.

[0099] In one embodiment of the present disclosure, the second UI (410) may include an area representing the code of the target document. In one embodiment of the present disclosure, the second UI (410) may display the written code. For example, the second UI (410) may include text regarding a function defining the Fibonacci sequence. Here, "#fibonacci sequence" may refer to a comment included in the target document, and "def fib(n):" may refer to code defining a function having the variable "n" and the function name "fib."

[0100] In one embodiment of the present disclosure, the second UI (410) may display a recommended code generated based on the written code or comments. The recommended code may be generated using a generative AI model based on the written code or comments. For example, the recommended code may be generated using at least a portion of the written code "def fib(n)" or "# fibonacci sequence." The recommended code may be a code block comprising multiple lines of code for the operation of a function. For example, referring to FIG. 4, the recommended code may include a code block consisting of six lines.

[0101] In one embodiment of the present disclosure, the second UI (410) may display a recommendation code generated based on a chat input. For example, the recommendation code may be generated using the chat input displayed on the third UI (420). The third UI (420) may display an interaction between a user and the electronic device (100) that includes a request and a response. A request may refer to an input in which a user requests a specific action from the electronic device (100). For example, the request may include the text "Generate a code that outputs the nth Fibonacci sequence integer." A response may refer to an output from the electronic device (100) in response to the request. For example, the response may include the text "The code according to your request has been generated. Do you have any additional requests?" In addition, for example, the response may include an output that displays a recommendation code on the second UI (410). The recommendation code may be generated using a generative AI model based on the chat input.

[0102] FIG. 5 is a block diagram of a system that provides code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0103] Referring to FIG. 5, a system (500) for providing code using a generative artificial intelligence model according to one embodiment of the present disclosure is illustrated. The system (500) may include at least one of an input / output device (510), an input interface (520), a prompt generation module (530), or an artificial intelligence module (540). However, the present disclosure is not limited thereto, and according to other embodiments, one or more other components may be added and / or one or more components may be omitted.

[0104] In one embodiment of the present disclosure, the input / output device (510) may include a keyboard. The keyboard may include an input device including a plurality of keys. The keyboard may generate a signal from the pressure applied to each key. The keyboard may transmit a signal related to the key to which the pressure is applied to the electronic device. In one embodiment of the present disclosure, the input / output device (510) may be a component included in the electronic device (100) or a separate device connected to the electronic device (100).

[0105] In one embodiment of the present disclosure, the system (500) can obtain an input signal using an input / output device (510). The input signal may correspond to a user input. The input / output device (510) can transmit the input signal to an input interface (520). In one embodiment of the present disclosure, the input interface (520) can obtain the input signal from the input / output device (510). The input interface (520) may include at least one of a code input interface, a chat input interface, or a shortcut key input interface.

[0106] In one embodiment of the present disclosure, the code input interface may obtain user input for writing or modifying code. For example, the code input interface may obtain user input for adding, deleting, or correcting code. For example, user input for adding code may include user input for adding characters, wherein the characters may include general characters such as alphabets, spaces, or special characters such as " / ". User input for deleting code may include user input for removing at least a portion of the written code. User input for correcting code may include user input for removing at least a portion of the written code and entering new characters.

[0107] In one embodiment of the present disclosure, the chat input interface can obtain user input including a request for code generation. For example, as illustrated in FIG. 4, the user input may include a request for the generation of a specific code. The chat input interface can obtain user input while the chat service is running or is being run. The chat input interface can be executed using a predetermined shortcut key or another input device (e.g., a mouse).

[0108] In one embodiment of the present disclosure, the shortcut key input interface may obtain user input including shortcut key input related to code generation. For example, the shortcut key input interface may obtain user input for a predetermined shortcut key or combination of shortcut keys. The shortcut key may be set to any key or combination of keys other than a key that modifies characters.

[0109] The input interface (520) can transmit user input to the prompt generation module (530) based on the acquired user input. For example, the input interface (520) can transmit the user input to the prompt generation module (530) in response to the acquired user input. In one embodiment of the present disclosure, the prompt generation module (530) can include a context information acquisition module and a prompt processing module. In one embodiment of the present disclosure, the input interface (520) can transmit the user input to at least one of the context information acquisition module or the prompt processing module of the prompt generation module (530). In one embodiment of the present disclosure, the prompt generation module (530) can be implemented by the processor of the electronic device (100) executing a program or instruction stored in the memory of the electronic device (100). In one embodiment of the present disclosure, an operation or process described as being performed by the prompt generation module (530) can be understood to be performed by the processor of the electronic device (100). For example, the processor of the electronic device (100) may perform at least one of a prompt generation module (530), a context information acquisition module, a code information retrieval module, a code information extraction module, a prompt processing module, a combination module, or a summary module. However, the present invention is not limited thereto, and the prompt generation module (530) may be performed by a processor of the server (110). In one embodiment of the present disclosure, the detailed components or modules included in the prompt generation module (530) may be viewed as software units that are responsible for specific functions or roles in an overall program that generates a prompt based on a user's input.

[0110] In one embodiment of the present disclosure, the context information acquisition module may include a code information retrieval module and / or a code information extraction module.

[0111] In one embodiment of the present disclosure, the code information retrieval module may obtain context information from a database. For example, the code information retrieval module may search for and obtain context information from an external network. In one embodiment of the present disclosure, the database may not be included in the context information acquisition module. For example, the database may be provided externally to the electronic device (100). The process of obtaining context information and the types of context information are described in detail with reference to FIG. 7.

[0112] In one embodiment of the present disclosure, the code information extraction module can obtain context information from memory. For example, the code information extraction module can extract context information from an integrated development environment (IDE) associated with a target document. The process of extracting context information and the types of context information are described in detail with reference to FIG. 6.

[0113] In one embodiment of the present disclosure, the context information acquisition module may transmit the acquired context information to the prompt processing module. The prompt processing module may include a combination module and a summary module.

[0114] In one embodiment of the present disclosure, the combination module can generate a prompt based on acquired context information. For example, the prompt can be generated by merging or concatenating context information. The prompt can include at least one of context information, user input, or target code. For example, if the prompt generated by the combination module is longer than a threshold, the combination module can pass the prompt to the summarization module. For example, if the prompt generated by the combination module is shorter than the threshold, the combination module can determine the prompt as the final prompt without passing it to the summarization module. The process of combining prompts according to one embodiment of the present disclosure is described in detail with reference to FIG. 8.

[0115] In one embodiment of the present disclosure, a summary module can summarize a prompt. The summary module can summarize a prompt according to predetermined rules. The summary module can summarize some contextual information of the prompt. The summary module can determine a priority corresponding to the contextual information included in the prompt and summarize the contextual information according to the priority information. For example, each contextual information included in the prompt can be assigned a priority, and the summary module can summarize the contextual information based on the priority assigned to each contextual information. The summary module can delete some contextual information of the prompt.

[0116] In one embodiment of the present disclosure, the summary module may summarize using an artificial intelligence module (540). For example, the summary module may transmit a prompt or selected context information to an external server and receive the summarized prompt or summarized context information using a generative AI model.

[0117] In one embodiment of the present disclosure, the artificial intelligence module (540) may include a generative AI model. The artificial intelligence module (540) may generate code using a prompt. The artificial intelligence module (540) may use the prompt as input to generate code corresponding to user input.

[0118] In one embodiment of the present disclosure, the electronic device (100) may include at least one of an input / output device (510), an input interface (520), a prompt generation module (530), or an artificial intelligence module (540). However, the present invention is not limited thereto, and some of the input / output device (510), the input interface (520), the prompt generation module (530), or the artificial intelligence module (540) may be implemented through another electronic device (100).

[0119] FIG. 6 is a diagram for explaining a process of extracting code information according to one embodiment of the present disclosure.

[0120] In one embodiment of the present disclosure, an electronic device (100) can obtain context information. The electronic device (100) can obtain context information from a target document or a reference document by executing a code information extraction module. The electronic device (100) can obtain context information from code or comments included in the target document or the reference document.

[0121] In one embodiment of the present disclosure, an electronic device (100) can obtain context information from a target document. The electronic device (100) can obtain context information based on a pointer (e.g., a mouse cursor, a keyboard cursor). The electronic device (100) can obtain context information including a code or comment located before the pointer. The electronic device (100) can obtain context information including a code or comment located after the pointer.

[0122] In one embodiment of the present disclosure, the electronic device (100) can obtain context information from an open document. The electronic device (100) can identify a document opened in an integrated development environment. For example, the electronic device (100) can obtain a list of open documents through an integrated development environment API. The electronic device (100) can obtain context information from the identified open document. Referring to FIG. 6, the electronic device (100) can obtain context data including code or comments included in files "main.py," "snake.py," and / or "requirements.txt" opened in the integrated development environment.

[0123] In one embodiment of the present disclosure, the electronic device (100) can obtain context information from a reference document included in a project such as a target document. Referring to FIG. 6, the target document "snake.py" is included in the project "TEST_PROJECT", such as "main.py" and "requirements.txt." The electronic device (100) can obtain context data including code or comments of "main.py" and "requirements.txt" included in the same project as the target document "snake.py."

[0124] In one embodiment of the present disclosure, the electronic device (100) can obtain context information from a dependency document. A dependency document may refer to a document that includes packages, libraries, tasks, and / or commands required to execute a project. For example, a dependency document may include "Requirement," "Makefile," and "dockerfile." Referring to FIG. 6, a dependency document may include "requirements.txt." The electronic device (100) can obtain context information that includes code or comments corresponding to packages, libraries, and / or API functions included in the dependency document.

[0125] In one embodiment of the present disclosure, the electronic device (100) may obtain context information from a document referenced by a target document. For example, the electronic device (100) may obtain context information including code or comments included in a document referenced by the target document via "import" or "include."

[0126] In one embodiment of the present disclosure, the electronic device (100) can obtain all code or comments included in a target document as context information. In one embodiment of the present disclosure, the electronic device (100) can obtain some information representing the code or comments included in the target document as context information. For example, if the amount of code information included in the document is large, the electronic device (100) can obtain only some of the information included in the document as context information. For example, if the amount of code information included in the document is greater than a reference value, the electronic device (100) can obtain context information based on a portion of the document. The amount of code information may include, but is not limited to, the size of the document or the number of lines of code in the document. The electronic device (100) can obtain a docstring related to the code included in the document as context data. The docstring may include comments related to the definition of a module, function, class, or method included in the code. The electronic device (100) can obtain a function signature as context information. A function signature may include a list of parameters specified for the function.

[0127] FIG. 7 is a diagram illustrating a process for searching code information according to one embodiment of the present disclosure.

[0128] In one embodiment of the present disclosure, an electronic device (100) can obtain context information. The electronic device (100) can obtain context information from a reference document by executing a code information retrieval module. The electronic device (100) can obtain context information from code or comments included in the reference document.

[0129] In one embodiment of the present disclosure, the electronic device (100) can identify a code representing a reference document. Referring to FIG. 7, the code "response = requests.get('https: / api.smartthings.com / v1 / locations', headers=headers)" included in the target document may refer to a code that calls the reference document. That is, the API document corresponding to the Internet address 'https: / api.smartthings.com / v1 / locations' may be the target document. The API document may include functions, parameters, features, and / or example code.

[0130] In one embodiment of the present disclosure, the electronic device (100) can obtain a reference document through an index representing a reference document included in the code. The index can represent a given code (e.g., a library, a package). The electronic device (100) can obtain a reference document corresponding to the index. For example, the electronic device (100) can obtain a reference document corresponding to the index using a search engine.

[0131] In one embodiment of the present disclosure, an electronic device (100) can obtain context information from a document written by another user in an organization in which a user is included. The electronic device (100) can identify the organization in which the user is included. The electronic device (100) can identify whether there is code (or document) similar to or identical to a target code (or target document) among codes (or documents) written by other users in the organization. For example, the electronic device (100) can search for a similar or identical function based on the function name. The electronic device (100) can obtain context information including code similar to or identical to the target code.

[0132] The electronic device (100) can obtain a reference document. For example, the electronic device (100) can obtain a reference document including at least one of code or comments as context information through a reference path included in a target document. The electronic device (100) can obtain at least some of the code or comments included in the reference document. In one embodiment of the present disclosure, the electronic device (100) can obtain all of the code or comments included in the reference document as context information. In one embodiment of the present disclosure, the electronic device (100) can obtain some information representing the code or comments included in the reference document as context information.

[0133] FIG. 8 is a diagram illustrating a process of combining context information according to one embodiment of the present disclosure.

[0134] In one embodiment of the present disclosure, the electronic device (100) can generate a prompt (840) including context information. For example, the context information can include first context information (810), second context information (820), and third context information (830). The electronic device (100) can generate the prompt by executing the combination module (1826). The context information (810, 820, 830) can be obtained by the electronic device (100) using a code information extraction module or a code information retrieval module. The context information can include a code or a comment.

[0135] In one embodiment of the present disclosure, the electronic device (100) can merge or concatenate context information (810, 820, 830) to generate a prompt (840).

[0136] In one embodiment of the present disclosure, the electronic device (100) may merge context information (810, 820, 830) according to priority information. For example, referring to FIG. 8, the prompt (840) may include first context information (810), third context information (830), and second context information (820) in that order. In one embodiment of the present disclosure, the electronic device (100) may sort the context information (810, 820, 830) according to priority information. For example, the electronic device (100) may include context information with a higher priority in a front-end order. However, the present disclosure is not limited thereto, and the electronic device (100) may include context information with a lower priority in a front-end order. The priority may be determined based on the importance of the context information. The priority may be determined in the reverse order of the importance of the context information. For example, the priority may be set higher as the importance of the context information decreases. For example, context information obtained from a target document may be determined to have the highest importance and a low priority. The electronic device (100) may determine context information with a low priority as important information and not summarize or delete it.

[0137] According to one embodiment of the present disclosure, the electronic device (100) may generate a prompt (840) by merging context information (810, 820, 830) without sorting. For example, the prompt may include context information in the order in which it was obtained, separate from priority information.

[0138] In one embodiment of the present disclosure, the electronic device (100) may generate a prompt including user input. For example, the electronic device (100) may generate a prompt including chat input. A prompt including chat input according to one embodiment of the present disclosure is described in detail with reference to FIG. 13.

[0139] FIG. 9 is a diagram illustrating a process for summarizing a prompt according to one embodiment of the present disclosure.

[0140] In one embodiment of the present disclosure, the electronic device (100) may generate a first prompt (940) including context information. For example, the context information may include first context information (910), second context information (920), and third context information (930). The electronic device (100) may summarize the first prompt (940) by executing the summary module (1828). For convenience of explanation, the prompt before the summary module (1828) performs the summary is referred to as the first prompt, and the summarized prompt after the summary module (1828) performs the summary is referred to as the second prompt.

[0141] In one embodiment of the present disclosure, the electronic device (100) may generate a second prompt (945) summarized from the first prompt (940). The electronic device (100) may summarize or delete at least some of the context information (910, 920, 930) of the first prompt (940). At least some of the context information (915, 925, 935) of the second prompt (945) may be a summary of the context information (910, 920, 930) of the first prompt (940). For example, the context information may be summarized to include important information, such as the name of a function, parameters, and output of the function.

[0142] In one embodiment of the present disclosure, the electronic device (100) may summarize the prompt so as not to repeatedly include the same context information. For example, if some context information included in the first prompt (940) is redundant, the electronic device (100) may delete the context information so as not to duplicate it.

[0143] In one embodiment of the present disclosure, the electronic device (100) may generate the second prompt (945) without summarizing or deleting some of the context information of the first prompt (940). For example, context information with high importance may require original context information without summarizing. The electronic device (100) may generate the second prompt (945) without summarizing or deleting code or comments of the target document. For example, the electronic device (100) may not summarize or delete code corresponding to the indicator (e.g., code or comments located before and after the indicator).

[0144] In one embodiment of the present disclosure, the electronic device (100) may repeatedly perform summarization until the length of the summarized prompt becomes shorter than a threshold value. The electronic device (100) may identify the length of the prompt before summarizing the prompt, and perform the summarization based on whether the length of the prompt is longer than the threshold value.

[0145] FIG. 10 is a diagram illustrating a process of summarizing a prompt using a generative language model according to one embodiment of the present disclosure.

[0146] In one embodiment of the present disclosure, the electronic device (100) can summarize a prompt using a generative language model (1030). The generative language model (1030) can be stored in the electronic device (100) or in a server connected to the electronic device (100).

[0147] In one embodiment of the present disclosure, a generative language model (1030) may generate summarized context information (1040) by inputting a prompt including context information (1010) and a request (1020). For example, the context information (1010) may include code or comments.

[0148] In one embodiment of the present disclosure, a request (1020) may include a task for a generative language model to perform summarization. For example, the request (1020) may include a task such as "summarize with a function signature and docstring." The generative language model (1030) may generate summarized context information (1040) from context information (1010) according to the request (1020). For example, the summarized context information (1040) may include a function name "merge_sort" and a parameter "arr", which are function signatures included in the context information (1010), and a docstring related to the operation of the function.

[0149] In one embodiment of the present disclosure, the electronic device (100) may select some of the context information of the prompt and input the selected context information into the generative language model. In one embodiment of the present disclosure, the electronic device (100) may input all of the context information of the prompt into the generative language model without selecting any of the context information. In one embodiment of the present disclosure, the request (1020) may include context information that is the target of the summary.

[0150] In one embodiment of the present disclosure, the electronic device (100) can summarize various natural languages ​​as well as codes and / or comments using a generative language model.

[0151] FIG. 11 is a diagram illustrating a prompt provided to a generative artificial intelligence model according to one embodiment of the present disclosure.

[0152] Referring to FIG. 11, in one embodiment of the present disclosure, a prompt is shown in response to user input or shortcut key input to modify code.

[0153] In one embodiment of the present disclosure, the prompt may include contextual information. The contextual information may include at least one of code or comments contained in the target document, a reference document, another document within the same project, and / or an external document.

[0154] A prompt can include code from a reference document as contextual information. See Figure 11. <context>and <end>Information contained within may indicate contextual information. Contextual information may include the location of the referenced document, its code, and / or comments within the referenced document. The location of the referenced document may refer to the path where the referenced document is stored. For example, "src / calculator.java" may indicate the location (and name) of the referenced document.

[0155] In one embodiment of the present disclosure, the prompt may include request information. The request information may include the location of the target document and / or the target code. Referring to FIG. 11, <filename>The information included after may mean requested information.

[0156] In one embodiment of the present disclosure, the target code may be determined based on user input. For example, the target code may refer to code associated with the last user input entered. For example, if the last user input entered relates to at least a portion of "Public static void main(String[] args) {", the target code may be code associated with "Public static void main(String[] args) {".

[0157] In one embodiment of the present disclosure, the target code may be determined based on an indicator included in the user interface. For example, the target code may be determined as a code indicated by the position of the keyboard cursor of the user interface. For example, if the keyboard cursor of the user interface is located at the beginning, middle, or end of "Public static void main(String[] args) {", the target code may be a code associated with "Public static void main(String[] args) {".

[0158] In one embodiment of the present disclosure, the electronic device (100) may generate a prompt based on user input. In one embodiment of the present disclosure, the electronic device (100) may generate a prompt in response to a predetermined amount of time having elapsed since the last time a user input was obtained. In one embodiment of the present disclosure, the electronic device (100) may generate a prompt in response to a shortcut key input being obtained.

[0159] FIG. 12 is a flowchart illustrating steps for obtaining user input according to one embodiment of the present disclosure. The flowchart of FIG. 12 includes detailed operations of operation S210 of FIG. 2 according to one embodiment of the present disclosure.

[0160] Referring to FIG. 12, in one embodiment of the present disclosure, operation S210 may include operation S1210 and operation S1220.

[0161] In operation S1210, the method may include an operation of identifying a user input for modifying a code. For example, the electronic device (100) may identify a user input for modifying a code. For example, the electronic device (100) may obtain an input signal for modifying information about the code through an input / output device. In one embodiment of the present disclosure, the user input may include a user input for modifying a code in a target document. The user input for modifying a code may include at least one of an input for adding, deleting, or correcting a code in the target document. The user input for modifying a code may include a user input for modifying one or more characters of the code.

[0162] In operation S1220, the method can identify whether a predetermined amount of time has elapsed since the last user input. For example, the electronic device (100) can identify whether a predetermined amount of time has elapsed since the last user input. The predetermined amount of time may be a predetermined value. For example, if the predetermined amount of time has not elapsed since the last user input, the electronic device (100) may not proceed to operation S220 and wait until the predetermined amount of time has elapsed since the last user input. The fact that the predetermined amount of time has not elapsed since the last user input may mean that the electronic device (100) is continuously acquiring user inputs.

[0163] For example, if a predetermined amount of time has passed since the last user input, the electronic device (100) may proceed to operation S220. In one embodiment of the present disclosure, the electronic device (100) may acquire context information in response to the absence of additional user input for a predetermined amount of time. For example, if there is an additional user input within a predetermined amount of time (e.g., 0.3 seconds), the electronic device (100) may not proceed to operation S220, but may proceed to operation S220 only if there is no additional user input for the predetermined amount of time.

[0164] An electronic device (100) according to one embodiment of the present disclosure may generate a first prompt based on user input modifying code and context information. For example, the electronic device (100) may generate a first prompt including target code including modified code and context information.

[0165] In one embodiment of the present disclosure, operation S210 does not necessarily have to include operations S1210 and S1220 of FIG. 12, and may omit at least some of S1210 and S1220 or include some additional steps.

[0166] FIG. 13 is a diagram illustrating a prompt provided to a generative artificial intelligence model according to one embodiment of the present disclosure.

[0167] Referring to FIG. 13, in one embodiment of the present disclosure, a prompt is shown based on user input regarding code generation.

[0168] In one embodiment of the present disclosure, the prompt may include contextual information. The contextual information may include at least one of code or comments contained in a target document, a reference document, another document within the same project, and / or an external document. The contextual information is omitted here as it has been described with reference to FIG. 11.

[0169] In one embodiment of the present disclosure, the prompt may include code and / or comments of the target document. For example, referring to FIG. 13, <filename>Information contained between <|end|> may refer to code and / or comments in the target document.

[0170] In one embodiment of the present disclosure, the prompt may include user input. The prompt may include chat input. Referring to FIG. 13, the prompt may include the acquired chat input, "Generate a code that receives two numbers from the user, adds them, and then prints them."

[0171] In one embodiment of the present disclosure, the electronic device (100) can generate a prompt based on user input. In response to the acquisition of a chat input, the electronic device (100) can generate a prompt corresponding to the chat input. In one embodiment of the present disclosure, the electronic device (100) can determine a priority based on the chat input. The electronic device (100) can summarize the prompt based on priority information.

[0172] FIG. 14 is a flowchart illustrating steps for obtaining user input according to one embodiment of the present disclosure. The flowchart of FIG. 14 includes detailed operations of operation S210 of FIG. 2 according to one embodiment of the present disclosure.

[0173] Referring to FIG. 14, in one embodiment of the present disclosure, operation S210 may include operation S1410 and operation S1420.

[0174] In operation S1410, the method may include an operation of identifying a request for code generation contained in a target document. For example, the electronic device (100) may identify a request for code generation contained in the target document. In one embodiment of the present disclosure, the request for code generation may include, but is not limited to, at least one of a chat input or a shortcut key input.

[0175] In one embodiment of the present disclosure, the electronic device (100) may include a chat input requesting information regarding code. For example, the user input may include chat information such as "Generate code for ~." In other words, the user input may include the user's request information. The chat input may include a user interface displaying a target document and text input entered through a separate user interface. For example, as described in FIG. 4 , the chat input may include a text input requesting code for a function intended by the user through a separate user interface.

[0176] In one embodiment of the present disclosure, the electronic device (100) may include a shortcut key input requesting information about a code. The shortcut key input may include an input unrelated to modifying characters in a target document. For example, the shortcut key input may include a predetermined key on a keyboard (e.g., F9) or a combination of predetermined keys (e.g., Shift + Enter).

[0177] In operation S1420, the method may include an operation of identifying a target of the request. For example, the electronic device (100) may identify a target of the request. The target of the request may include a target code.

[0178] In one embodiment of the present disclosure, the electronic device (100) can identify the target of a request related to a chat input. For example, in a chat input requesting code for a given function, the target of the request may refer to the given function.

[0179] In one embodiment of the present disclosure, the electronic device (100) can identify the target of a request related to a shortcut key input. The electronic device (100) can identify the target of the request based on the position of an indicator when the shortcut key is input. The indicator may include, but is not limited to, a mouse cursor or a keyboard cursor. For example, when a shortcut key is input, the electronic device (100) can identify the target of the request according to a predetermined rule based on the position of the indicator.

[0180] In one embodiment of the present disclosure, for example, when a shortcut key is input, the electronic device (100) can identify the target of the request corresponding to the start portion of the code if the indicator indicates the start portion of the code. For example, when a shortcut key is input at the very beginning of a function, a code block including multiple lines of code for implementing the function may be the target of the request.

[0181] In one embodiment of the present disclosure, for example, when a shortcut key is input, the electronic device (100) can identify the target of a request corresponding to the middle portion of the code if the indicator indicates the middle portion. For example, if a shortcut key input is obtained in the middle portion of a function (e.g., when a portion of code is input), a line of code indicated by the indicator may be the target of the request.

[0182] In one embodiment of the present disclosure, the electronic device (100) may proceed to operation S220 after identifying the target of the request. The electronic device (100) according to one embodiment of the present disclosure may generate a first prompt based on the target of the request and context information. For example, the electronic device (100) may generate a first prompt including the target of the request and context information.

[0183] In one embodiment of the present disclosure, operation S210 does not necessarily have to include operations S1410 and S1420 of FIG. 14, and may omit at least some of S1410 and S1420 or include some additional steps.

[0184] FIG. 15 is a flowchart illustrating steps for obtaining context information according to one embodiment of the present disclosure. The flowchart of FIG. 15 includes detailed operations of operation S220 of FIG. 2 according to one embodiment of the present disclosure.

[0185] Referring to FIG. 15, in one embodiment of the present disclosure, operation S220 may include operations S1510, S1520, and S1530.

[0186] In operation S1510, the method may include an operation of acquiring at least one of codes or comments included in the target document. For example, the electronic device (100) may acquire at least one of codes or comments included in the target document. In one embodiment of the present disclosure, the context information may include information included in the target document. That is, the electronic device (100) may acquire context information including at least one of codes or comments included in the target document.

[0187] In operation S1520, the method may obtain at least one of the codes or comments included in the reference document. For example, the electronic device (100) may obtain at least one of the codes or comments included in the reference document that can be used for code generation. In one embodiment of the present disclosure, the context information may include at least one of the codes or comments included in the reference document. That is, the electronic device (100) may obtain context information including at least one of the codes or comments included in the reference document.

[0188] In one embodiment of the present disclosure, the reference document may include, but is not limited to, at least one of a document loaded into an integrated development environment such as a target document, a document referenced by the target document among one or more documents included in a project including the target document, a package or library referenced by the target document, or an Application Programming Interface (API) document referenced by the target document.

[0189] In operation S1530, the method may obtain at least one of codes or comments included in a document written by another user. For example, the electronic device (100) may obtain at least one of codes or comments included in a document written by another user within a group including the user of the target document. In one embodiment of the present disclosure, context information may include, but is not limited to, at least one of codes or comments included in a document written by another user within a group including the user of the target document. For example, the electronic device (100) may identify a group including the user of the target document, and obtain context information including at least one of codes or comments included in a document written by a member of the group. That is, the electronic device (100) may obtain context information including at least one of codes or comments included in a document written by another user within a group including the user of the target document.

[0190] In one embodiment of the present disclosure, operation S220 does not necessarily include operations S1510 to S1530 of FIG. 15, and may omit at least some of S1510 to S1530 or include some additional steps. In addition, the order of operations S1510 to S1530 may be changed.

[0191] FIG. 16 is a flowchart illustrating steps for generating a summarized prompt according to one embodiment of the present disclosure. The flowchart of FIG. 12 includes detailed operations of operations S240 and S250 of FIG. 2 according to one embodiment of the present disclosure.

[0192] Referring to FIG. 16, in one embodiment of the present disclosure, operation S240 may include operation S1610 and operation S1620.

[0193] In operation S1610, the method may include an operation of determining a priority among pieces of information included in the context information. For example, the electronic device (100) may determine a priority among pieces of information included in the context information. The electronic device (100) may determine the priority according to a rule-based procedure. That is, the electronic device (100) may determine a priority among pieces of information included in the context information based on a predetermined rule. The electronic device (100) may select information to be summarized with priority based on the priority information.

[0194] In operation S1620, the method may include an operation of selecting context information to be summarized with priority based on priority information. For example, the electronic device (100) may select context information to be summarized with priority based on priority information. In one embodiment of the present disclosure, the electronic device (100) may select context information with a higher priority first. In one embodiment of the present disclosure, the electronic device (100) may not select some context information with a lower priority.

[0195] In one embodiment of the present disclosure, operation S250 may include operations S1630 and S1640.

[0196] In operation S1630, the method may include generating a second prompt by summarizing context information with a higher priority first. For example, the electronic device (100) may generate the second prompt by summarizing context information with a higher priority first. In one embodiment of the present disclosure, the electronic device (100) may generate the second prompt by summarizing context information with a higher priority first until the length of the second prompt becomes shorter than a threshold value. For example, the electronic device (100) may generate the second prompt by summarizing first context information with a first priority, and summarize the second context information by summarizing second context information with a second priority lower than the first priority. The electronic device (100) may sequentially summarize context information from high priority to low priority context information. The electronic device (100) may repeat summarizing the context information. For example, the electronic device (100) may repeatedly perform a low-level summary instead of a high-level summary from the beginning. The electronic device (100) may stop summarizing based on the length of the prompt becoming shorter than a threshold value.

[0197] In one embodiment of the present disclosure, the electronic device (100) can generate a second prompt using a generative AI model. For example, the electronic device (100) can request a summary of the first prompt from the generative AI model to generate a summarized second prompt. The generative AI model can be operated by the electronic device (100) or a server connected to the electronic device (100). The electronic device (100) can generate the second prompt by transmitting the first prompt or at least one of the context information selected in operation S240 to the server and receiving the summarized result through the generative AI model of the server.

[0198] In operation S1640, the method may include an operation of deleting high-priority context information. For example, the electronic device (100) may generate a second prompt by deleting high-priority context information first. In one embodiment of the present disclosure, the electronic device (100) may generate a second prompt by deleting high-priority context information first, if the length of the summarized second prompt is longer than a threshold value, for example. According to one embodiment of the present disclosure, the electronic device (100) may delete the context information after performing a summary of the context information. For example, the electronic device (100) may delete the context information if the length of the prompt is longer than the threshold value despite the summary of the selected context information. In one embodiment of the present disclosure, the electronic device (100) may delete the context information without performing a summary of the context information. For example, the electronic device (100) may generate a second prompt by deleting the context information based on the priority information without performing a summary.

[0199] In one embodiment of the present disclosure, operation S240 does not necessarily include operations S1610 and S1620 of FIG. 16 . Furthermore, operation S250 does not necessarily include operations S1630 and S1640 of FIG. 16 . At least some of operations S1610 to S1640 may be omitted or some additional steps may be included. Furthermore, the order of operations S1630 and S1640 may be changed.

[0200] A system for providing code using a generative artificial intelligence model by an electronic device (100) according to one embodiment of the present disclosure is described with reference to FIGS. 17a, 17b, and 17c.

[0201] FIG. 17a is a diagram illustrating a system for providing code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0202] In one embodiment of the present disclosure, the electronic device (100) can provide various services that provide code using a generative AI model.

[0203] Referring to FIG. 17A, in one embodiment of the present disclosure, an electronic device (100) may perform a service (1710) for generating code. For example, the electronic device (100) may generate a prompt based on a user input requesting the generation of a predetermined code. The electronic device (100) may input the generated prompt into a generative AI model to obtain a response including code written in a programming language. The electronic device (100) may generate a code based on conditions included in the user input.

[0204] In one embodiment of the present disclosure, an electronic device (100) may perform a code translation service (1720). For example, the electronic device (100) may generate a prompt based on a user input requesting that code written in the "Python" programming language be translated into code written in the "C" programming language. The electronic device (100) may input the generated prompt into a generative AI model to obtain a response including code translated into another programming language.

[0205] FIG. 17b is a diagram illustrating a system that provides code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0206] Referring to FIG. 17B , in one embodiment of the present disclosure, the electronic device (100) may perform a service (1730) that generates text describing code. For example, the electronic device (100) may generate a prompt based on a user input requesting the generation of text describing code written in a programming language. The electronic device (100) may input the generated prompt into a generative AI model to obtain a response including text describing the code.

[0207] FIG. 17c is a diagram illustrating a system for providing code using a generative artificial intelligence model according to one embodiment of the present disclosure.

[0208] Referring to FIG. 17c, in one embodiment of the present disclosure, the electronic device (100) may perform a service (1740) that generates a docstring for code. For example, the electronic device (100) may generate a prompt based on a user input requesting the generation of a docstring for code written in a programming language. The electronic device (100) may input the generated prompt into a generative AI model to obtain a response including text describing the code.

[0209] In one embodiment of the present disclosure, an electronic device (100) may perform a service (1750) for refactoring code. For example, the electronic device (100) may generate a prompt based on a user input requesting refactoring of written code. The electronic device (100) may input the generated prompt into a generative AI model to obtain a response including newly written code that performs the same function.

[0210] In one embodiment of the present disclosure, an electronic device (100) can perform a service (1720) for correcting errors in code. For example, the electronic device (100) can generate a prompt based on a user input requesting correction of a bug in the code. The electronic device (100) can input the generated prompt into a generative AI model to obtain a response including the corrected code.

[0211] FIG. 18 is a block diagram illustrating a configuration of an electronic device according to one embodiment of the present disclosure.

[0212] In one embodiment of the present disclosure, an electronic device (100) may include a processor (1810), a memory (1820), and a communication interface (1830).

[0213] The processor (1810) can control the overall operations of the electronic device (100). For example, the processor (1810) can control the overall operations of the electronic device (100) to provide personalized code by executing one or more instructions of a program stored in the memory (1820). There may be one or more processors (1810).

[0214] The processor (1810) may be configured with at least one of, but is not limited to, a central processing unit, a microprocessor, a graphic processing unit, an application specific integrated circuits (ASICs), a digital signal processor (DSPs), a digital signal processing device (DSPDs), a programmable logic device (PLDs), a field programmable gate array (FPGAs), an application processor, a neural processing unit, or an artificial intelligence processor designed with a hardware structure specialized for processing an artificial intelligence model.

[0215] The processor (1810) may execute the code information extraction module (1822) to obtain context information from a target document or a reference document. For example, the processor (1810) may execute the code information extraction module (1822) to obtain context information including at least one of code or comments included in the target document and code or comments included in a reference document stored in the memory (1820). Since the description related to the operations of the code information extraction module (1822) has already been described in the description of the previous drawings, a repeated description will be omitted.

[0216] The processor (1810) may execute the code information retrieval module (1824) to obtain context information from a document or reference document written by another user. For example, the processor (1810) may execute the code information retrieval module (1824) to obtain context information including at least one of code or comment included in a document written by another user or code or comment included in an external reference document referenced using a network. Since a description related to the operations of the code information retrieval module (1824) has already been described in the description of the previous drawings, a repeated description will be omitted.

[0217] The processor (1810) may execute the combination module (1826) to generate a first prompt based on context information. Since the operations of the combination module (1826) have already been described in the description of the previous drawings, a repetitive description will be omitted.

[0218] The processor (2240) may execute the summary module (1828) to generate a second prompt that summarizes the first prompt. Since the operations of the summary module (1828) have already been described in the description of the previous drawings, a repeated description will be omitted.

[0219] Meanwhile, the modules stored in the aforementioned memory (1820) are provided for convenience of explanation and are not necessarily limited thereto. To implement the aforementioned embodiments, other modules may be added (e.g., a generative AI module), and some modules may be omitted (e.g., a summary module). Furthermore, a single module may be divided into multiple modules with distinct functions, and some of the aforementioned modules may be combined to be implemented as a single module.

[0220] In one embodiment of the present disclosure, the electronic device (100) may further include additional components to perform the operations described in the above-described embodiments. For example, the electronic device (100) may further include a display, a camera, a microphone, a speaker, an input / output interface, and the like. The display may output a video signal to the screen of the electronic device (100) under the control of the processor (1810).

[0221] In one embodiment of the present disclosure, the method may include a plurality of operations, and the plurality of operations may be performed by one processor or by multiple processors. For example, when a first operation, a second operation, and a third operation are performed by the method according to one embodiment, the first operation, the second operation, and the third operation may all be performed by the first processor, or the first and second operations may be performed by the first processor (e.g., a general-purpose processor) and the third operation may be performed by the second processor (e.g., an AI-specific processor). Here, the AI-specific processor, which is an example of the second processor, may perform operations for training / inference of an AI model. However, the embodiments of the present disclosure are not limited thereto.

[0222] One or more processors according to the present disclosure may be implemented as a single-core processor or as a multi-core processor.

[0223] When a method according to one embodiment of the present disclosure includes multiple operations, the multiple operations may be performed by one core or may be performed by multiple cores included in one or more processors.

[0224] The memory (1820) may store instructions, data structures, and program codes that can be read by the processor (1810). Operations performed by the processor (1810) may be implemented by executing instructions or codes of a program stored in the memory (1820).

[0225] The memory (1820) may include a flash memory type, a hard disk type, a multimedia card micro type, a card type memory (e.g., SD or XD memory, etc.), and may include a non-volatile memory including at least one of a ROM (Read-Only Memory), an EEPROM (Electrically Erasable Programmable Read-Only Memory), a PROM (Programmable Read-Only Memory), a magnetic memory, a magnetic disk, and an optical disk, and a volatile memory such as a RAM (Random Access Memory) or an SRAM (Static Random Access Memory).

[0226] The memory (1820) may store one or more instructions and / or programs that cause the electronic device (100) to operate to provide code. For example, the memory (1820) may store instructions and / or programs for implementing the functions of the code information extraction module (1822), the code information retrieval module (1824), the combination module (1826), and the summary module (1828). Meanwhile, the memory (1820) may further store instructions and / or programs for implementing the functions of the prompt generation module.

[0227] The communication interface (1830) can perform data communication with other electronic devices under the control of the processor (1810).

[0228] The communication interface (1830) may include a communication circuit that can perform data communication between the electronic device (100) and another electronic device (e.g., a server (110)) using at least one of data communication methods including, for example, wired LAN, wireless LAN, Wi-Fi, Bluetooth, ZigBee, Wi-Fi Direct (WFD), infrared Data Association (IrDA), Bluetooth Low Energy (BLE), Near Field Communication (NFC), Wireless Broadband Internet (Wibro), World Interoperability for Microwave Access (WiMAX), Shared Wireless Access Protocol (SWAP), Wireless Gigabit Alliances (WiGig), and RF communication.

[0229] The communication interface (1830) can transmit and receive prompts regarding a generative artificial intelligence model and code information corresponding to the prompts to and from the server (110). For example, the communication interface (1830) can transmit prompts to the server (110) and receive code information from the server (110).

[0230] In one embodiment of the present disclosure, the electronic device (100) may not include a communication interface (1830). The electronic device (100) may provide code information corresponding to a prompt using a generative artificial intelligence model included in the electronic device (100), without using a generative artificial intelligence model of an external electronic device (e.g., a server (110)).

[0231] FIG. 19 is a block diagram illustrating the configuration of a server according to one embodiment of the present disclosure.

[0232] In one embodiment of the present disclosure, the server (110) may include a processor (1910), a memory (1920), and a communication interface (1930). The server (110) may be a high-performance computing device, higher than the electronic device (100), capable of processing complex operations and tasks using large amounts of data, such as training, inference, management, and distribution of generative AI models.

[0233] The processor (1910) can control the overall operations of the server (110). For example, the processor (1910) can control the overall operations of the server (110) to generate personalized code by executing one or more instructions of a program stored in the memory (1920). There may be one or more processors (1910).

[0234] The processor (1910) may be configured as at least one of, but is not limited to, a central processing unit, a microprocessor, a graphic processing unit, an application specific integrated circuits (ASICs), a digital signal processor (DSPs), a digital signal processing device (DSPDs), a programmable logic device (PLDs), a field programmable gate array (FPGAs), an application processor, a neural processing unit, or an artificial intelligence processor designed with a hardware structure specialized for processing an artificial intelligence model.

[0235] The processor (1910) can generate code by executing a generative language model (1925). The processor (1910) can generate code corresponding to a prompt using the generative language model (1925). In one embodiment of the present disclosure, the processor (1910) can summarize a prompt by executing the generative language model (1925). The processor (1910) can input a prompt obtained through a communication interface (1930) into the generative language model (1925) to generate a summarized prompt.

[0236] The memory (1920) may store instructions, data structures, and program codes that can be read by the processor (1910). Operations performed by the processor (1910) may be implemented by executing instructions or codes of a program stored in the memory (1920).

[0237] The memory (1920) may include a flash memory type, a hard disk type, a multimedia card micro type, a card type memory (e.g., SD or XD memory, etc.), and may include a non-volatile memory including at least one of a ROM (Read-Only Memory), an EEPROM (Electrically Erasable Programmable Read-Only Memory), a PROM (Programmable Read-Only Memory), a magnetic memory, a magnetic disk, and an optical disk, and a volatile memory such as a RAM (Random Access Memory) or a SRAM (Static Random Access Memory).

[0238] The memory (1920) may store one or more instructions and / or programs that cause the server (110) to operate to generate personalized code. For example, the memory (1920) may store instructions and / or programs for implementing the functions of a generative language module (1925). The generative language module (1925) may include a generative AI model.

[0239] The communication interface (1930) can perform data communication with other electronic devices under the control of the processor (1910).

[0240] The communication interface (1930) may include a communication circuit that can perform data communication between the server (110) and another electronic device (e.g., the electronic device (100)) using at least one of data communication methods including, for example, wired LAN, wireless LAN, Wi-Fi, Bluetooth, ZigBee, Wi-Fi Direct (WFD), infrared Data Association (IrDA), Bluetooth Low Energy (BLE), Near Field Communication (NFC), Wireless Broadband Internet (Wibro), World Interoperability for Microwave Access (WiMAX), Shared Wireless Access Protocol (SWAP), Wireless Gigabit Alliances (WiGig), and RF communication.

[0241] The communication interface (1930) can transmit and receive data to and from the electronic device (100) to provide a code. For example, the communication interface (1930) can receive a prompt from the electronic device (100) and transmit a personalized code to the electronic device (100).

[0242] The present disclosure relates to a method, electronic device, and server for generating and providing code using a generative artificial intelligence model. Furthermore, the present disclosure relates to a method for generating prompts input into a generative AI model for providing code. The technical challenges addressed by the present disclosure are not limited to those described above, and other technical challenges not mentioned herein will be readily apparent to those skilled in the art, based on the description herein.

[0243] The information referenced for code generation can dynamically change depending on the situation. For example, if the library used for code generation changes, the information referenced for code generation may also change. Generative AI models have difficulty generating results using information generated after the learning stage or information personally created by the user. Therefore, by providing a prompt containing contextual information to the generative AI model, a response tailored to the user's intent can be obtained. In this case, the cost and time for additional learning can be saved. However, the length of the prompt is limited depending on the generative AI. Therefore, the length of the prompt cannot exceed a threshold. An electronic device (100) according to an embodiment of the present disclosure can generate a prompt shorter than the threshold and containing contextual information. Furthermore, an electronic device (100) according to an embodiment of the present disclosure can obtain an efficient and reliable response from a generative AI model by determining the priority summarized in the prompt based on the importance of the information. The technical effects of the present disclosure are not limited to those mentioned above, and other technical effects not mentioned will be clearly understood by a person skilled in the art to which the present invention pertains from the description of this specification.

[0244] In one embodiment of the present disclosure, a method for providing a code using a generative artificial intelligence model is provided. The method may include obtaining user input corresponding to a first document. The method may include obtaining first context information usable for code generation based on the user input. The method may include generating a first prompt for code generation based on the first context information and the user input. The method may include selecting second context information from among the first context information according to priority information based on the length of the first prompt. The method may include generating a second prompt corresponding to the first prompt based on the second context information and the user input. The method may include transmitting the first prompt or the second prompt to a server. The method may include receiving and providing a recommendation code generated by the generative artificial intelligence model based on the first prompt or the second prompt from the server.

[0245] In one embodiment of the present disclosure, the first context information may include at least one of a first code or a first comment included in a first document, at least one of a second code or a second comment included in a reference document available for code generation, or at least one of a third code or a third comment included in a second document created by a second user within a group including the first user of the first document.

[0246] In one embodiment of the present disclosure, the reference document may include at least one of a document loaded into an integrated development environment such as a target document, a document referenced by the first document among one or more documents included in a project including the first document, a package or library referenced by the first document, or an API document referenced by the first document.

[0247] In one embodiment of the present disclosure, the user input may include a user input modifying code in a first document. The step of obtaining the first context information may include a step of obtaining the first context information based on whether additional user input is not obtained for a predetermined period of time after the user input.

[0248] In one embodiment of the present disclosure, the user input may include a request for generating code included in a first document. The step of obtaining first context information may include a step of obtaining first context information based on the user input. The step of generating a first prompt may include a step of generating a first prompt including the request included in the user input.

[0249] In one embodiment of the present disclosure, the step of generating the second prompt may include transmitting at least one of the first prompt, the first context information, or the user input to the server or another server. The step of generating the second prompt may include obtaining the summarized second prompt through a generative artificial intelligence model of the server or another server.

[0250] In one embodiment of the present disclosure, the step of selecting the second context information may include the step of determining priority information regarding the priority of each piece of information included in the first context information. The step of generating the second prompt may include the step of selecting context information to be summarized preferentially from among the first context information based on the priority information. The step of generating the second prompt may include the step of generating the second prompt by summarizing context information with a higher priority until the length of the second prompt becomes shorter than a threshold value.

[0251] In one embodiment of the present disclosure, the step of generating the second prompt may include the step of generating the second prompt by deleting high-priority context information based on a length of the summarized second prompt being longer than a threshold value.

[0252] In one embodiment of the present disclosure, the step of obtaining first context information may include the step of determining target context information available for code generation based on at least one of user input or a first document. The step of obtaining first context information may include the step of obtaining the determined target context information from the first document or a reference document.

[0253] In one embodiment of the present disclosure, priority information may include at least one of an order of context information to be processed with priority when summarization is performed and context information for which summarization is not performed.

[0254] In one embodiment of the present disclosure, an electronic device is provided that provides code using a generative artificial intelligence model. The electronic device may include at least one processor including a processing circuit, and a memory including one or more storage media storing at least one instruction. The at least one instruction may be individually or collectively executed by the at least one processor to enable the electronic device to obtain user input corresponding to a first document. The at least one instruction may be individually or collectively executed by the at least one processor to enable the electronic device to obtain first context information usable for code generation based on the user input. The at least one instruction may be individually or collectively executed by the at least one processor to enable the electronic device to generate a first prompt for code generation based on the first context information and the user input. The at least one instruction may be individually or collectively executed by the at least one processor to enable the electronic device to select second context information from among the first context information based on a length threshold of the first prompt and priority information. At least one of the instructions may be individually or collectively executed by at least one processor to cause the electronic device to generate a second prompt corresponding to the first prompt based on second context information and user input. At least one of the instructions may be individually or collectively executed by at least one processor to cause the electronic device to transmit the first prompt or the second prompt to a server. At least one of the instructions may be individually or collectively executed by at least one processor to cause the electronic device to receive and provide a recommendation code generated by a generative artificial intelligence model based on the first prompt or the second prompt from the server.

[0255] In one embodiment of the present disclosure, the first context information may include at least one of a first code or a first comment included in a first document, at least one of a second code or a second comment included in a reference document available for code generation, or at least one of a third code or a third comment included in a second document created by a second user within a group including the first user of the first document.

[0256] In one embodiment of the present disclosure, the reference document may include at least one of a document loaded into an integrated development environment such as a target document, a document referenced by the first document among one or more documents included in a project including the first document, a package or library referenced by the first document, or an API document referenced by the first document.

[0257] In one embodiment of the present disclosure, the user input may include a user input that modifies code in a first document. At least one of the instructions may be individually or collectively executed by at least one processor so that the electronic device may acquire first context information based on whether additional user input has been obtained for a predetermined period of time following the user input.

[0258] In one embodiment of the present disclosure, the user input includes a request for code generation included in a first document, and at least one of the instructions is individually or collectively executed by at least one processor so that the electronic device can obtain first context information based on obtaining the user input. The at least one of the instructions is individually or collectively executed by at least one processor so that the electronic device can generate a first prompt including the request included in the user input.

[0259] In one embodiment of the present disclosure, at least one of the instructions may be individually or collectively executed by at least one processor to cause the electronic device to transmit at least one of a first prompt, first context information, or user input to a server or another server. At least one of the instructions may be individually or collectively executed by at least one processor to cause the electronic device to obtain a second prompt summarized by a generative artificial intelligence model of the server or another server.

[0260] In one embodiment of the present disclosure, at least one instruction may be individually or collectively executed by at least one processor so that the electronic device can determine priority information regarding the priority of each piece of information included in the first context information. At least one instruction may be individually or collectively executed by at least one processor so that the electronic device can select context information to be summarized first among the first context information based on the priority information. At least one instruction may be individually or collectively executed by at least one processor so that the electronic device can generate the second prompt by summarizing context information with a higher priority first until the length of the second prompt becomes shorter than a threshold value.

[0261] In one embodiment of the present disclosure, at least one instruction is individually or collectively executed by at least one processor to cause the electronic device to generate a second prompt by deleting high priority context information based on a length of the summarized second prompt being longer than a threshold value.

[0262] In one embodiment of the present disclosure, at least one instruction is executed individually or collectively by at least one processor to enable an electronic device to determine target context information available for code generation based on at least one of user input or a first document. At least one instruction is executed individually or collectively by at least one processor to enable the electronic device to obtain target context information from a target document or a reference document.

[0263] In one embodiment of the present disclosure, priority information may include at least one of an order of context information to be processed with priority when summarization is performed and context information for which summarization is not performed.

[0264] In one embodiment of the present disclosure, a computer-readable recording medium having recorded thereon a computer program for executing the above-described method on a computer is provided.

[0265] In one embodiment of the present disclosure, the device-readable storage medium may be provided in the form of a non-transitory storage medium. Here, the term "non-transitory storage medium" simply means a tangible device that does not contain signals (e.g., electromagnetic waves), and this term does not distinguish between cases where data is stored semi-permanently and cases where data is stored temporarily. For example, a "non-transitory storage medium" may include a buffer in which data is temporarily stored.

[0266] According to one embodiment, the method according to various embodiments disclosed in the present document may be provided as included in a computer program product. The computer program product may be traded as a product between a seller and a buyer. The computer program product may be distributed in the form of a machine-readable storage medium (e.g., compact disc read-only memory (CD-ROM)), or may be distributed online (e.g., downloaded or uploaded) through an application store or directly between two user devices (e.g., smartphones). In the case of online distribution, at least a portion of the computer program product (e.g., a downloadable app) may be temporarily stored or temporarily generated in a machine-readable storage medium, such as the memory of a manufacturer's server, an application store's server, or an intermediary server.< / filename> < / filename> < / end> < / context>

Claims

1. A method for providing code using a generative artificial intelligence model, Step (S210) of obtaining user input corresponding to the first document; Step (S220) of obtaining first context information available for code generation based on the above user input; A step (S230) of generating a first prompt for code generation based on the first context information and the user input; A step (S240) of selecting second context information from among the first context information according to priority information based on the length of the first prompt; A step (S250) of generating a second prompt corresponding to the first prompt based on the second context information and the user input; Step (S260) of transmitting the first prompt or the second prompt to the server; and A method comprising a step (S270) of receiving and providing a recommendation code generated through a generative artificial intelligence model based on the first prompt or the second prompt from the server.

2. In the first paragraph, the first context information is At least one of the first code or the first comment included in the first document, At least one of the second code or second comment included in the reference documentation available for generating the above code, or A method characterized in that it includes at least one of a third code or a third comment included in a second document written by a second user within a group including the first user of the first document.

3. In paragraph 2, the reference document A document loaded into an Integrated Development Environment (IDE) such as the above first document, One or more documents included in the project including the above first document, and which are referenced by the above first document, The package or library referenced in the above first document, or A method comprising at least one of the API (Application Programming Interface) documents referenced by the first document.

4. In any one of paragraphs 1 to 3, The above user input includes user input that modifies code in the first document, The step (S220) of obtaining the first context information is as follows: A method comprising the step of obtaining the first context information based on no additional user input being obtained for a set time after the user input.

5. In any one of paragraphs 1 to 4, The above user input includes a request for code generation contained in the first document, The step (S220) of obtaining the first context information is as follows: A step of obtaining the first context information based on obtaining the user input is included, The step (S230) of generating the first prompt is: A method comprising the step of generating a first prompt including a request included in said user input.

6. In any one of paragraphs 1 to 5, The step (S250) of generating the second prompt is: transmitting at least one of the first prompt, the first context information or the user input to the server or another server; and A method comprising the step of obtaining a second prompt summarized through a generative artificial intelligence model of said server or said other server.

7. In any one of paragraphs 1 to 6, the step (S240) of selecting the second context information is: A step of determining priority information regarding the priority of each piece of information included in the first context information; A step of selecting context information to be summarized first among the first context information based on the priority information, The step (S250) of generating the second prompt is: A method comprising the step of generating the second prompt by summarizing high priority context information from the beginning until the length of the second prompt becomes shorter than a threshold value.

8. In paragraph 7, The step (S250) of generating the second prompt is: A method comprising the step of generating the second prompt by deleting the high priority context information based on the length of the summarized second prompt being longer than the threshold value.

9. In any one of paragraphs 1 to 8, The step (S220) of obtaining the first context information is determining target context information available for code generation based on at least one of the user input or the first document; and A method comprising the step of obtaining the determined target context information from the first document or reference document.

10. In any one of paragraphs 1 to 9, A method wherein the priority information includes at least one of an order of context information to be processed with priority when summarization is performed and context information for which summarization is not performed.

11. In an electronic device that provides code using a generative artificial intelligence model, At least one processor (1810) comprising a processing circuit; and A memory (1820) including one or more storage media storing at least one instruction, wherein the at least one instruction is individually or collectively executed by the at least one processor so that the electronic device, Obtain user input corresponding to the first document, Based on the above user input, first context information available for code generation is obtained, Based on the first context information and the user input, a first prompt for code generation is generated, The length of the first prompt is based on a threshold value, and the second context information is selected from the first context information based on priority information. Generate a second prompt corresponding to the first prompt based on the second context information and the user input, Transmitting the first prompt or the second prompt to the server, An electronic device that receives and provides a recommendation code generated through a generative artificial intelligence model based on the first prompt or the second prompt from the server.

12. In paragraph 11, the first context information is At least one of the first code or the first comment included in the first document, At least one of the second code or second comment included in the reference documentation available for generating the above code, or An electronic device characterized in that it includes at least one of a third code or a third comment included in a second document written by a second user within a group including the first user of the first document.

13. In paragraph 12, the reference document A document loaded into an Integrated Development Environment (IDE) such as the above first document, One or more documents included in the project including the above first document, and which are referenced by the above first document, The package or library referenced in the above first document, or An electronic device comprising at least one of the API (Application Programming Interface) documents referenced by the first document.

14. In any one of paragraphs 11 to 13, The above user input includes user input that modifies code in the first document, The at least one processor executes the one or more instructions, An electronic device that acquires the first context information based on no additional user input being acquired for a set period of time after the user input.

15. A computer-readable recording medium having recorded thereon a computer program for executing the method of any one of clauses 1 to 10 on a computer.

Citation Information

Patent Citations

  • Code generation method and apparatus

    CN116719520B

  • Code generation and compiling deployment method, platform and equipment based on AI large model

    CN117008923A

  • Code query method and device

    CN117033422A

  • External reinforcing means for pressure sensing element for detecting the risk corresponding to internal defect or reducing of thickness for heating pipe

    KR102629184B1

  • Systems and methods for a conversational framework of program synthesis

    US20230280985A1