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

By using a generative AI model to generate appropriate prompts during the code generation process by leveraging contextual information and priority selection, the problem of poor code generation quality and efficiency in existing technologies is solved, achieving more efficient and accurate code generation.

CN121620749APending Publication Date: 2026-03-06SAMSUNG ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202480051066.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2023-12-04
Filing Date
2024-09-25
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

Existing generative AI models struggle to effectively utilize contextual information during code generation, resulting in poor code quality and efficiency.

Method used

By using a generative AI model, prompts are generated based on user input and contextual information. Appropriate contextual information is selected and summarized according to priority information to generate the final prompt, thereby improving the accuracy and efficiency of code generation.

Benefits of technology

It improves the accuracy and efficiency of code generation, ensures that the generated code is more in line with user needs, reduces unnecessary information redundancy, and enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121620749A_ABST
    Figure CN121620749A_ABST
Patent Text Reader

Abstract

An electronic device for providing a code by using a generative artificial intelligence model and a method implemented by the electronic device are provided. The method may include the steps of: obtaining a user input corresponding to a first document; obtaining first context information capable of being used for code generation based on user input; generating a first prompt for code generation based on the first context information and the user input; selecting second context information from the first context information according to the priority information based on the length of the first prompt; generating a second prompt corresponding to the first prompt based on the second context information and the user input; sending the first prompt or the second prompt to a server; and receiving, from the server, a recommendation code generated based on the first prompt or the second prompt via the generative AI model, and providing the recommendation code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to a method and electronic device for using a generative artificial intelligence (AI) model. More specifically, this disclosure relates to a method and electronic device for providing code by using a generative AI model. Background Technology

[0002] Generative artificial intelligence (AI) is a technique that learns the structure and patterns of large-scale data based on input data and generates new synthetic data. Such generative AI produces human-level results in various tasks involving text, images, speech, video, music, and more. For example, generative language models refer to techniques capable of performing various natural language processing tasks. Generative language models (as generative AI models for text) generate response text to user queries. Generative language models can include large language models (LLMs).

[0003] Recently, generative AI has been widely applied in technologies such as search functionality, chatbots, and code generation. Summary of the Invention

[0004] Technical solution According to embodiments of this disclosure, a method for providing code using a generative artificial intelligence (AI) 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 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: sending the first prompt or the second prompt to a server. The method may include: receiving recommended code generated by the generative AI model based on the first prompt or the second prompt from the server, and providing the recommended code.

[0005] According to embodiments of this disclosure, an electronic device is provided for providing code using a generative artificial intelligence (AI) model. The electronic device may include: at least one processor, including processing circuitry; and a memory, including one or more storage media storing at least one instruction. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to obtain user input corresponding to a first document. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to obtain first context information capable of being used for code generation based on the user input. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to generate a first prompt for code generation based on the first context information and the user input. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to select second context information from the first context information based on priority information according to the length of the first prompt. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to generate a second prompt corresponding to the first prompt based on the second context information and the user input. When the at least one instruction is executed individually or jointly by the at least one processor, the electronic device sends the first prompt or the second prompt to the server. When the at least one instruction is executed individually or jointly by the at least one processor, the electronic device receives and provides recommended code generated by a generative AI model based on the first prompt or the second prompt from the server.

[0006] According to embodiments of this disclosure, a computer-readable recording medium has a computer program recorded thereon, which performs the above-described method when executed by a computer. Attached Figure Description

[0007] Figure 1 This is a diagram illustrating a system for providing code using a generative artificial intelligence (AI) model, according to embodiments of the present disclosure.

[0008] Figure 2 This is a flowchart of a method for providing code using a generative AI model, according to embodiments of the present disclosure.

[0009] Figure 3a This is a diagram illustrating a hint about a generative AI model according to embodiments of the present disclosure.

[0010] Figure 3b This is a diagram illustrating a hint about a generative AI model according to embodiments of the present disclosure.

[0011] Figure 4 This is an illustration used to explain the user interface for providing code using a generative AI model according to embodiments of the present disclosure.

[0012] Figure 5 This is a block diagram of a system for providing code using a generative AI model, according to embodiments of the present disclosure.

[0013] Figure 6 This is a diagram illustrating the process of extracting code information according to embodiments of the present disclosure.

[0014] Figure 7 This is a diagram illustrating the process of searching for code information according to embodiments of the present disclosure.

[0015] Figure 8 This is a block diagram illustrating the process of interpreting combined context information according to embodiments of the present disclosure.

[0016] Figure 9 This is a block diagram for explaining the process of summarizing the suggestions according to embodiments of the present disclosure.

[0017] Figure 10 This is a view for explaining the process of summarizing prompts using a generative language model according to embodiments of the present disclosure.

[0018] Figure 11 This is a view illustrating prompts provided by a generative AI model according to embodiments of this disclosure.

[0019] Figure 12 This is a flowchart of the operation of obtaining user input according to an embodiment of the present disclosure.

[0020] Figure 13 This is a view illustrating prompts provided by a generative AI model according to embodiments of this disclosure.

[0021] Figure 14 This is a flowchart of the operation of obtaining user input according to an embodiment of the present disclosure.

[0022] Figure 15 This is a flowchart of the operation of obtaining context information according to embodiments of the present disclosure.

[0023] Figure 16 This is a flowchart of the operation for generating a summary prompt according to embodiments of the present disclosure.

[0024] Figure 17a This is a diagram illustrating a system for providing code using a generative AI model, according to embodiments of the present disclosure.

[0025] Figure 17bThis is a diagram illustrating a system for providing code using a generative AI model, according to embodiments of the present disclosure.

[0026] Figure 17c This is a diagram illustrating a system for providing code using a generative AI model, according to embodiments of the present disclosure.

[0027] Figure 18 This is a block diagram of the structure of an electronic device according to an embodiment of the present disclosure.

[0028] Figure 19 This is a block diagram illustrating the structure of a server according to an embodiment of the present disclosure. Detailed Implementation

[0029] This document describes embodiments of the present disclosure in detail with reference to the accompanying drawings, enabling those skilled in the art to readily implement the disclosure. However, the present disclosure may be implemented in many different forms and should not be construed as limited to the embodiments set forth herein. Embodiments of the present disclosure will now be described more fully with reference to the accompanying drawings.

[0030] Throughout the disclosure, the expression "at least one of a, b, or c" indicates only a, only b, only c, both a and b, both a and c, both b and c, all of a, b, and c, or variations thereof.

[0031] Although commonly used terms have been chosen to describe this disclosure in consideration of its functionality, these terms may vary depending on the intent of a person skilled in the art, precedent, the emergence of new technologies, etc. Terms arbitrarily chosen by the applicant of this disclosure may also be used in specific circumstances. In such cases, their meaning may be understood through their description. Therefore, terms must be defined based on their meaning and the entirety of the specification, rather than simply by stating the terms.

[0032] Unless they have a distinctly different meaning in the context, singular expressions may include plural expressions. While terms such as "first" and "second" may be used to describe various components, these components are not necessarily limited to the terms mentioned above. The terms mentioned above are only used to distinguish one component from another.

[0033] When used in this specification, the terms "comprising" and / or "including" specify the presence of the said element, but do not exclude the presence or addition of one or more other elements. When used in this specification, the terms "unit," "device," and "module" may refer to a unit that performs at least one function or operation.

[0034] Depending on the context, the expression "configured as (or set to)" as used herein may be used interchangeably with, for example, "suitable for," "capable of," "designed for," "suitable for," "manufactured as," or "capable of." The expression "configured as (or set to)" may not necessarily mean "specifically designed for" in terms of hardware. Conversely, in some cases, the expression "system configured as" may refer to a situation where the system, together with another device or component, is "capable of." Depending on the context, the expression "module performs" as used herein may be used interchangeably with "module is configured to perform."

[0035] In example cases where an element (e.g., a first element) is “coupled to” or “connected to” another element (e.g., a second element), the first element may be directly coupled to or connected to the second element, or a third element may exist between them unless otherwise stated.

[0036] According to one or more embodiments of this disclosure, a module "sending" or "delivering" data may direct data provision to another module. A module may be connected to other modules via wired or wireless means. A module may provide data directly to another module, or may provide data to other modules via another module.

[0037] According to one or more embodiments of this disclosure, descriptions of techniques well-known in the art and not directly related to this disclosure may be omitted. This is to clearly convey the spirit of this disclosure by omitting any unnecessary explanations. In the drawings, for the sake of simplicity, parts unrelated to the description are omitted, and the same reference numerals refer to the same elements. Furthermore, the reference numerals used in each drawing are only used to describe that drawing, and different reference numerals used in different drawings do not indicate different elements. The actual dimensions of the individual elements are not necessarily shown in the drawings. In the drawings, the same elements or corresponding elements are represented by the same reference numerals.

[0038] The advantages and features of this disclosure, as well as methods of achieving these advantages and features, will become apparent from the embodiments described in detail below with reference to the accompanying drawings. However, this is not intended to limit this disclosure to a particular mode of practice, and all changes, equivalents, and substitutions without departing from the spirit and scope of the disclosure are included herein. These embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of this disclosure to those skilled in the art. Embodiments of this disclosure may be defined according to the claims.

[0039] According to one or more embodiments of this disclosure, each block and combination of blocks shown in the flowchart can be implemented by computer program instructions. The computer program instructions can be provided to a processor of a general-purpose computer, a processor of a special-purpose computer, or a processor of another programmable data processing apparatus, and the instructions, which execute via the processor of the computer or the processor of the other programmable data processing apparatus, can generate means for performing the functions specified in the flowchart blocks. The computer program instructions can also be stored in a computer-usable memory or computer-readable storage medium that can instruct a computer or other programmable data processing apparatus to function in a particular manner, and the instructions stored in the computer-usable memory or computer-readable storage medium can generate an article of writing including instruction means for performing the functions specified in the flowchart blocks. The computer program instructions can be mounted on a computer or other programmable data processing apparatus.

[0040] According to one or more embodiments of this disclosure, each block of the flowchart may represent a module, segment, or portion of code comprising one or more executable instructions for implementing a specified logical function. According to embodiments of this disclosure, the functions mentioned in the blocks may also occur out of order. For example, two blocks shown consecutively may actually be executed substantially simultaneously, or may be executed in reverse order according to their functions.

[0041] According to one or more embodiments of this disclosure, the terms "unit," "module," or "...device(or)" as used herein may refer to a hardware element (such as a field-programmable gate array (FPGA) or application-specific integrated circuit (ASIC)) that performs a specific function. "Unit" or "...device" may not be limited to hardware. The term "unit" or "...device" may be configured to be included in an addressable storage medium or to reproduce one or more processors. According to embodiments of this disclosure, as an example, the term "unit" or "...device" may include object-oriented software components, class components, and task components, as well as processes, functions, attributes, programs, subroutines, program code segments, drivers, firmware, microcode, circuits, data, databases, data structures, tables, arrays, and variables. The functionality provided by a particular component or a particular "...unit" may be combined to reduce its number or may be divided into additional components. According to embodiments of this disclosure, a "unit" or "...device" may include one or more processors.

[0042] Figure 1 This is a diagram illustrating a system for providing code using a generative artificial intelligence (AI) model, according to embodiments of the present disclosure.

[0043] According to embodiments of this disclosure, electronic device 100 and server 110 can provide a code recommendation service to user 120, wherein the code recommendation service provides code using a generative AI model. The code recommendation service according to this disclosure can provide recommended code related to code that user 120 is writing or intends to modify. For example, the code recommendation service can allow user 120 to input information related to recommended code that the user desires.

[0044] According to one or more embodiments of this disclosure, "generative AI" may include AI techniques that generate new text, images, etc., in response to input data (e.g., text and images). According to embodiments of this disclosure, generative AI may generate output data corresponding to a user request based on input data including such a request.

[0045] According to one or more embodiments of this disclosure, a "generative AI model" may include an AI model (e.g., a neural network model) that implements generative AI techniques. A generative AI model can generate new data with similar characteristics to or corresponding to the input data by learning patterns and structures from training data. For example, a generative AI model may generate images using image-to-image or text-to-image methods. However, this disclosure is not limited thereto, and therefore, a generative AI model may include various expressions representing the same / similar concepts. For example, a 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 embodiments of this disclosure, electronic device 100 can obtain user input for code generation. For example, user input may include signals or input data for code generation input by user 120 to electronic device 100.

[0047] According to one or more embodiments of this disclosure, "user input" may include input data entered by a user into an electronic device. According to embodiments of this disclosure, user input may include input signals obtained through an input / output device of the electronic device. For example, the electronic device may obtain user input signals for generating codes through an input device. Input devices may include, but are not limited to, a keyboard or a microphone. However, this disclosure is not limited thereto, and therefore, user input may include various expressions representing the same / similar concepts. For example, user input may be referred to as input data or input signals, and is not limited to the examples described above.

[0048] Reference Figure 1The first interface 130 displays code written by user 120 into electronic device 100. Electronic device 100 can provide recommended code related to the code included in the first interface 130, as shown in the second interface 140. For example, user 120 may be writing code for a function "fib" with "n" as a variable, as shown in the first interface 130. Electronic device 100 can provide recommended code for the function "fib" with "n" as a variable, as shown in the first interface 140. For example, electronic device 100 can determine the purpose, intent, and / or function of a function based on its name and variables, and can generate and provide code related to the function's operations. For example, electronic device 100 can provide code related to the function's operations by displaying recommended code on a display. Electronic device 100 can determine the purpose of function "fib(n)" as calculating the value of a Fibonacci sequence based on an integer n, and can generate code related to the operations of function "fib(n)". According to one or more embodiments of this disclosure, the code that is the target of the recommended code of the electronic device 100 may be referred to as the target code. For example, "def fib(n)" is the target code of the electronic device 100, and the electronic device 100 can provide a recommended code corresponding to the target code.

[0049] Electronic device 100 can obtain contextual information for generating code. Contextual information may include code related to the target document. For example, contextual information may include code or comments included in the target document, as well as code related to a document (such as the target document) currently being written in an integrated development environment (IDE). For example, electronic device 100 may recognize the comment "#Fibonacci sequence" on the first interface 130 as contextual information.

[0050] According to one or more embodiments of this disclosure, "contextual information" may include background information that can be referenced for performing a generative AI model. According to embodiments of this disclosure, contextual information may include descriptions or related information about data generated by the generative AI model. However, this disclosure is not limited thereto, and therefore, contextual information may include various expressions representing the same / similar concepts. For example, contextual information may include, but is not limited to, background, conditions, or environment.

[0051] The electronic device 100 can generate prompts for a generative AI model using contextual information. The prompts may include information for code generation. The generative AI model can receive the prompts and output code corresponding to them.

[0052] According to one or more embodiments of this disclosure, a "prompt" may include input data for a generative AI model. According to embodiments of this disclosure, a prompt may include input data for initiating interaction with the generative AI model. The prompt may include text input, wherein the text input includes one or more words and / or one or more sentences. According to embodiments of this disclosure, the prompt may include natural language text. Natural language text may include various information that the generative AI model can use to generate a response to a request. For example, the prompt may include at least one of contextual information, intent information, task information, or constraint information. However, this disclosure is not limited thereto, and therefore, the prompt may include various expressions representing the same / similar concepts. For example, the prompt may include, but is not limited to, "input," "input phrase," "user command," "instruction," "command," "task query," "trigger statement," or "message," and is not limited thereto.

[0053] According to embodiments of this disclosure, electronic device 100 may summarize a prompt based on its length. For example, electronic device 100 may summarize a prompt when it is longer than a threshold. For example, electronic device 100 may summarize a prompt based on determining that it is longer than a threshold. Electronic device 100 may summarize information included in a prompt based on priority information. For example, electronic device 100 may correct at least a portion of the information included in a prompt to be shorter, or may delete a portion of the information. According to embodiments of this disclosure, a prompt that is not summarized may be referred to as a first prompt, and a prompt that is summarized may be referred to as a second prompt.

[0054] As used herein, "threshold" can refer to an upper limit on the length of a prompt. According to embodiments of this disclosure, in example cases where the length of a prompt exceeds the threshold, the generative AI model may not generate output data or may generate inaccurate output data. According to embodiments of this disclosure, the length of a prompt can be determined in units of tokens. A token can represent the smallest unit of a string whose meaning the generative AI model can understand. According to embodiments of this disclosure, the length of the string constituting a token may not be constant. However, this disclosure is not limited to this, and therefore, the threshold can include various expressions representing the same / similar concepts. For example, the threshold may include, but is not limited to, a maximum value, a maximum threshold level, or a predetermined value.

[0055] According to embodiments of this disclosure, electronic device 100 can send a prompt to server 110. Server 110 can generate code corresponding to the prompt using a generative AI model. Electronic device 100 can receive information about the code from server 110 and provide the code using the received information.

[0056] According to embodiments of this disclosure, electronic device 100 can be any of a variety of devices that provide personalized codes for tasks performed by user 120. For example, electronic device 100 can be implemented using electronic devices of various types and shapes, each including a display. Electronic device 100 may include, but is not limited to, devices capable of displaying codes via a display, such as smart TVs, smartphones, tablet PCs, laptop PCs, glasses displays, and head-mounted displays (HMDs).

[0057] According to embodiments of this disclosure, electronic device 100 can be implemented using various types and shapes of electronic devices, each capable of being connected to a display via wired or wireless means. For example, electronic device 100 may include, but is not limited to, devices capable of displaying code via a display via wired or wireless means, such as set-top boxes and desktop PCs.

[0058] According to embodiments of this disclosure, server 110 may be an apparatus for generating code using a generative AI model. Server 110 may be an apparatus capable of handling complex computations and tasks using large-scale data, such as the training, inference, management, and distribution of generative AI models. According to embodiments of this disclosure, training of the generative AI model executed on server 110 may be performed by another computing device. Server 110 may receive prompts for code generation from electronic device 100, which is a client device, and may send information about the generated code to electronic device 100.

[0059] According to embodiments of this disclosure, the electronic device 100 and server 110 providing code recommendation services may be referred to as a "code recommendation system". Optionally, for ease of explanation, the electronic device 100 and server 110 may be simply referred to as the "system". According to embodiments of this disclosure, embodiments in which code is generated by the code recommendation system and provided to users will be described. However, the operation of this disclosure is not necessarily performed by the code recommendation system.

[0060] According to embodiments of this disclosure, the operation of providing code can be performed independently by electronic device 100. In this case, a generative AI model that generates code by using prompts can be stored in electronic device 100. Electronic device 100 can generate code by performing operations according to this disclosure using the generative AI model. According to embodiments, electronic device 100 has relatively low computing performance compared to server 110, and therefore, the generative AI model used by electronic device 100 can be a lightweight AI model to suit the computing performance of electronic device 100.

[0061] According to embodiments of this disclosure, the operation of providing code can be performed independently by server 110. In this case, server 110 may simply receive a code generation request from electronic device 100, generate code by performing the operations according to this disclosure, and return the generation result to electronic device 100.

[0062] According to embodiments of this disclosure, electronic device 100 may include a server. For example, external device 100 may include a server providing cloud computing services. In other words, electronic device 100 may perform operations, programs, and / or functions upon request from another electronic device (e.g., a client device), and may send the results of the operations, programs, and / or functions to the other electronic device and display the results of the operations, programs, and / or functions. For example, electronic device 100 may perform operations provided with code according to this disclosure, and may display the code on the display of another electronic device.

[0063] According to embodiments of this disclosure, the operation provided by the code can be executed separately by multiple electronic devices. For example, in the operation according to this disclosure, "operation A" can be executed by "electronic device A", and "operation B" can be executed by "electronic device B". Because examples of various implementations of this disclosure (such as the examples above) are obvious, descriptions will be omitted in this disclosure for the sake of brevity.

[0064] The detailed operation of the user 120-based input recommendation code performed by the electronic device 10 will be described in more detail with reference to the accompanying drawings and descriptions, which will be described later.

[0065] Figure 2 This is a flowchart of a method for providing code using a generative AI model, according to embodiments of the present disclosure.

[0066] Reference Figure 2 A brief description is given of the operations performed by the electronic device 100 that provide codes, and a detailed description of each operation will be given with reference to the following figures.

[0067] In operation S210, the method may include obtaining user input corresponding to a first document. For example, electronic device 100 may obtain user input for code generation included in a target document. According to embodiments of this disclosure, the target document may include a document containing generated code. According to embodiments of this disclosure, the user input may include at least one of input to correct code in the target document or a request regarding code in the target document. (Refer to...) Figure 4 , Figure 5 , Figure 12 and Figure 14 The present disclosure describes in detail the operation of obtaining user input performed by an electronic device according to embodiments of the present disclosure.

[0068] In operation S220, the method may include obtaining first contextual information for code generation based on user input. For example, electronic device 100 may obtain contextual information that can be used for code generation based on user input.

[0069] According to embodiments of this disclosure, contextual information may include, but is not limited to, at least one of the following: information included in the target document, information included in the reference document, or information included in a document written by another user in a group that includes the user of the target document. Information included in the document may include code or comments.

[0070] According to embodiments of this disclosure, code may include text written in a programming language to cause an electronic device to perform specific operations. According to embodiments of this disclosure, annotations may refer to text included in a document that does not affect the operation of the electronic device. For example, annotations may be included in a document to aid in understanding the code. For example, annotations may include text describing the operation of the code in human language rather than a programming language.

[0071] According to embodiments of this disclosure, a reference document may include a document referenced by code in the target document. In an example where code in the target document references code written in another document, the other document including the referenced code may be referred to as a reference document.

[0072] According to embodiments of this disclosure, electronic device 100 can determine contextual information that can be used for code generation based on at least one of user input or a target document. Electronic device 100 can obtain the determined contextual 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, electronic device 100 may generate a first prompt for code generation based on context information and user input. According to embodiments of this disclosure, the first prompt may include at least one of context information or user input. (Refer to...) Figure 8 and Figures 8 to 14 A first hint is given in detail regarding embodiments according to this disclosure.

[0074] In operation S240, the method may include selecting second context information from first context information based on priority information. For example, based on the fact that the length of the first prompt is greater than a threshold, the electronic device 100 may select information from the context information to generate a second prompt summarizing the first prompt based on the priority information. In the example case where the length of the first prompt is greater than the threshold, the electronic device 100 may select information from the context information to generate the second prompt. For example, in response to determining that the length of the first prompt is greater than the threshold, the electronic device 100 may select information from the context information to generate the second prompt.

[0075] According to embodiments of this disclosure, priority information may include information about the order of context information. For example, priority information may include at least one of the following: the order of context information that is prioritized during summary processing or context information that is not summarized. For example, a portion of the context information of the 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 embodiments, priority information may indicate setting priorities based on the importance of context information. For example, as the importance of context information decreases, the priority may be set higher. In this case, priority may include the order of summarizing multiple pieces of context information. Priority may include information about context information that is not summarized. According to embodiments of this disclosure, priority may be referred to as, but is not limited to, summary order.

[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, electronic device 100 may generate a second prompt that summarizes the first prompt based on selected context information and user input. According to embodiments of this disclosure, in operation S250, electronic device 100 may summarize or delete the selected context information.

[0077] According to embodiments of this disclosure, electronic device 100 can generate a second prompt by summarizing or deleting at least a portion of the contextual information included in the first prompt. According to embodiments of this disclosure, electronic device 100 can generate a second prompt from the first prompt using a generative AI model.

[0078] In operation S260, the method may include sending a first prompt or a second prompt. For example, electronic device 100 may send the first prompt or the second prompt to a server. For example, the server may be a device that includes a generative AI model for code generation.

[0079] In operation S270, the method may include receiving a recommended code generated using a generative AI model based on a first prompt or a second prompt. For example, electronic device 100 may receive and provide the code generated by the generative AI model based on the first prompt or the second prompt from a server. For example, the server may input the first prompt or the second prompt into the generative AI model to generate the code. Electronic device 100 may provide the code generated by the generative AI model via a display.

[0080] According to embodiments of this disclosure, the method of providing code does not necessarily include operations S210 to S270. At least some of operations S210 to S270 may be omitted, or some operations may be further included.

[0081] Figure 3a This is a diagram illustrating a hint about a generative AI model according to embodiments of the present disclosure.

[0082] Hints refer to information provided to a generative AI model so that the model can obtain the answer the user wants. The generative AI model can then generate a response based on the information included in the hints.

[0083] According to embodiments of this disclosure, the prompt may include a role. For example, the prompt may include text associated with a role of generative AI (e.g., a Q&A chatbot), such as “I am an AI programming assistant.” The role of the generative AI can be set to various roles, such as a prompt engineer, etc. However, the embodiments are not limited thereto.

[0084] According to embodiments of this disclosure, the prompt may include a task. The task may include information associated with the goal of the generative AI. For example, the prompt may include text associated with the generative AI task, such as, "If a user asks about code or technical issues, I provide code suggestions and follow technical information." The generative AI task can be set up as various tasks, such as a prompt summary, etc. However, embodiments of this disclosure are not limited thereto.

[0085] According to embodiments of this disclosure, the prompt may include constraints. Constraints may include specific requests for responses from the generative AI model. For example, the prompt may include text associated with constraints on the generative AI, such as, "If the question category is not relevant to the code or technical field, I will answer with 'Unknown'." Constraints on the generative AI can be set to various constraints, such as limitations on the length or complexity of the response. However, embodiments of this disclosure are not limited thereto.

[0086] According to embodiments of this disclosure, prompts may include examples. Examples may include example information associated with a user request. For example, a prompt may include text associated with an example of generative AI operation, such as, “Q: What is Docker? A: Docker is a platform for developers and system administrators to build, ship, and run distributed applications.” For example, a prompt may include text associated with an example of constraints on generative AI, such as, “Q: How many people live in South Korea? A: Unknown.”

[0087] According to embodiments of this disclosure, a prompt may include a request. A user request may include information about a query requesting a response from a generative AI model. For example, a prompt may include text associated with a user request for generative AI, such as, “Q: What is dropout?”.

[0088] According to embodiments of this disclosure, generative AI models can provide responses to prompts. For example, a generative AI model can generate response text to a user request, such as "Dropout is a regularization technique used to prevent overfitting in deep learning."

[0089] Figure 3a The prompts shown only include text written in human language. However, embodiments of this disclosure are not limited to this, and the prompts may include various types of natural language. For example, as will be referred to later... Figure 3b The description, or hints, may include text written in a programming language.

[0090] Figure 3b This is a diagram illustrating a hint about a generative AI model according to embodiments of the present disclosure.

[0091] According to embodiments of this disclosure, the prompt may include a task. For example, the prompt may include text associated with a user request for generative AI, such as "Translate Python code into C++:". The generative AI model according to embodiments of this disclosure changing code written in a first programming language to code written in a second programming language can be referred to as a translation function.

[0092] According to embodiments of this disclosure, the prompt may include examples. For example, the prompt may include text associated with an example of an operation in generative AI, such as, "Python: print("hello world") C++: cout<<"hello world\n";". In other words, the prompt may include an example of how the Python code "print("hello world")" can be translated into the C++ language "cout<<"helloworld\n";".

[0093] According to embodiments of this disclosure, a prompt may include a request. For example, a prompt may include text associated with a user request for generative AI, such as "Python: name=input() C++:". In other words, a prompt may include a user request that translates the Python code "name=input()" into C++. According to embodiments of this 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;" to the user request.

[0094] However, this disclosure is not limited thereto, and therefore, the indication is not limited to the references above. Figure 3a and Figure 3b The information described may be omitted or may include additional information.

[0095] Figure 4This is an illustration used to explain the user interface for providing code using a generative AI model according to embodiments of the present disclosure.

[0096] Figure 4 A user interface (UI) providing code according to an embodiment of the present disclosure is shown. 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 or a third UI 420 displaying chat. The UI may be displayed via a display of the electronic device 100, but embodiments of the present disclosure are not limited thereto. The UI may be displayed via various types of electronic devices including a display.

[0097] According to embodiments of this disclosure, the first UI 400 may represent an integrated development environment (IDE). An IDE may refer to a program or service where users write code. The first UI 400 may include, for example, a target document, a project including the target document, and other documents included in the project. For example, the first UI 400 may include the target document "fib.py", the project "test_project" including the target document, and another document "main.py" included in the project.

[0098] According to embodiments of this disclosure, the second UI 410 can display via Figure 5 The input obtained from the code input interface. The third UI 420 can display the input obtained through... Figure 5 The input obtained from the chat input interface. According to embodiments of this disclosure, the code input interface may include an interface for obtaining input about code. According to embodiments of this disclosure, the chat input interface may include an interface for obtaining input about the chat. Referring later... Figure 5 The code input interface and chat input interface according to embodiments of the present disclosure are described.

[0099] According to embodiments of this disclosure, the second UI 410 may include a region representing code in the target document. According to embodiments of this disclosure, the second UI 410 may display written code. For example, the second UI 410 may include text about defining a function for a Fibonacci sequence. "#Fibonacci sequence" may refer to a comment included in the target document, and "def fib(n):" may refer to code defining a function with a variable "n" and a function name "fib".

[0100] According to embodiments of this disclosure, the second UI 410 can display recommended code generated based on written code or annotations. A generative AI model can be used to generate recommended code based on written code or annotations. For example, recommended code can be generated using at least some of the written code "def fib(n)" or "#Fibonacci sequence". The recommended code can be a block of code comprising multiple lines of code for function operations. For example, refer to... Figure 4 Recommended code may include blocks of code written in 6 lines.

[0101] According to embodiments of this disclosure, the second UI 410 may display recommended codes generated based on chat input. For example, recommended codes may be generated using chat input displayed on the third UI 420. The third UI 420 may display interactions including requests and responses between the user and the electronic device 100. The request may refer to input from the user requesting a specific action from the electronic device 100. For example, the request may include the text "Generate code to output a Fibonacci sequence for the nth integer". The response may refer to the output of the electronic device 100 in response to the request. For example, the response may include the text "I have generated the code based on your request. Do you have any additional requests?" For example, the response may include the output displaying recommended codes on the second UI 410. Generative AI models may be used to generate recommended codes based on chat input.

[0102] Figure 5 This is a block diagram of a system for providing code using a generative AI model, according to embodiments of the present disclosure.

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

[0104] According to embodiments of the present disclosure, I / O device 510 may include a keyboard. The keyboard may include an input device comprising a plurality of keys. The keyboard may generate a signal from pressure applied to each key. The keyboard may send a signal associated with a key that has been pressed to an electronic device. According to embodiments of the present disclosure, I / O device 510 may be a component included in electronic device 100 or a special device connected to electronic device 100.

[0105] According to embodiments of this disclosure, system 500 can obtain input signals using I / O device 510. The input signals may correspond to user input. I / O device 510 can send the input signals to input interface 520. According to embodiments of this disclosure, input interface 520 can obtain input signals from I / O device 510. Input interface 520 may include at least one of a code input interface, a chat input interface, or a shortcut key input interface.

[0106] According to embodiments of this disclosure, the code input interface may receive user input for writing or correcting code. For example, the code input interface may receive user input for adding, deleting, or modifying code. For instance, user input for adding code may include user input for adding characters. Characters may include regular characters (such as the alphabet), 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 modifying code may include user input for removing at least a portion of the written code and entering new characters.

[0107] According to embodiments of this disclosure, the chat input interface can receive user input including requests for code generation. For example, as referred to above... Figure 4 The user input may include a request to generate specific code. The chat input interface may receive user input when the chat service is executed or while the chat service is being executed. The chat input interface can be executed using predetermined keyboard shortcuts or using another input device (e.g., a mouse).

[0108] According to embodiments of this disclosure, the shortcut key input interface can receive user input including shortcut key input for code generation. For example, the shortcut key input interface can receive user input regarding a predetermined shortcut key or combination of shortcut keys. The shortcut key can be set to any key other than a correction character key or a combination of keys other than a correction character key.

[0109] Input interface 520 may send user input to prompt generation module 530 based on obtained user input. For example, input interface 520 may send user input to prompt generation module 530 in response to obtained user input. According to embodiments of the present disclosure, prompt generation module 530 may include a context information acquisition module and a prompt processing module. According to embodiments of the present disclosure, input interface 520 may send user input to at least one of the context information acquisition module or the prompt processing module of prompt generation module 530. According to embodiments of the present disclosure, prompt generation module 530 may be implemented by a program or instructions stored in the memory of electronic device 100 executed by the processor of electronic device 100. According to embodiments of the present disclosure, operations or processes described as performed by prompt generation module 530 may be understood as being performed by processor of electronic device 100. For example, processor of electronic device 100 may execute at least one of prompt generation module 530, context information acquisition module, code information search module, code information extraction module, prompt processing module, combination module, or summary module. However, embodiments of the present disclosure are not limited thereto, and prompt generation module 530 may be executed by processor of server 110. According to embodiments of this disclosure, the detailed components or modules included in the prompt generation module 530 can be considered as software units that perform specific functions or roles throughout the prompt generation process based on user input.

[0110] According to embodiments of this disclosure, the context information acquisition module may include a code information search module and / or a code information extraction module.

[0111] According to embodiments of this disclosure, the code information search module can obtain context information from a database. For example, the code information search module can search and obtain context information from an external network. According to embodiments of this disclosure, the database may not be included in the context information acquisition module. For example, the database may be located outside the electronic device 100. (Refer to...) Figure 7 Describe in detail the process of obtaining context information and the types of context information.

[0112] According to embodiments of this disclosure, the code information extraction module can obtain context information from memory. For example, the code information extraction module can extract multiple pieces of context information from the integrated development environment associated with the target document. (See also...) Figure 6 Describe in detail the process of extracting context information and the types of context information.

[0113] According to embodiments of this disclosure, the context information acquisition module can send context information to the prompt processing module. The prompt processing module may include a combination module and a summary module.

[0114] According to embodiments of this disclosure, the combining module can generate a prompt based on obtained context information. For example, a prompt can be generated by merging or concatenating context information. The prompt may include at least one of context information, user input, or target code. In an example case where the prompt generated by the combining module is longer than a threshold, the combining module may send the prompt to the summarizing module. In an example case where the prompt generated by the combining module is shorter than a threshold, the combining module may not send the prompt to the summarizing module, but may instead determine the final prompt. Referring later... Figure 8 The process of combining prompts according to embodiments of the present disclosure will be described in more detail.

[0115] According to embodiments of this disclosure, the summarizing module can summarize the prompt. The summarizing module can summarize the prompt according to predetermined rules. The summarizing module can summarize some contextual information from multiple contextual information items included in the prompt. The summarizing module can determine the priority corresponding to the multiple contextual information items included in the prompt, and summarize the contextual information according to the priority information. For example, each contextual information item included in the prompt can be assigned a priority, and the summarizing module summarizes the contextual information based on the priority assigned to each contextual information item. The summarizing module can delete some contextual information items from the multiple contextual information items included in the prompt.

[0116] According to embodiments of this disclosure, the summarization module can summarize contextual information using the AI ​​module 540. For example, the summarization module can send prompts or selected contextual information to an external server and can receive prompts or contextual information summarized using a generative AI model.

[0117] According to embodiments of this disclosure, AI module 540 may include a generative AI model. AI module 540 can generate code using prompts. AI module 540 can generate code corresponding to user input by using prompts as input.

[0118] According to embodiments of this disclosure, electronic device 100 may include at least one of I / O device 510, input interface 520, prompt generation module 530, or AI module 540. However, embodiments of this disclosure are not limited thereto, and some of I / O device 510, input interface 520, prompt creation module 530, or AI module 540 may be implemented by another electronic device 100.

[0119] Figure 6 This is a diagram illustrating the process of extracting code information according to embodiments of the present disclosure.

[0120] According to embodiments of this disclosure, electronic device 100 can obtain context information. Electronic device 100 can obtain context information from a target document or reference document by executing a code information extraction module. Electronic device 100 can obtain context information from code or comments included in the target document or reference document.

[0121] According to embodiments of this disclosure, electronic device 100 can obtain contextual information from a target document. Electronic device 100 can obtain contextual information based on indicators (e.g., mouse cursor or keyboard cursor). Electronic device 100 can obtain contextual information including code or comments preceding the indicator. Electronic device 100 can obtain contextual information including code or comments following the indicator.

[0122] According to embodiments of this disclosure, electronic device 100 can obtain context information from an open document. Electronic device 100 can identify documents opened in an integrated development environment (IDE). For example, electronic device 100 can obtain a list of open documents through an IDE application programming interface (API). Electronic device 100 can obtain context information from the identified open documents. (See also...) Figure 6 The electronic device 100 can obtain contextual data including code or comments, which are included in the files "main.py", "snake.py" and / or "requirements.txt" that are made available to the integrated development environment.

[0123] According to embodiments of this disclosure, electronic device 100 can obtain contextual information from reference documents (such as target documents) included in a project. (See also...) Figure 6 The target document "snake.py" is included in the same project "TEST_PROJECT" along with "main.py" and "requirements.txt". The electronic device 100 can obtain contextual data including the code or comments of "main.py" and "requirements.txt" included in the same project along with the target document "snake.py".

[0124] According to embodiments of this disclosure, electronic device 100 can obtain context information from relevant documents. Relevant documents may refer to documents containing packages, libraries, tasks, and / or instructions required to perform a project. For example, relevant documents may include "Requirement," "Makefile," and "Dockerfile." See also... Figure 6 The relevant documentation may include "requirements.txt". The electronic device 100 can obtain contextual information including code or comments corresponding to packages, libraries, and / or API functions included in the relevant documentation.

[0125] According to embodiments of this disclosure, electronic device 100 can obtain contextual information from a document referenced by the target document. For example, electronic device 100 can obtain contextual information about code or comments included in a document referenced by the target document via "import" or "include".

[0126] According to embodiments of this disclosure, electronic device 100 can obtain all code or comments included in a target document as context information. According to embodiments of this disclosure, electronic device 100 can obtain some information representing code or comments included in a target document as context information. In example cases where the amount of code information included in the document is large, electronic device 100 can obtain only some of the information included in the document as context information. For example, when the amount of code information included in the document is greater than a reference value, electronic device 100 can obtain context information based only 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. Electronic device 100 can obtain docstrings associated with the code included in the document as context data. Docstrings may include comments associated with module, function, class, or method definitions included in the code. Electronic device 100 can obtain function signatures as context information. Function signatures may include a list of parameters specified in the function.

[0127] Figure 7 This is a diagram illustrating the process of searching for code information according to embodiments of the present disclosure.

[0128] According to embodiments of this disclosure, electronic device 100 can obtain context information. Electronic device 100 can obtain context information from a reference document by executing a code information search module. Electronic device 100 can obtain context information from code or comments included in the reference document.

[0129] According to embodiments of this disclosure, electronic device 100 can recognize codes representing reference documents. (Refer to...) Figure 7 The code "response=requests.get('https: / / api.smartthings.com / v1 / locations',headers=headers)" included in the target documentation can refer to the code that invokes the reference documentation. In other words, the API documentation corresponding to the internet address "https: / / api.smartthings.com / v1 / locations" can be the target documentation. API documentation can include functionality, parameters, functions, and / or sample code.

[0130] According to embodiments of this disclosure, electronic device 100 can obtain reference documents via an index representing reference documents included in code. The index may represent predefined code (e.g., a library or package). Electronic device 100 can obtain reference documents corresponding to the index. For example, electronic device 100 can obtain reference documents corresponding to the index by using a search engine.

[0131] According to embodiments of this disclosure, electronic device 100 can obtain contextual information from a document written by another user within an organization that includes the user. Electronic device 100 can identify the organization that includes the user. Electronic device 100 can identify whether there is code (or document) similar to or identical to the target code (or target document) in code (or document) written by other users included in the organization. For example, electronic device 100 can search for functions with titles similar to or identical to the function. Electronic device 100 can obtain contextual information including code similar to or identical to the target code.

[0132] Electronic device 100 can obtain reference documents. For example, electronic device 100 can obtain a reference document, including at least one of code or comments, as context information via a reference path included in the target document. Electronic device 100 can obtain at least some of the code or comments included in the reference document. According to embodiments of this disclosure, electronic device 100 can obtain all the code or comments included in the reference document as context information. According to embodiments of this disclosure, electronic device 100 can obtain some information representing the code or comments included in the reference document as context information.

[0133] Figure 8 This is a block diagram illustrating the process of interpreting combined context information according to embodiments of the present disclosure.

[0134] According to embodiments of this disclosure, electronic device 100 can generate a prompt 840 including contextual information. For example, the contextual information may include first contextual information 810, second contextual information 820, and third contextual information 830. Electronic device 100 can execute combination module 1826 to generate the prompt. The first contextual information 810, second contextual information 820, and third contextual information 830 can be obtained by electronic device 100 using a code information extraction module or a code information search module. The contextual information may include code or comments.

[0135] According to embodiments of this disclosure, electronic device 100 can generate prompt 840 by merging or connecting first context information 810, second context information 820 and third context information 830.

[0136] According to embodiments of this disclosure, electronic device 100 may merge first context information 810, second context information 820, and third context information 830 based on priority information. For example, refer to... Figure 8 The prompt 840 may include first context information 810, third context information 830, and second context information 820 in the mentioned order. According to embodiments of this disclosure, electronic device 100 may align first context information 810, second context information 820, and third context information 830 based on priority information. For example, electronic device 100 may include high-priority context information positioned in a first-to-last order. However, embodiments of this disclosure are not limited thereto, and electronic device 100 may include low-priority context information in a first-to-last order. Priority may be determined based on the importance of the context information. Priority may be determined in the reverse order of 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 be the most important and its priority may be determined to be low. Electronic device 100 may determine low-priority context information as important information and may not summarize or delete low-priority context information.

[0137] According to embodiments of this disclosure, electronic device 100 can generate a prompt 840 by merging the first context information 810, the second context information 820, and the third context information 830 without aligning them. For example, the prompt may include context information in an order of acquisition separate from priority information.

[0138] According to embodiments of this disclosure, electronic device 100 can generate prompts that include user input. For example, electronic device 100 can generate prompts that include chat input. See below for further details. Figure 13 A more detailed description is provided of prompts including chat input according to embodiments of the present disclosure.

[0139] Figure 9 This is a block diagram for explaining the process of summarizing the suggestions according to embodiments of the present disclosure.

[0140] According to embodiments of this disclosure, 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. Electronic device 100 may execute a summary module 1828 to summarize the first prompt 940. For ease of description, a prompt not summarized by summary module 1828 is referred to as a first prompt, and a prompt summarized by summary module 1828 is referred to as a second prompt.

[0141] According to embodiments of this disclosure, electronic device 100 can generate a second prompt 945, wherein the second prompt 945 is a summary of the first prompt 940. Electronic device 100 can summarize or delete at least some of the first context information 910, second context information 920, and third context information 930 of the first prompt 940. At least some of the first context information 915, second context information 925, and third context information 935 of the second prompt 945 can be a summary of the first context information 910, second context information 920, and third context information 930 of the first prompt 940. For example, the context information can be summarized to include important information such as the name of a function, its parameters, and its output.

[0142] According to embodiments of this disclosure, electronic device 100 may summarize prompts to include the same contextual information without redundancy. In an example where some contextual information among the multiple pieces of contextual information included in the first prompt 940 is repeated, electronic device 100 may delete some contextual information to prevent repetition.

[0143] According to embodiments of this disclosure, electronic device 100 can generate a second prompt 945 without summarizing or deleting some contextual information from the first prompt 940. For example, highly important contextual information may require the original contextual information not to be summarized. Electronic device 100 can generate the second prompt 945 without summarizing or deleting code or comments in the target document. For example, electronic device 100 may not summarize or delete code corresponding to an indicator (e.g., code or comments located before or after the indicator).

[0144] According to embodiments of this disclosure, the electronic device 100 can repeatedly perform a summary until the length of the summary prompt becomes less than a threshold. The electronic device 100 can identify the length of the prompt before the summary is performed, and perform the summary based on the prompt length being greater than the threshold.

[0145] Figure 10 This is a view for explaining the process of summarizing prompts using a generative language model according to embodiments of the present disclosure.

[0146] According to embodiments of this disclosure, electronic device 100 can summarize prompts using generative language model 1030. Generative language model 1030 may be stored in electronic device 100 or in a server connected to electronic device 100.

[0147] According to embodiments of this disclosure, the generative language model 1030 can generate summarized contextual information 1040 by inputting prompts including contextual information 1010 and a request 1020. For example, the contextual information 1010 may include code or comments.

[0148] According to embodiments of this disclosure, request 1020 may include a task performed by the generative language model to summarize. For example, request 1020 may include the task "summarize using function signature and docstring". Generative language model 1030 may generate context information 1040 for the summary from context information 1010 based on request 1020. For example, the context information 1040 for the summary may include a function name "merge_sort" and a parameter "arr", and a docstring associated with the function's operation, wherein the function name "merge_sort" and the parameter "arr" are function signatures included in context information 1010.

[0149] According to embodiments of this disclosure, electronic device 100 may select some context information from the prompted context information and input the selected context information into a generative language model. According to embodiments of this disclosure, electronic device 100 may input all context information into a generative language model without selecting some of the prompted context information. According to embodiments of this disclosure, request 1020 may include context information to be summarized.

[0150] According to embodiments of this disclosure, electronic device 100 can summarize various natural languages, as well as codes or annotations, by using a generative language model.

[0151] Figure 11 This is a view illustrating prompts provided by a generative AI model according to embodiments of this disclosure.

[0152] According to embodiments of this disclosure, in Figure 11 The text shows a prompt to correct the code based on user input or keyboard shortcuts.

[0153] According to embodiments of this disclosure, the prompt may include contextual information. Contextual information may include at least one of the following: the target document, a reference document, code or comments included in another document within the same project and / or an external document.

[0154] Hints can include code from referenced documentation as contextual information. (Refer to...) Figure 11 Included <context>and <end>The information in between can refer to contextual information. Contextual information can include the location of the referenced document, the code in the referenced document, and / or the comments in the referenced document. The location of the referenced document can refer to the path where the referenced document is stored. For example, "src / calculator.java" can represent the location (and name) of the referenced document.

[0155] According to embodiments of this disclosure, the prompt may include request information. The request information may include the location of the target document and / or target code. See also... Figure 11 Included <filename>The following information may refer to the request information.

[0156] According to embodiments of this disclosure, target code can be determined based on user input. For example, target code may refer to code associated with previous user input. In an example where previous user input is associated with 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] According to embodiments of this disclosure, target code can be determined based on indicators included in the user interface. For example, target code can be determined as code indicated by the position of the keyboard cursor in the user interface. In the example case where the keyboard cursor in the user interface is located at the beginning, middle, or end of "Public static void main(String[]args){", the target code can be code associated with "Public static void main(String[]args){".

[0158] According to embodiments of the present disclosure, electronic device 100 may generate prompts including user input. According to embodiments of the present disclosure, electronic device 100 may generate a prompt in response to a predetermined time elapsed since the last time user input was received. According to embodiments of the present disclosure, electronic device 100 may generate a prompt in response to receiving shortcut key input.

[0159] Figure 12 This is a flowchart of the operation of obtaining user input according to an embodiment of the present disclosure. Figure 12 The flowchart includes embodiments according to this disclosure. Figure 2 Detailed operation of S210.

[0160] Reference Figure 12 According to embodiments of the present disclosure, operation S210 may include operation S1210 and operation S1220.

[0161] In operation S1210, the method may include recognizing user input for correcting code. For example, electronic device 100 may recognize user input for correcting code. For example, electronic device 100 may obtain input signals for correcting information about the code via I / O devices. According to embodiments of this disclosure, user input may include user input for correcting code in a target document. User input for correcting code may include at least one of adding, deleting, or modifying code in the target document. User input for correcting code may include user input for modifying one or more characters of the code.

[0162] In operation S1220, the method may include identifying whether a defined period of time has elapsed since the previous user input. For example, electronic device 100 may identify whether a defined time period has elapsed since the previous user input. The defined time period may be a predetermined value. In an example case where no predetermined time period has elapsed since the previous user input, electronic device 100 may not proceed to operation S220 and may wait until the predetermined time period has elapsed since the previous user input. The predetermined time period in which no user input has elapsed may refer to electronic device 100 continuously receiving user input.

[0163] In an example scenario where a predetermined time period has elapsed since the previous user input, electronic device 100 may proceed to operation S220. According to embodiments of this disclosure, electronic device 100 may obtain contextual information in response to the absence of additional user input during the predetermined time period. For example, when additional user input exists within the predetermined time period (e.g., 0.3 seconds), electronic device 100 may not proceed to operation S220, and may only proceed to operation S220 if no additional user input exists within the predetermined time period.

[0164] According to embodiments of the present disclosure, the electronic device 100 can generate a first prompt based on user input of a correction code and context information. For example, the electronic device 100 can generate a first prompt including a target code, wherein the target code includes a correction code and context information.

[0165] According to embodiments of this disclosure, operation S210 is not necessarily included. Figure 12 Operations S1210 and S1220 may be omitted, or some operations may be further included in operation S210.

[0166] Figure 13 This is a view illustrating prompts provided by a generative AI model according to embodiments of this disclosure.

[0167] According to embodiments of this disclosure, in Figure 13 The text shows a prompt based on user input generated from the code.

[0168] According to embodiments of this disclosure, the prompt may include contextual information. The contextual information may include at least one of the following: the target document, a referenced document, code or comments included in another document within the same project and / or an external document. (Referenced) Figure 11 The context information is described, so its description will be omitted.

[0169] In embodiments of this disclosure, the prompt includes the code and / or comments of the object file. For example, see reference... Figure 13 Included <filename>The information between <|end|> can refer to the code and / or comments of the target document.

[0170] According to embodiments of this disclosure, the prompt may include user input. The prompt may include chat input. See also... Figure 13 The prompt may include the received chat input: "Generate code that receives two numbers from the user, adds them together, and then prints the result."

[0171] According to embodiments of this disclosure, electronic device 100 can generate prompts based on user input. In response to chat input being received, electronic device 100 can generate prompts corresponding to the chat input. According to embodiments of this disclosure, electronic device 100 can determine priorities based on chat input. Electronic device 100 can summarize prompts based on priority information.

[0172] Figure 14 This is a flowchart of the operation of obtaining user input according to an embodiment of the present disclosure. Figure 14 The flowchart includes embodiments according to this disclosure. Figure 2 Detailed operation of S210.

[0173] Reference Figure 14 According to embodiments of the present disclosure, operation S210 may include operation S1410 and operation S1420.

[0174] In operation S1410, the method may include identifying a request for code generation included in a target document. For example, electronic device 100 may identify a request for code generation included in a target document. According to embodiments of this disclosure, the request for code generation may include, but is not limited to, at least one of chat input or keyboard shortcut input.

[0175] According to embodiments of this disclosure, electronic device 100 may include chat input requesting information about code. For example, user input may include the chat message "Generate code for ~". In other words, user input may include the user's request information. Chat input may include text input generated through a special user interface other than the user interface displaying the target document. For example, as referenced above... Figure 4 The chat input may include text input of codes that request the user's desired functionality through a special user interface.

[0176] According to embodiments of this disclosure, electronic device 100 may include shortcut key input for requesting information about code. Shortcut key input may include input unrelated to inputting characters in the target document for correction. For example, 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 identifying the requested target. For example, electronic device 100 may identify the requested target. The requested target may include a target code.

[0178] According to embodiments of this disclosure, electronic device 100 can identify the target of a request associated with chat input. For example, in chat input requesting code for a specific function, the target of the request may refer to that specific function.

[0179] According to embodiments of this disclosure, electronic device 100 can identify a requested target associated with a shortcut key input. When a shortcut key is input, electronic device 100 can identify the requested target based on the position of an indicator. The indicator may include, but is not limited to, a mouse cursor or a keyboard cursor. In the example case where a shortcut key is input, electronic device 100 can identify the requested target according to a predetermined rule based on the position of the indicator.

[0180] According to embodiments of this disclosure, in an example where a shortcut key is entered and an indicator points to the beginning of code, the electronic device 100 can identify the request target corresponding to the beginning. In an example where the shortcut key input is obtained from the very beginning of a function, a block of code comprising multiple lines of code implementing the function can be the target of the request.

[0181] According to embodiments of this disclosure, in an example where a shortcut key is entered and an indicator points to the middle portion of a code, the electronic device 100 can identify the request target corresponding to the middle portion. In an example where shortcut key input is obtained from the middle portion of a function (e.g., when some code is entered), the single line of code indicated by the indicator can be the request target.

[0182] According to embodiments of the present disclosure, electronic device 100 can identify the requested target and then proceed to operation S220. Electronic device 100 according to embodiments of the present disclosure can generate a first prompt based on the requested target and context information. For example, electronic device 100 can generate a first prompt including the requested target and context information.

[0183] According to embodiments of this disclosure, operation S210 is not necessarily included. Figure 14 Operations S1410 and S1420 may be omitted, or some operations may be further included in operation S210.

[0184] Figure 15 This is a flowchart of the operation of obtaining context information according to embodiments of the present disclosure. Figure 15 The flowchart includes embodiments according to this disclosure. Figure 2 Detailed operation of S220.

[0185] Reference Figure 15 According to embodiments of the present disclosure, operation S220 may include operation S1510, operation S1520 and operation S1530.

[0186] In operation S1510, the method may include obtaining at least one of the code or comments included in the target document. For example, electronic device 100 may obtain at least one of the code or comments included in the target document. According to embodiments of this disclosure, contextual information may include information included in the target document. In other words, electronic device 100 may obtain contextual information including at least one of the code or comments included in the target document.

[0187] In operation S1520, the method may include obtaining at least one of the code or comments included in a reference document. For example, electronic device 100 may obtain at least one of the code or comments included in a reference document that is available in code generation. According to embodiments of this disclosure, context information may include at least one of the code or comments included in a reference document. In other words, electronic device 100 may obtain context information including at least one of the code or comments included in a reference document.

[0188] According to embodiments of this disclosure, the reference document may include, but is not limited to, at least one of the following: a document loaded in an integrated development environment (e.g., a target document), a document referenced by the target document that is included in one or more documents in a project that includes the target document, a package or library referenced by the target document, or an API document referenced by the target document.

[0189] In operation S1530, the method may include obtaining at least one of the codes or comments included in a document written by another user. For example, electronic device 100 may obtain at least one of the codes or comments included in a document written by another user within a group of users including the target document. According to embodiments of this disclosure, contextual information may include, but is not limited to, at least one of the codes or comments included in a document written by another user within a group of users including the target document. For example, electronic device 100 may identify a group of users including the target document and may obtain contextual information including at least one of the codes or comments included in a document written by a member of the group. In other words, electronic device 100 may obtain contextual information including at least one of the codes or comments included in a document written by another user within a group of users including the target document.

[0190] According to embodiments of this disclosure, operation S220 is not necessarily included. Figure 15 Operations S1510 to S1530 may be performed, and at least some of operations S1510 to S1530 may be omitted, or further operations may be included in operation S220. The order of operations S1510 to S1530 may be changed.

[0191] Figure 16 This is a flowchart of the operation for generating a summary prompt according to embodiments of the present disclosure. Figure 12 The flowchart includes embodiments according to this disclosure. Figure 2 Detailed operation of operation S240 and operation S250.

[0192] Reference Figure 16 According to embodiments of this disclosure, operation S240 may include operation S1610 and operation S1620.

[0193] In operation S1610, the method can determine the priority among multiple pieces of information included in context information. For example, electronic device 100 can determine the priority among multiple pieces of information included in context information. Electronic device 100 can determine the priority according to a rule-based procedure. In other words, electronic device 100 can determine the priority among multiple pieces of information included in context information based on predetermined rules. Electronic device 100 can select information to be summarized first based on priority information.

[0194] In operation S1620, the method may include selecting context information based on priority information. For example, electronic device 100 may select context information to be prioritized for summarization based on priority information. According to embodiments of this disclosure, electronic device 100 may first select high-priority context information. According to embodiments of this disclosure, electronic device 100 may not select some low-priority context information.

[0195] According to embodiments of this disclosure, operation S250 may include operation S1630 and operation S1640.

[0196] In operation S1630, the method may include generating a second prompt by first summarizing high-priority context information. For example, electronic device 100 may generate a second prompt by first summarizing high-priority context information. According to embodiments of this disclosure, electronic device 100 may generate a second prompt by first summarizing high-priority context information until the length of the second prompt becomes less than a threshold. For example, electronic device 100 may generate a second prompt by summarizing first context information with a first priority and then summarizing second context information with a second priority lower than the first priority, etc. Electronic device 100 may summarize context information sequentially from high-priority to low-priority context information. Electronic device 100 may repeat the summarization of context information. For example, electronic device 100 may repeatedly perform low-level summarization instead of high-level summarization from the beginning. Electronic device 100 may stop summarizing based on the length of the prompt being less than a threshold.

[0197] According to embodiments of this disclosure, electronic device 100 can generate a second prompt by using a generative AI model. For example, electronic device 100 can generate a summarized second prompt by requesting a summary of the first prompt from the generative AI model. The generative AI model can be operated by electronic device 100 or a server connected to electronic device 100. Electronic device 100 can generate the second prompt by sending the first prompt or at least one of the context information selected in operation S240 to the server and receiving the result of a summary by the generative AI model of the server.

[0198] In operation S1640, the method may include deleting high-priority context information. For example, electronic device 100 may generate a second prompt by first deleting high-priority context information. According to embodiments of the present disclosure, in an example where the length of the summarized second prompt is greater than a threshold, electronic device 100 may generate a second prompt by first deleting high-priority context information. According to embodiments of the present disclosure, electronic device 100 may delete context information after summarizing context information. For example, when the length of the summarized multiple context information prompts is still greater than a threshold, electronic device 100 may delete the context information. According to embodiments of the present disclosure, electronic device 100 may delete context information without summarizing context information. For example, electronic device 100 may generate a second prompt by deleting context information based on priority information without summarizing.

[0199] According to embodiments of this disclosure, operation S240 is not necessarily included. Figure 16 Operations S1610 and S1620. Similarly, operation S250 does not necessarily include... Figure 16 Operations S1630 and S1640. At least some of operations S1610 to S1640 may be omitted, or some operations may be further included. The order of operations S1630 and S1640 may be changed.

[0200] Now refer to Figure 17a , Figure 17b and Figure 17c This invention describes a system for providing code using a generative AI model in an electronic device 100 according to an embodiment of the present disclosure.

[0201] Figure 17a This is a diagram illustrating a system for providing code using a generative AI model, according to embodiments of the present disclosure.

[0202] According to embodiments of this disclosure, electronic device 100 can provide various services that provide code by using generative AI models.

[0203] Reference Figure 17a According to embodiments of this disclosure, electronic device 100 can execute a service 1710 for generating code. For example, electronic device 100 can generate a prompt based on user input requesting the generation of specific code. Electronic device 100 can input the generated prompt into a generative AI model to obtain a response including code written in a programming language. Electronic device 100 can generate code based on conditions included in the user input.

[0204] According to embodiments of this disclosure, electronic device 100 can perform a service 1720 for translating code. For example, electronic device 100 can generate a prompt based on user input to request the conversion of code written in the "Python" programming language into code written in the "C" programming language. Electronic device 100 can input the generated prompt into a generative AI model to obtain a response that includes code written in another programming language.

[0205] Figure 17b This is a diagram illustrating a system for providing code using a generative AI model, according to embodiments of the present disclosure.

[0206] Reference Figure 17b According to embodiments of this disclosure, electronic device 100 can execute service 1730 for generating text describing code. For example, electronic device 100 can generate a prompt based on user input requesting the generation of text describing code written in a programming language. Electronic device 100 can then input the generated prompt into a generative AI model to obtain a response including text describing the code.

[0207] Figure 17c This is a diagram illustrating a system for providing code using a generative AI model, according to embodiments of the present disclosure.

[0208] Reference Figure 17c According to embodiments of this disclosure, electronic device 100 can perform a service 1740 for generating docstrings for code. For example, electronic device 100 can generate a prompt based on user input requesting the generation of docstrings for code written in a programming language. Electronic device 100 can then input the generated prompt into a generative AI model to obtain a response including text describing the code.

[0209] According to embodiments of this disclosure, electronic device 100 can execute service 1750 for refactoring code. For example, electronic device 100 can generate prompts based on user input requesting refactoring of written code. Electronic device 100 can input the generated prompts into a generative AI model to obtain a response including newly written code for performing the same function.

[0210] According to embodiments of this disclosure, electronic device 100 can execute a service 1760 for fixing errors in code. For example, electronic device 100 can generate a prompt based on user input requesting error fixing in the code. Electronic device 100 can input the generated prompt into a generative AI model to obtain a response including code for error fixing.

[0211] Figure 18 This is a block diagram illustrating the structure of an electronic device 100 according to an embodiment of the present disclosure.

[0212] According to embodiments of this disclosure, electronic device 100 may include processor 1810, memory 1820, and communication interface 1830.

[0213] Processor 1810 can control all operations of electronic device 100. For example, processor 1810 can control all operations of electronic device 100 by executing one or more instructions of a program stored in memory 1820 to provide personalized code. Processor 1810 may be included as one or more.

[0214] The processor 1810 may include, but is not limited to, at least one of a central processing unit, a microprocessor, a graphics processing unit, an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field-programmable gate array (FPGA), an application processor, a neural processing unit, or an AI-specific processor designed with a hardware architecture specifically for processing AI models.

[0215] Processor 1810 can obtain context information from a target document or reference document by executing code information extraction module 1822. For example, processor 1810 can execute code information extraction module 1822 to obtain context information, wherein the context information includes at least one of code or comments included in the target document or code or comments included in a reference document stored in memory 1820. Since a description related to the operation of code information extraction module 1822 has been given with reference to the above-described drawings, these descriptions will not be repeated.

[0216] Processor 1810 can obtain contextual information from a document or reference document written by another user by executing code information search module 1824. For example, processor 1810 can execute code information search module 1824 to obtain contextual information, wherein the contextual information includes at least one of code or comments included in a document written by another user or code or comments included in an external reference document using web references. Since a description relating to the operation of code information search module 1824 has already been given with reference to the above figures, these descriptions will not be repeated.

[0217] The processor 1810 can generate a first cue based on scene information by executing the combination module 1826. Since a description relating to the operation of the combination module 1826 has already been given with reference to the accompanying drawings, these descriptions will not be repeated.

[0218] Processor 2240 can generate a second prompt by executing summary module 1828, wherein the second prompt is a summary of the first prompt. Since a description relating to the operation of summary module 1828 has already been given with reference to the accompanying drawings, these descriptions will not be repeated.

[0219] The modules stored in memory 1820 are for ease of description, but the embodiments of this disclosure are not limited thereto. To implement the above embodiments of this application, other modules (e.g., generative AI modules) may be added, and some modules (e.g., summarizing modules) may be omitted. A module may be divided into multiple modules distinguished according to detailed functions, and some of the above modules may be combined to form a single module.

[0220] According to embodiments, the electronic device 100 may further include additional components for performing the operations described in the above embodiments of this disclosure. For example, the electronic device 100 may also include a display, camera, microphone, speaker, I / O interface, etc. The display may output image signals to the screen of the electronic device 100 under the control of the processor 1810.

[0221] According to embodiments of this disclosure, the method may include multiple operations, and these operations may be executed by one or more processors. In an example case where the first, second, and third operations are performed by the method according to embodiments of this disclosure, all three operations may be executed by a first processor, or the first and second operations may be executed by a first processor (e.g., a general-purpose processor), and the third operation may be executed by a second processor (e.g., an AI processor). An AI-specific processor, as an example of a second processor, may perform operations for training / inference of an AI model. However, embodiments of this disclosure are not limited thereto.

[0222] One or more processors according to this disclosure can be implemented as single-core processors or multi-core processors.

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

[0224] Instructions, data structures, and program code readable by the processor 1810 can be stored in memory 1820. Operations performed by the processor 1810 can be achieved by executing the instructions or code of the program stored in memory 1820.

[0225] The memory 1820 may include flash memory, hard disk memory, multimedia card micro-type and card-type memory (e.g., Secure Digital (SD) or Extreme Digital (XD) memory), and may include non-volatile memory (including at least one of read-only memory (ROM), electrically erasable programmable ROM (EEPROM), programmable ROM (PROM), magnetic storage, magnetic disk or optical disk) and volatile memory (such as random access memory (RAM) or static random access memory (SRAM)).

[0226] The memory 1820 may store one or more instructions and / or programs for operating the electronic device 100 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 search module 1824, the combination module 1826, and the summary module 1828. The memory 1820 may also 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 communication circuitry capable of performing data communication between electronic device 100 and other electronic devices (e.g., server 110) by using at least one of the following data communication methods: wired LAN, wireless LAN, Wi-Fi, Bluetooth, Zigbee, Wi-Fi Direct (WFD), Infrared Communication (IrDA), Bluetooth Low Energy (BLE), Near Field Communication (NFC), Wireless Broadband Internet (Wibro), Global Microwave Access Interoperability (WiMAX), Shared Wireless Access Protocol (SWAP), Wireless Gigabit Alliance (WiGig), and RF communication.

[0229] The communication interface 1830 can send hints about the generative AI model to the server 110 and receive code information corresponding to the hints from the server 110. For example, the communication interface 1830 can send hints to the server 110 and receive code information from the server 110.

[0230] According to embodiments of this disclosure, electronic device 100 may not include communication interface 1830. Electronic device 100 may provide code information corresponding to prompts by using a generative AI model included in electronic device 100 instead of using a generative AI model of an external electronic device (e.g., server 110).

[0231] Figure 19 This is a block diagram of the structure of server 110 according to an embodiment of the present disclosure.

[0232] According to embodiments of this disclosure, server 110 may include processor 1910, memory 1920, and communication interface 1930. Server 110 may be a computing device with higher performance than electronic device 100 and is capable of using large-scale data to process complex computations and tasks such as training, inference, management, and distribution of generative AI models.

[0233] Processor 1910 can control all operations of server 110. For example, processor 1910 can control all operations of server 110 for generating personalized code by executing one or more instructions of a program stored in memory 1920. Processor 1910 may be included as one or more.

[0234] The processor 1910 may include, but is not limited to, at least one of a central processing unit, a microprocessor, a graphics processing unit, an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field-programmable gate array (FPGA), an application processor, a neural processing unit, or an AI-specific processor designed with a hardware architecture dedicated to processing AI models.

[0235] Processor 1910 can generate code by executing generative language model 1925. Processor 1910 can generate code corresponding to prompts by using generative language model 1925. According to embodiments of this disclosure, processor 1910 can summarize prompts by executing generative language model 1925. Processor 1910 can input prompts obtained through communication interface 1930 into generative language model 1925 to generate summarized prompts.

[0236] Instructions, data structures, and program code readable by processor 1910 can be stored in memory 1920. Operations performed by processor 1910 can be achieved by executing the instructions or code of the program stored in memory 1920.

[0237] The memory 1920 may include flash memory, hard disk memory, multimedia card micro and card memory (e.g., Secure Digital (SD) or Extreme Digital (XD) memory), and may include non-volatile memory (including at least one of read-only memory (ROM), electrically erasable programmable ROM (EEPROM), programmable ROM (PROM), magnetic storage, magnetic disk or optical disk) and volatile memory (such as random access memory (RAM) or static random access memory (SRAM)).

[0238] Memory 1920 may store one or more instructions and programs for instructing server 110 to generate personalized code. For example, memory 1920 may store instructions and / or programs for implementing the functionality of generative language model 1925. Generative language model 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 communication circuitry capable of performing data communication between server 110 and other electronic devices (e.g., electronic device 100) by using at least one of the following data communication methods: wired LAN, wireless LAN, Wi-Fi, Bluetooth, Zigbee, Wi-Fi Direct (WFD), Infrared Communication (IrDA), Bluetooth Low Energy (BLE), Near Field Communication (NFC), Wireless Broadband Internet (Wibro), Global Microwave Access Interoperability (WiMAX), Shared Wireless Access Protocol (SWAP), Wireless Gigabit Alliance (WiGig), and RF communication.

[0241] The communication interface 1930 can send data for providing codes to and receive data for providing codes from the electronic device 100. For example, the communication interface 1930 can receive prompts from the electronic device 100 and can send personalized codes to the electronic device 100.

[0242] This disclosure relates to a method, electronic device, and server for generating and providing code using a generative AI model. This disclosure also relates to a method for generating prompts that are input into a generative AI model to provide code. Additional aspects will be set forth in part in the description which follows, and in part will be apparent from the description, or may be learned by practicing the embodiments presented in this disclosure.

[0243] The information referenced for code generation can be dynamically changed as needed. In example cases where the library used for code generation changes, the information referenced for code generation can change. Generative AI models struggle to generate results using information created after a learning point or information created by the user personally. Therefore, by providing the generative AI model with prompts containing contextual information, responses tailored to user intent can be obtained. In this case, additional learning costs and time can be saved. However, according to generative AI, the length of prompts is limited. Therefore, the length of prompts cannot exceed a threshold. The electronic device 100 according to embodiments of this disclosure can generate prompts shorter than the threshold and including contextual information. Furthermore, the electronic device 100 according to embodiments of this disclosure can obtain efficient and highly reliable responses from the generative AI model by determining the priority summarized in the prompt based on the importance of the information. Additional technical effects will be set forth in part in the description which follows, and will be apparent in part from the description, or may be learned by practicing the embodiments presented in this disclosure.

[0244] According to embodiments of this disclosure, a method for providing code using a generative artificial intelligence (AI) 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 hint for code generation based on the first context information and the user input. The method may include: selecting second context information from the first context information according to priority information based on the length of the first hint. The method may include: generating a second hint corresponding to the first hint based on the second context information and the user input. The method may include: sending the first hint or the second hint to a server. The method may include: receiving recommended code generated by the generative AI model based on the first hint or the second hint from the server, and providing the recommended code.

[0245] According to embodiments of this disclosure, the first context information may include at least one of a first code or a first comment included in the first document. The first context information may include at least one of a second code or a second comment included in a reference document capable of being used for code generation. The first context information may include at least one of a third code or a third comment included in a second document written by a second user, wherein the second user is within the group that includes the first user of the first document.

[0246] According to embodiments of this disclosure, the reference document may include at least one of the following: a document that is identical to the target document and is loaded into an integrated development environment (IDE); a document referenced by the first document and included in one or more documents in a project that includes the first document; a package or library referenced by the first document; or an application programming interface (API) document referenced by the first document.

[0247] According to embodiments of this disclosure, the user input may include user input correcting code in the first document. Obtaining the first context information may include obtaining the first context information based on the fact that no additional user input is received during a defined time period following the user input.

[0248] According to embodiments of this disclosure, the user input may include a request for code generation included in the first document. Obtaining the first context information may include: obtaining the first context information based on obtaining the user input. Obtaining the first context information may include: generating the first prompt may include: generating the first prompt that includes the request included in the user input.

[0249] According to embodiments of this disclosure, generating the second prompt may include sending at least one of the first prompt, the first context information, or the user input to the server or another server. Generating the second prompt may include obtaining a second prompt summarized by a generative AI model included in the server or the other server.

[0250] According to embodiments of this disclosure, selecting the second context information may include: determining priority information regarding the priority of each piece of information among a plurality of pieces of information included in the first context information. Selecting the second context information may include: selecting context information to be prioritized for summarization within the first context information based on the priority information. Generating the second prompt may include: generating the second prompt by first summarizing high-priority context information until the length of the second prompt becomes less than a threshold.

[0251] According to embodiments of this disclosure, generating the second prompt may include: generating the second prompt by deleting the high-priority context information based on the fact that the length of the summarized second prompt is greater than the threshold.

[0252] According to embodiments of this disclosure, obtaining the first context information may include: determining target context information that can be used for code generation based on at least one of the user input or the first document. Obtaining the first context information may include: obtaining the determined target context information from the first document or a reference document.

[0253] According to embodiments of this disclosure, the priority information may include at least one of the order of context information that is prioritized when a summary is performed or context information that is not performed when a summary is performed.

[0254] According to embodiments of this disclosure, an electronic device is provided for providing code using a generative artificial intelligence (AI) model. The electronic device may include: at least one processor, including processing circuitry; and a memory, including one or more storage media storing at least one instruction. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to obtain user input corresponding to a first document. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to obtain first context information capable of being used for code generation based on the user input. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to generate a first prompt for code generation based on the first context information and the user input. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to select second context information from the first context information based on priority information according to the length of the first prompt. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to generate a second prompt corresponding to the first prompt based on the second context information and the user input. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to send either the first prompt or the second prompt to a server. When the at least one instruction is executed individually or jointly by the at least one processor, the electronic device receives and provides the recommended code generated by the generative AI model based on the first prompt or the second prompt from the server.

[0255] According to embodiments of this disclosure, the first context information may include at least one of a first code or a first comment included in the first document. The first context information may include at least one of a second code or a second comment included in a reference document capable of being used for code generation. The first context information may include at least one of a third code or a third comment included in a second document written by a second user, wherein the second user is within the group that includes the first user of the first document.

[0256] According to embodiments of this disclosure, the reference document may include at least one of the following: a document identical to the target document loaded into an integrated development environment (IDE); a document referenced by the first document in one or more documents included in a project that includes the first document; a package or library referenced by the first document; or an application programming interface (API) document referenced by the first document.

[0257] According to embodiments of this disclosure, the user input may include user input for correcting code in the first document. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to obtain the first context information based on the absence of additional user input during a defined time period following the user input.

[0258] According to embodiments of this disclosure, the user input may include a request regarding the generation of code included in the first document. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to obtain the first context information based on the user input and generate the first prompt including the request included in the user input.

[0259] According to embodiments of this disclosure, when executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to send at least one of the first prompt, the first context information, or the user input to the server or another server. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to receive a second prompt summarized by a generative AI model included in the server or the other server.

[0260] According to embodiments of this disclosure, when executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to determine priority information regarding the priority of each piece of information among a plurality of pieces of information included in the first context information. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to select context information to be prioritized for summarization within the first context information based on the priority information. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to generate the second prompt by first summarizing high-priority context information until the length of the second prompt becomes less than a threshold.

[0261] According to embodiments of this disclosure, when the at least one instruction is executed individually or jointly by the at least one processor, the electronic device generates the second prompt by deleting the high-priority context information based on the length of the summarized second prompt being greater than the threshold.

[0262] According to embodiments of this disclosure, when executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to determine target context information that can be used for code generation based on at least one of the user input or the first document. When executed individually or jointly by the at least one processor, the at least one instruction causes the electronic device to obtain the target context information from the target document or the reference document.

[0263] According to embodiments of this disclosure, the priority information may include at least one of the following: the order of context information that is prioritized when a summary is performed, or context information that is not performed when a summary is performed.

[0264] According to embodiments of this disclosure, a computer-readable recording medium has a computer program recorded thereon, which performs the above-described method when executed by a computer.

[0265] According to embodiments, machine-readable storage media may be provided as non-transitory storage media. "Non-transitory storage media" refers to a tangible device and only means that a "non-transitory storage medium" does not contain signals (e.g., electromagnetic waves). This term does not distinguish between cases where data is stored semi-permanently in the storage medium and cases where data is temporarily stored. For example, a non-transitory recording medium may include a buffer for temporarily storing data.

[0266] According to embodiments of this disclosure, methods according to various disclosed embodiments can be provided by being included in a computer program product. The computer program product, as a commodity, can be traded between a seller and a buyer. The computer program product can be distributed in the form of a device-readable storage medium (e.g., an optical disc read-only memory (CD-ROM)), or distributed online (e.g., downloaded or uploaded) through an app store, or distributed 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 application) may be stored at least temporarily in a device-readable storage medium (such as the memory of a manufacturer's server, an app store's server, or a relay server), or at least a portion of the computer program product may be temporarily generated.< / filename> < / filename> < / end> < / context>

Claims

1. A method of providing code by using a generative artificial intelligence (AI) model, the method comprising: obtaining a user input corresponding to a first document (S210); obtaining first context information usable for code generation based on the user input (S220); generating a first prompt for code generation based on the first context information and the user input (S230); selecting second context information from the first context information according to priority information based on a length of the first prompt (S240); generating a second prompt corresponding to the first prompt based on the second context information and the user input (S250); transmitting the first prompt or the second prompt to a server (S260); and receiving (S270) recommended code generated by the generative AI model based on the first prompt or the second prompt from the server, and providing the recommended code. The first context information includes:

2. The method of claim 1, wherein, at least one of a first code or a first comment included in the first document; at least one of a second code or a second comment included in a reference document usable for code generation; and at least one of a third code or a third comment included in a second document written by a second user, wherein the second user is within a group of first users including the first document. The reference document includes at least one of:

3. The method of claim 2, wherein, a same document as a target document loaded into an integrated development environment (IDE); a document referenced by the first document included in one or more documents of a project including the first document; a package or a library referenced by the first document; or an application programming interface (API) document referenced by the first document. 4.The method of any one of claims 1 to 3, wherein, the user input includes a user input to correct a code in the first document, and obtaining the first context information (S220) includes obtaining the first context information based on no additional user input being obtained during a defined time period after the user input. 5.The method of any one of claims 1 to 4, wherein, the user input includes a request regarding code generation included in the first document, obtaining the first context information (S220) includes obtaining the first context information based on obtaining the user input, and generating the first prompt (S230) includes generating the first prompt including the request included in the user input. Generating the second prompt (S250) includes:

6. The method of any one of claims 1 to 5, wherein, transmitting at least one of the first prompt, the first context information, or the user input to the server or another server; and obtaining a second prompt summarized by a generative AI model included in the server or the other server. 7.The method of any one of claims 1 to 6, wherein, selecting the second context information (S240) includes: ​ determining priority information regarding a priority of each of a plurality of pieces of information included in the first context information; and selecting, based on the priority information, context information to be prioritized for summarization in the first context information, and generating the second prompt (S250) includes generating the second prompt by first summarizing high-priority context information until a length of the second prompt becomes less than a threshold.

8. The method of claim 7, wherein, generating the second prompt (S250) includes generating the second prompt by deleting the high-priority context information based on a length of the second prompt after summarization being greater than the threshold.

9. The method of any one of claims 1 to 8, wherein, obtaining the first context information (S220) includes: determining target context information that can be used for code generation based on at least one of the user input or the first document; and obtaining the determined target context information from the first document or a reference document.

10. The method of any one of claims 1 to 9, wherein, The priority information includes at least one of an order of context information that is processed first when performing summarization or context information that is not performed summarization. 11.An electronic device for providing code by using a generative artificial intelligence (AI) model, the electronic device comprising: at least one processor (1810) including processing circuitry; and a memory (1820) including one or more storage mediums storing at least one instruction, wherein the at least one instruction, when executed by the at least one processor individually or collectively, causes the electronic device to: obtain a user input corresponding to a first document; obtain first context information that can be used for code generation based on the user input; generate a first prompt for code generation based on the first context information and the user input; select second context information from the first context information according to priority information based on a length of the first prompt; generate a second prompt corresponding to the first prompt based on the second context information and the user input; transmit the first prompt or the second prompt to a server; and receive recommended code generated by the generative AI model based on the first prompt or the second prompt from the server and provide the code. 12.The electronic device of claim 11, wherein, The first context information includes: at least one of a first code or a first comment included in the first document; at least one of a second code or a second comment included in a reference document that can be used for code generation; and at least one of a third code or a third comment included in a second document written by a second user, wherein the second user is within a group of first users including the first document. 13.The electronic device of claim 12, wherein, The reference document includes at least one of: a document identical to a target document loaded into an integrated development environment (IDE); a document referenced by the first document included in one or more documents included in a project including the first document; a package or a library referenced by the first document; or an application programming interface (API) document referenced by the first document. 14.The electronic device of any one of claims 11 to 13, wherein, the user input includes user input to correct code in the first document, and the at least one instruction, when executed by the at least one processor alone or collectively, causes the electronic device to perform operations of: obtaining the first context information based on no additional user input being obtained during a defined time period after the user input. 15.A computer-readable recording medium having recorded thereon a computer program which, when executed by a computer, performs the method of any one of claims 1 to 10.