Code annotation generation method, device and equipment based on AI, RPA and AI Agent
Automatically generate RPA code annotations through AI, RPA and AI Agent technologies, solving the problem of time-consuming and low accuracy in code annotation generation, and achieving efficient and accurate code annotation generation.
Patent Information
- Application Number
- CN202411111219.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-11-29
AI Technical Summary
RPA code annotation generation takes a long time and is prone to omissions or inaccuracies, resulting in low development efficiency and high error rate.
Using the code annotation generation method based on AI, RPA and AI Agent, code annotation is automatically generated to reduce manual intervention by obtaining the RPA code to be commented, processing the code structure, determining the annotation location and inserting the object code annotation.
Effectively reduce the time-consuming generation of shortened code comments, improve generation accuracy, reduce human error rate, and improve development efficiency.
Smart Images

Figure CN119045876A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of artificial intelligence (AI), robotic process automation (RPA) and artificial intelligence agent (AI agent), and in particular to a code annotation generation method, device and equipment based on AI, RPA and AI agent. Background Art
[0002] Robotic Process Automation (RPA) uses specific "robot software" to simulate human operations on computers and automatically execute process tasks according to rules.
[0003] Artificial Intelligence (AI) is a technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence.
[0004] The artificial intelligence agent (AI agent) of the digital labor platform can perceive the environment, make decisions and perform actions. The difference from traditional artificial intelligence is that it has the ability to think and act independently and can call tools to complete given goals. AI Agent is based on large language models (LLM) as its core computing engine, which enables it to have conversations, perform tasks, reason and show a certain degree of autonomy. It has the ability to understand, perceive, plan, remember and use tools independently, and can automatically perform complex tasks. Specifically, the AI agent, an intelligent assistant composed of multiple AI capabilities driven by LLM, can interact with employees in natural language, understand employees' instructions and needs, and provide feedback and responses; it can master domain knowledge related to the business to complete complex professional work; it can decompose complex tasks into several executable tasks and use data and tools to complete tasks; it can also collaborate with employees, and AI agents can also collaborate to complete complex tasks, so as to enable digital employees to achieve a leap from automation to intelligence, help employees complete their work more efficiently, and fully realize human-machine collaboration.
[0005] In today's wave of digital transformation, enterprises are increasingly relying on RPA to improve efficiency, reduce human errors and lower operating costs. However, a significant challenge in the RPA development process is the generation of code comments. In related technologies, developers usually write RPA code comments manually. Therefore, the generation of code comments is not only time-consuming, but also prone to omissions or inaccurate descriptions. Summary of the invention
[0006] The embodiments of the present disclosure provide a method, apparatus and device for generating code comments based on AI, RPA and AI Agent to solve one of the technical problems existing in the related technologies. The technical solution is as follows:
[0007] In a first aspect, an embodiment of the present disclosure provides a method for generating code comments based on AI, RPA, and AI Agent, including:
[0008] Acquire the RPA code to be annotated from the initial RPA code based on the code annotation type, wherein the RPA code to be annotated includes at least one code structure;
[0009] Processing at least one code structure based on AI and code annotation type to obtain target code annotations for the RPA code to be annotated;
[0010] Determine the code annotation location of the RPA code to be annotated; and
[0011] Insert the target code comments into the code comment position in the initial RPA code
[0012] In a second aspect, an embodiment of the present disclosure provides a device for generating code comments based on AI, RPA, and AI Agent, including:
[0013] An acquisition module, used for acquiring RPA code to be annotated from the initial RPA code based on the code annotation type, wherein the RPA code to be annotated includes at least one code structure;
[0014] A processing module, configured to process at least one code structure based on AI and code annotation type to obtain a target code annotation of the RPA code to be annotated;
[0015] A determination module, used to determine a code annotation position of the RPA code to be annotated; and
[0016] The insertion module is used to insert the target code comment into the code comment position in the initial RPA code.
[0017] In a third aspect, an embodiment of the present disclosure provides an electronic device, the electronic device comprising: a memory and a processor. The memory and the processor communicate with each other through an internal connection path, the memory is used to store instructions, the processor is used to execute the instructions stored in the memory, and when the processor executes the instructions stored in the memory, the processor executes the method in any one of the above-mentioned embodiments.
[0018] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a computer, the method in any one of the above-mentioned embodiments is executed.
[0019] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which implements the method in any one of the above-mentioned aspects when executed by a processor.
[0020] The advantages or beneficial effects of the above technical solution include at least:
[0021] The RPA code to be annotated is obtained from the initial RPA code based on the code annotation type, wherein the RPA code to be annotated includes at least one code structure, and at least one code structure is processed based on AI and the code annotation type to obtain the target code annotation of the RPA code to be annotated, determine the code annotation position of the RPA code to be annotated, and insert the target code annotation into the code annotation position in the initial RPA code. Based on AI, RPA and AI Agent technologies, the time consumption of generating code annotations can be effectively shortened, and the accuracy of generating code annotations can be effectively improved.
[0022] The above summary is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments and features described above, further aspects, embodiments and features of the present disclosure will be readily apparent by reference to the accompanying drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments disclosed in accordance with the present disclosure and should not be regarded as limiting the scope of the present disclosure.
[0024] Figure 1 is a flowchart of a method for generating code comments based on AI, RPA and AI Agent provided by an embodiment of the present disclosure;
[0025] Figure 2is a flowchart of a method for generating code comments based on AI, RPA and AI Agent provided by another embodiment of the present disclosure;
[0026] Figure 3 is a flowchart of a method for generating code comments based on AI, RPA and AI Agent provided by another embodiment of the present disclosure;
[0027] Figure 4 is a schematic diagram of the implementation process in the embodiment of the present disclosure;
[0028] Figure 5 is a structural diagram of a code annotation generation device based on AI, RPA and AI Agent provided by an embodiment of the present disclosure;
[0029] Figure 6 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0030] Embodiments of the present disclosure are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present disclosure, and cannot be understood as limiting the present disclosure.
[0031] In today's wave of digital transformation, enterprises are increasingly relying on RPA to improve efficiency, reduce human errors and lower operating costs. However, a significant challenge in the RPA development process is the generation of code comments. In related technologies, developers usually write RPA code comments manually. Therefore, the generation of code comments is not only time-consuming, but also prone to omissions or inaccurate descriptions.
[0032] In order to solve at least one of the above-mentioned problems, the embodiments of the present disclosure propose a code annotation generation method, device and equipment based on artificial intelligence (AI), robotic process automation (RPA) and digital labor platform intelligent assistant (AI Agent).
[0033] These and other aspects of the embodiments of the present disclosure will be apparent with reference to the following description and drawings. In these descriptions and drawings, some specific implementations of the embodiments of the present disclosure are specifically disclosed to represent some ways of implementing the principles of the embodiments of the present disclosure, but it should be understood that the scope of the embodiments of the present disclosure is not limited thereto. On the contrary, the embodiments of the present disclosure include all changes, modifications and equivalents that fall within the spirit and connotation of the appended claims.
[0034] Before describing the embodiments of the present disclosure in detail, for ease of understanding, common technical terms are first introduced:
[0035] In the description of the present disclosure, the term "plurality" refers to two or more.
[0036] In the description of the present disclosure, the term “RPA code” refers to a computer program code for implementing RPA.
[0037] In the description of this disclosure, the term "code annotation type" refers to the type of annotation for RPA code. Code annotation types include, for example, full code annotation, partial code annotation, function annotation, etc., which are not limited.
[0038] In the description of the present disclosure, the term “initial RPA code” refers to the original RPA code on which code annotation is to be performed.
[0039] In the description of the present disclosure, the term “RPA code to be annotated” refers to a local RPA code extracted from an initial RPA code based on which corresponding code annotations need to be generated.
[0040] In the description of this disclosure, the term "code structure" refers to a data structure used to organize and store multiple different types of data items. It can combine different types of data together to more conveniently process and manage related data.
[0041] In the description of this disclosure, the term “target code annotation” refers to code annotation generated for the RPA code to be annotated.
[0042] In the description of the present disclosure, the term "code annotation position" refers to an annotation position for adding a target code annotation, which is a position in the initial RPA code and can be used to add a target code annotation to the RPA code to be annotated.
[0043] In the description of this disclosure, the term "token" refers to an element of a single unit processed by a large model.
[0044] In the description of the present disclosure, the term "maximum number of tokens supported by the large model" refers to the number of elements of a single unit that the large model can process at one time.
[0045] In the description of the present disclosure, the term “RPA grammar rule” refers to a grammar rule of a computer program code that implements RPA.
[0046] In the description of the present disclosure, the term “sub-code annotation” refers to an RPA code segment obtained by refining and segmenting the RPA code to be annotated.
[0047] In the description of this disclosure, the term "sub-code annotation" refers to the annotation content obtained by annotating a sub-RPA code segment.
[0048] In the description of the present disclosure, the term “target code annotation” refers to a code annotation that matches the overall RPA code to be annotated.
[0049] In the description of the present disclosure, the term “code selection information” refers to instruction information for selecting a local RPA code from an initial RPA code.
[0050] In the description of the present disclosure, the term “first RPA code” refers to a local RPA code selected by the code selection information.
[0051] In the description of the present disclosure, the term "second RPA code" refers to an RPA code that has an association relationship with the first RPA code in terms of functional logic, semantic content, etc., and can also be understood as a context code of the first RPA code.
[0052] Figure 1 It is a flowchart of a code annotation generation method based on AI, RPA and AI Agent provided by an embodiment of the present disclosure.
[0053] In a possible implementation method provided by an embodiment of the present disclosure, the present disclosure takes the code comment generation method based on AI, RPA and AI Agent as an example, which is configured in a code comment generation device based on AI, RPA and AI Agent. The code comment generation device based on AI, RPA and AI Agent can be applied to any electronic device with computing capability.
[0054] The electronic device may be a personal computer, a mobile terminal, a service end (or server), etc. The mobile terminal may be, for example, a mobile phone, a tablet computer, a personal digital assistant, or other hardware device with various operating systems.
[0055] In another possible implementation of the embodiments of the present disclosure, the code annotation generation method based on AI, RPA and AI Agent can be applied to AI Agent, wherein the AI Agent can run in any electronic device with computing capabilities.
[0056] In another possible implementation of the embodiments of the present disclosure, the code annotation generation method based on AI, RPA and AI Agent can be applied to a Robotic Process Automation (RPA) robot, wherein the RPA robot can run in any electronic device with computing capabilities.
[0057] like Figure 1 As shown, the code annotation generation method based on AI, RPA and AI Agent may include the following steps S101 to S104:
[0058] Step S101: obtaining RPA code to be annotated from the initial RPA code based on the code annotation type, wherein the RPA code to be annotated includes at least one code structure.
[0059] In the description of the present disclosure, the term “RPA code” refers to a computer program code for implementing RPA.
[0060] In the description of this disclosure, the term "code annotation type" refers to the type of annotation for RPA code. Code annotation types include, for example, full code annotation, partial code annotation, function annotation, etc., which are not limited.
[0061] In the description of the present disclosure, the term “initial RPA code” refers to the original RPA code on which code annotation is to be performed.
[0062] In the description of the present disclosure, the term “RPA code to be annotated” refers to a local RPA code extracted from an initial RPA code based on which corresponding code annotations need to be generated.
[0063] In the description of this disclosure, the term "code structure" refers to a data structure used to organize and store multiple different types of data items. It can combine different types of data together to more conveniently process and manage related data.
[0064] In some embodiments, the code annotation type can be referenced to parse the initial RPA code to obtain the RPA code to be annotated. In this process, the code annotation type can be referenced automatically based on the AI Agent to parse the initial RPA code to obtain the RPA code to be annotated.
[0065] For example, if the reference code annotation type is full code annotation, it can be determined that the initial RPA code needs to be fully annotated. In this case, all RPA codes that need to be annotated in the initial RPA code can be used as RPA codes to be annotated. If the reference code annotation type is partial code annotation, local RPA codes to be annotated can be selected from the initial RPA code based on the reference code annotation type. If the reference code annotation type is function annotation, part of the RPA code containing functions can be selected from the initial RPA code and used as RPA codes to be annotated.
[0066] In some embodiments, after obtaining the RPA code to be annotated from the initial RPA code based on the code annotation type, one or more code structures contained in the RPA code to be annotated can also be determined. The code structures can be used to understand the code structure and semantics to support the generation of correct code annotations.
[0067] Step S102: Process at least one code structure based on AI and code annotation type to obtain target code annotation of the RPA code to be annotated.
[0068] In the description of this disclosure, the term “target code annotation” refers to code annotation generated for the RPA code to be annotated.
[0069] After obtaining the RPA code to be annotated from the initial RPA code based on the code annotation type and determining one or more code structures contained in the RPA code to be annotated, the code annotation type and the one or more code structures can be processed based on AI to analyze and obtain the target code annotation.
[0070] For example, one or more code structures can be semantically parsed based on AI to identify the functions, loops, branch judgments, exception handling and other logic contained therein, and then, target code comments can be generated based on the identified content combined with the preconfigured template; or the code comment type and one or more code structures can be processed based on the AI model to generate target code comments; or any other possible method can be used to process at least one code structure based on AI and code comment type to obtain the target code comments of the RPA code to be annotated, without limitation.
[0071] Step S103: Determine the code annotation position of the RPA code to be annotated.
[0072] In the description of the present disclosure, the term "code annotation position" refers to an annotation position for adding a target code annotation, which is a position in the initial RPA code and can be used to add a target code annotation to the RPA code to be annotated.
[0073] In some embodiments, after the target code annotation of the RPA code to be annotated is generated based on AI, the code annotation location of the RPA code to be annotated may also be determined.
[0074] In some embodiments, the code annotation position of the RPA code to be annotated can be determined by referring to the position of the RPA code to be annotated in the initial RPA code; or the code annotation position of the RPA code to be annotated can be determined based on a configured manner; or the code annotation position of the RPA code to be annotated can be determined based on any other possible manner, without limitation.
[0075] Step S104: insert the target code comment into the code comment position in the initial RPA code.
[0076] After determining the code comment position of the RPA code to be annotated, the target code comment may be inserted into the initial RPA code at the code comment position.
[0077] In this embodiment, the RPA code to be annotated is obtained from the initial RPA code based on the code annotation type, wherein the RPA code to be annotated includes at least one code structure, and at least one code structure is processed based on AI and the code annotation type to obtain the target code annotation of the RPA code to be annotated, determine the code annotation position of the RPA code to be annotated, and insert the target code annotation into the code annotation position in the initial RPA code. Based on AI, RPA and AI Agent technologies, the time consumption of generating code annotations can be effectively shortened, and the accuracy of generating code annotations can be effectively improved.
[0078] Figure 2 It is a flowchart of a code annotation generation method based on AI, RPA and AI Agent provided by another embodiment of the present disclosure.
[0079] In this embodiment, the implementation process of the code comment type being full code comment is shown.
[0080] like Figure 2 As shown, the code annotation generation method based on AI, RPA and AI Agent may include the following steps S201 to S209:
[0081] Step S201: Determine the maximum number of tokens supported by the RPA grammar rules and the large model.
[0082] In the embodiments of the present disclosure, the term "token" refers to an element of a single unit (eg, word count) processed by a large model.
[0083] In the embodiment of the present disclosure, the term "maximum number of tokens supported by the large model" refers to the number of elements of a single unit that the large model can process at one time.
[0084] In the embodiments of the present disclosure, the term “RPA grammar rules” refers to grammar rules of a computer program code that implements RPA.
[0085] In some embodiments, the RPA grammar rules can be determined based on a computer program file that implements the RPA code, and the maximum number of tokens supported by the large model can be determined based on a functional description file of the large model.
[0086] Step S202: segment the initial RPA code based on the RPA grammar rules and the maximum number of tokens to obtain multiple RPA code segments, where each RPA code segment includes at least one code structure.
[0087] After determining the RPA grammar rules and the maximum number of tokens supported by the large model, the initial RPA code can be segmented based on the RPA grammar rules and the maximum number of tokens to obtain multiple RPA code segments.
[0088] That is to say, each RPA code segment obtained by segmentation can contain one or more complete code structures, and the large model can support one-time model processing of each RPA code segment, so that when the large model processes the RPA code segment, it can avoid finer-grained segmentation of the RPA code segment due to the limitation of the maximum number of tokens of the model itself, so that the large model can process the RPA code segment containing complete semantics at one time, thereby improving processing consistency and accuracy.
[0089] For example, the initial RPA code can be segmented to obtain multiple RPA code segments, the number of individual unit elements contained in each RPA code segment is less than or equal to the maximum number of tokens supported by the large model, and each RPA code segment is divided with reference to the RPA grammar rules, so that each RPA code segment can contain one or more code structures with complete semantics, supporting the large model to accurately parse each RPA code segment.
[0090] Step S203: taking the RPA code segment as the RPA code to be annotated.
[0091] After obtaining multiple RPA code segments, the RPA code segments can be used as RPA codes to be annotated, and each RPA code to be annotated also includes one or more code structures.
[0092] Step S204: semantically parse at least one code structure based on the large model to obtain semantic content of the RPA code to be annotated.
[0093] After the initial RPA code is segmented based on the RPA grammar rules and the maximum number of tokens to obtain multiple RPA code segments, and one or more code structures contained in each RPA code segment are determined, semantic analysis can be performed on at least one code structure based on a large model to obtain the semantic content of the RPA code to be annotated, wherein the large model can be specifically, for example, a large language model (LLM), which has the ability to identify the semantic content of one or more code structures. The LLM can be pre-trained, and during the training process, a large amount of sample data (including sample RPA code segments, one or more sample code structures contained in the sample RPA code segments, and sample semantic content corresponding to the sample code structures) can be used to train the deep learning model, so that the trained LLM can understand the semantic content of the RPA code to be annotated.
[0094] Step S205: segment the RPA code to be annotated again according to the semantic content to obtain multiple sub-RPA code segments.
[0095] After identifying the semantic content of the RPA code to be annotated, the RPA code to be annotated can be segmented again with reference to the semantic content. For example, the RPA code to be annotated can contain one or more RPA code segments, and at least one of the RPA code segments can be segmented again according to the semantic content to obtain multiple sub-RPA code segments.
[0096] Step S206: Determine the sub-code annotations corresponding to each sub-RPA code segment.
[0097] In the embodiments of the present disclosure, the term “sub-code annotation” refers to an RPA code segment obtained by segmenting the RPA code to be annotated.
[0098] In the embodiments of the present disclosure, the term "sub-code annotation" refers to the annotation content obtained by annotating a sub-RPA code segment.
[0099] After obtaining multiple sub-RPA code segments, each sub-RPA code segment can be annotated to obtain sub-code annotations corresponding to each sub-RPA code segment. For example, each sub-RPA code segment can be processed based on the big model to obtain sub-code annotations output by the big model.
[0100] Step S207: Generate target code annotations based on the sub-code annotations and semantic content.
[0101] In the embodiments of the present disclosure, the term “target code annotation” refers to a code annotation that matches the overall RPA code to be annotated.
[0102] In the disclosed embodiment, since the sub-RPA code segments are obtained by further segmenting the RPA code to be annotated, the above directly processes each sub-RPA code segment to obtain a sub-code annotation corresponding to each sub-RPA code segment. The sub-code annotation can accurately represent the semantics and code logic of the corresponding sub-RPA code segment. In addition, multiple sub-code annotations can be integrated based on the semantic content of the RPA code to be annotated, so that the integrated target code annotation can accurately represent the overall semantic content and code logic of the RPA code to be annotated.
[0103] Step S208: Determine the code annotation position of the RPA code to be annotated.
[0104] Step S209: insert the target code comment into the code comment position in the initial RPA code.
[0105] For the description of steps S208 - S209 , please refer to the above embodiment and will not be repeated here.
[0106] In this embodiment, the RPA code to be annotated is obtained from the initial RPA code based on the code annotation type, wherein the RPA code to be annotated contains at least one code structure, and at least one code structure is processed based on AI and the code annotation type to obtain the target code annotation of the RPA code to be annotated, determine the code annotation position of the RPA code to be annotated, and insert the target code annotation into the code annotation position in the initial RPA code. Based on AI, RPA and AI Agent technology, the time consumption of generating code annotations can be effectively shortened, and the generation accuracy of code annotations can be effectively improved. In addition, each RPA code segment obtained by segmentation can contain one or more complete code structures, and the large model can support one-time model processing of each RPA code segment, so that the large model can avoid finer-grained segmentation of the RPA code segment due to the limitation of the maximum number of tokens of the model itself during the processing of the RPA code segment, so that the large model can process the RPA code segment containing complete semantics at one time, improving the processing consistency and processing accuracy. Since the sub-RPA code segments are obtained by further segmenting the RPA code to be annotated, the above directly processes each sub-RPA code segment to obtain the sub-code annotation corresponding to each sub-RPA code segment. The sub-code annotation can accurately represent the semantics and code logic of the corresponding sub-RPA code segment. In addition, based on the semantic content of the RPA code to be annotated, multiple sub-code annotations can be integrated so that the integrated target code annotation can accurately represent the overall semantic content and code logic of the RPA code to be annotated.
[0107] Figure 3It is a flowchart of a code annotation generation method based on AI, RPA and AI Agent provided by another embodiment of the present disclosure.
[0108] In this embodiment, it is shown that the code comment type is a partial code comment and / or a function comment.
[0109] like Figure 3 As shown, the code annotation generation method based on AI, RPA and AI Agent may include the following steps S301 to S308:
[0110] Step S301: receiving instruction information based on the AI Agent, wherein the instruction information includes code selection information.
[0111] In the embodiments of the present disclosure, the term "code selection information" refers to instruction information for selecting local RPA code from the initial RPA code. The code selection information may specifically be, for example, a function index, name, identifier, etc. of the local RPA code, which is used to select the local RPA code to be annotated from the overall initial RPA code.
[0112] In some embodiments, the instruction information may be input by a user. The instruction information input by the user may be received by the AI Agent without limitation.
[0113] Step S302: Select a first RPA code corresponding to the code selection information from the initial RPA code.
[0114] In the embodiment of the present disclosure, the term “first RPA code” refers to a local RPA code selected by the code selection information.
[0115] Step S303: Identify the code semantics of the first RPA code based on AI.
[0116] After selecting the first RPA code corresponding to the code selection information from the initial RPA code, the first RPA code can be semantically parsed based on the large model to obtain the code semantics of the first RPA code, wherein the large model can be specifically, for example, a large language model (LLM), which can have the ability to recognize the code semantics of the RPA code. The LLM can be pre-trained, and during the training process, a large amount of sample data (including sample RPA code and sample code semantics corresponding to the sample RPA code) can be used to train the deep learning model, so that the trained LLM can understand the code semantics of the first RPA code.
[0117] Step S304: identifying, from the RPA code based on code semantics, a second RPA code that is contextually associated with the first RPA code.
[0118] In the embodiments of the present disclosure, the term "second RPA code" refers to an RPA code that has an association relationship with the first RPA code in terms of functional logic, semantic content, etc., and can also be understood as a context code of the first RPA code.
[0119] After the code semantics carried by the first RPA code are identified based on AI, a second RPA code that is contextually associated with the first RPA code can also be identified from the RPA code based on the code semantics. The identified second RPA code can support improving the accuracy of code annotation recognition.
[0120] Step S305: Mark the first RPA code, and synthesize the marked first RPA code and the second RPA code into the RPA code to be annotated.
[0121] After the second RPA code is identified, the marked first RPA code and the second RPA code may be combined into the RPA code to be annotated.
[0122] Therefore, by receiving instruction information based on AI Agent, wherein the instruction information includes code selection information, and selecting a first RPA code corresponding to the code selection information from the initial RPA code, identifying the code semantics of the first RPA code based on AI, and identifying a second RPA code that is contextually associated with the first RPA code from the RPA code based on the code semantics, marking the first RPA code, and synthesizing the marked first RPA code and the second RPA code into the RPA code to be annotated, it is possible to support improving the accuracy of code annotation recognition.
[0123] Step S306: Process at least one code structure based on AI and code annotation type to obtain target code annotation of the RPA code to be annotated.
[0124] The code comment types in this embodiment may include: partial code comments and / or function comments.
[0125] If the code annotation type is a partial code annotation, at least one code structure is processed based on the AI and the code annotation type to obtain a target code annotation of the RPA code to be annotated, which can be illustrated as follows:
[0126] At least one code structure contained in the second RPA code is processed based on the large model to obtain the context semantics of the second RPA code; based on the code semantics of the first RPA code, the context semantics of the second RPA code, and at least one code structure contained in the first RPA code, the target code annotation is determined. Thus, when the code annotation type is a partial code annotation, the target code annotation of the RPA code to be annotated can be accurately and quickly generated.
[0127] That is to say, the context semantics carried by the second RPA code based on the big model can then be used to generate target code annotations with the help of the context semantics and in combination with the code semantics of the first RPA code and one or more code structures contained in the first RPA code. For example, the target code annotations can be formed by extracting the summary and core content of the aforementioned context semantics and code semantics, processing the summary and core content based on the standardized template of the annotations, and combining one or more code structures in the first RPA code.
[0128] If the code annotation type is a function annotation, at least one code structure is processed based on the AI and the code annotation type to obtain a target code annotation for the RPA code to be annotated, which can be illustrated as follows:
[0129] Based on the large model, at least one code structure contained in the second RPA code is processed to obtain the context semantics of the second RPA code; the function to be annotated is identified from at least one code structure contained in the first RPA code; the first function function information of the function to be annotated is determined based on the code semantics of the first RPA code; the second function function information related to the function to be annotated is identified from the context semantics of the second RPA code; the function annotation corresponding to the function to be annotated is determined based on the first function function information and the second function function information, and the function annotation is used as the target code annotation. Thus, when the code annotation type is a partial code annotation, the target code annotation of the RPA code to be annotated can be accurately and quickly generated.
[0130] Step S307: Determine the code annotation position of the RPA code to be annotated.
[0131] Step S308: insert the target code comment into the code comment position in the initial RPA code.
[0132] For the description of steps S307 - S308 , please refer to the above embodiment for details, which will not be repeated here.
[0133] In this embodiment, the RPA code to be annotated is obtained from the initial RPA code based on the code annotation type, wherein the RPA code to be annotated includes at least one code structure, and at least one code structure is processed based on AI and the code annotation type to obtain the target code annotation of the RPA code to be annotated, determine the code annotation position of the RPA code to be annotated, and insert the target code annotation into the code annotation position in the initial RPA code. Based on AI, RPA and AI Agent technology, the time consumption of generating code annotations can be effectively shortened, and the generation accuracy of code annotations can be effectively improved. By receiving instruction information based on AI Agent, wherein the instruction information includes code selection information, and selecting a first RPA code corresponding to the code selection information from the initial RPA code, identifying the code semantics of the first RPA code based on AI, and identifying a second RPA code that is contextually associated with the first RPA code from the RPA code based on the code semantics, marking the first RPA code, and synthesizing the marked first RPA code and the second RPA code into the RPA code to be annotated, it can support improving the accuracy of code annotation recognition.
[0134] The examples for the above embodiment are as follows:
[0135] You can use the Large Language Model (LLM) to automatically generate business explanations or code comments (also referred to as comments) for RPA code. Based on natural language processing (NLP) technology, it can automatically parse the code logic and generate clear and accurate business explanations or code comments. The implementation process is as follows:
[0136] Automatic comment generation: LLM is used to analyze RPA code and automatically generate comments, reducing the manual workload of developers. High-quality comments: The generated comments are accurate, comprehensive and consistent, improving the readability and maintainability of the code. Intelligent code understanding: LLM has the ability to understand complex code logic and can generate appropriate comments for complex processes. Close to business implementation: It can distinguish between business explanations and code comments to better serve different user groups and development needs.
[0137] like Figure 4 As shown, Figure 4 It is a schematic diagram of the implementation process in the embodiment of the present disclosure.
[0138] Steps for generating business explanations and full code comments (also called full comments):
[0139] Code segmentation: Since large models (also called large language models) usually have a maximum token limit, and when more tokens are input, the return time of large models will be significantly longer. RPA code usually has more lines. Therefore, in order to ensure that access to large models does not exceed the token limit and interact with large models more quickly, RPA code is segmented according to RPA syntax rules and max tokens to ensure that the code is reasonably segmented without destroying the RPA code structure (such as functions, loops, branch judgments, exception handling, etc.), so as to ensure that the large language model can better understand the code structure and semantics.
[0140] Assemble full annotation prompt: You can ask the large model to perform secondary segmentation according to the semantics of the code, generate corresponding business explanations or comments for each segment (an optional example of code comments), and return the results in the specified format.
[0141] Full comment prompt requirement example = """ Divide the code into segments according to business logic and generate business explanations or comments for each segment. The return format is as follows:
[0142] Overall code function description: xxx
[0143] Segment 1: line no int-int
[0144] Function: xxxx
[0145] Segment 2: line no int-int
[0146] Function: xxxx (Important reminder: the generated content is limited to one line, and no line breaks should be generated in the middle))""".
[0147] Then, you can call the big model to generate full comments: pass the assembled full comment prompt to the big language model, and call the big language model to generate business explanations or full code comments.
[0148] Assemble the overall full annotation prompt: Since the code is segmented in the above steps, the large language model is used to assemble the business explanation of each code segment into an overall business explanation based on the business explanation of each code segment generated above. Prompt example:
[0149] Overall business explanation or code comment prompt="""Code function summary, summarize the overall code function description based on each segment function
[0150] The return format is as follows:
[0151] Overall function description: xxx""".
[0152] Call the big model for full annotation summary: give a brief description of the overall business explanation, and pass the overall business explanation or code comment prompt to the big language model for overall business explanation.
[0153] Some code comment generation steps
[0154] Select reasonable context: Since the code semantics selected by the user requires the help of context code to make more reasonable code comments, it is necessary to select reasonable code context according to the token restrictions of the large language model to generate code comments.
[0155] Assembly code comment prompt:
[0156] Partial code comment prompt=""" adds a comment to the specified code. The content in <===Start====>****<===End====> in the code is the code that needs to be commented on. Pay attention to only generate text comments, do not continue writing code or generate other information. Language is required <lang>to generate the result """.
[0157] Call the large model to generate some code comments: pass the assembled prompt to the large language model to generate code comments.
[0158] Function annotation generation steps
[0159] Select reasonable context: Since the code semantics selected by the user requires the help of context code to make more reasonable code comments, it is necessary to select reasonable code context according to the token restrictions of the large language model to generate code comments.
[0160] Assemble function comment prompt:
[0161] Function comment prompt=""" adds comments to the specified function in the code. In the code, the function after <--here is the method that needs to be commented on--> is the function that needs to be commented on. The return format is as follows:
[0162] Function: This is a method that implements the function xxx.
[0163] Input parameters: parameter 1 (string type), parameter 2 (number type)
[0164] Output: Return xxx result """
[0165] Post-processing
[0166] Extracting structured information: Although the large model will return in the required format, the returned information is in plain text. In the disclosed embodiment, rules can also be used to extract structured information, and the extracted content includes:
[0167] Fragment business explanation or code comment
[0168] The starting line number of the fragment
[0169] Insertion position index: insert the comment content according to the line number information obtained in the above process.
[0170] The code comment generation method based on AI, RPA and AI Agent provided in the embodiments of the present disclosure can be applied to a digital employee development assistant (digital employee development intelligent assistant), wherein the digital employee development assistant has intelligent data processing capabilities and an automated code generation mechanism. It can automatically parse and process complex data sets, reducing the reliance on manual programming, thereby reducing labor costs. In addition, the extended command library of the digital employee development assistant can quickly generate computer program code that seamlessly connects with RPA products, improves the code reuse rate, and shortens the development cycle. In addition, the "self-healing" function of the digital employee development assistant can automatically adapt to changes in the user interface, reducing maintenance work and related costs caused by interface updates. When the code comment generation method based on AI, RPA and AI Agent is applied to the digital employee development assistant, the digital employee development assistant can effectively shorten the time-consuming generation of code comments and effectively improve the generation accuracy of code comments with the assistance of AI, RPA and AI Agent technologies.
[0171] Figure 5 This is a structural diagram of a code annotation generation device based on AI, RPA and AI Agent provided by an embodiment of the present disclosure.
[0172] like Figure 5 As shown, the code annotation generating device 50 based on AI, RPA and AI Agent includes:
[0173] The acquisition module 501 is used to acquire the RPA code to be annotated from the initial RPA code based on the code annotation type, wherein the RPA code to be annotated includes at least one code structure.
[0174] The processing module 502 is used to process at least one code structure based on AI and code annotation type to obtain a target code annotation of the RPA code to be annotated.
[0175] The determination module 503 is used to determine the code annotation position of the RPA code to be annotated.
[0176] The inserting module 504 is used to insert the target code comment into the code comment position in the initial RPA code.
[0177] In some embodiments of the present disclosure, the device is applied to an RPA robot.
[0178] In some embodiments of the present disclosure, code comment types include: full code comments;
[0179] Among them, the acquisition module is specifically used for:
[0180] Determine the maximum number of tokens supported by RPA grammar rules and large models;
[0181] The initial RPA code is segmented based on the RPA grammar rule and the maximum number of tokens to obtain multiple RPA code segments, wherein each RPA code segment includes at least one code structure;
[0182] The RPA code snippet is used as the RPA code to be annotated.
[0183] In some embodiments of the present disclosure, code comment types include: full code comments;
[0184] The processing module is specifically used for:
[0185] Perform semantic analysis on at least one code structure based on the big model to obtain semantic content of the RPA code to be annotated;
[0186] The RPA code to be annotated is segmented again according to the semantic content to obtain multiple sub-RPA code segments;
[0187] Determine the sub-code annotations corresponding to each sub-RPA code segment;
[0188] Generate target code comments based on sub-code comments and semantic content.
[0189] In some embodiments of the present disclosure, code annotation types include: partial code annotation and / or function annotation;
[0190] Among them, the acquisition module is specifically used for:
[0191] Receiving instruction information based on the AI Agent, wherein the instruction information includes code selection information;
[0192] selecting a first RPA code corresponding to the code selection information from the initial RPA codes;
[0193] Identify the code semantics of the first RPA code based on AI;
[0194] Identifying, from the RPA code based on code semantics, a second RPA code that is contextually associated with the first RPA code;
[0195] The first RPA code is marked, and the marked first RPA code and the second RPA code are combined into the RPA code to be annotated.
[0196] In some embodiments of the present disclosure, code annotation types include: partial code annotation;
[0197] The processing module is specifically used for:
[0198] Processing at least one code structure included in the second RPA code based on the large model to obtain context semantics of the second RPA code;
[0199] A target code annotation is determined based on code semantics of the first RPA code, context semantics of the second RPA code, and at least one code structure included in the first RPA code.
[0200] In some embodiments of the present disclosure, code annotation types include: function annotations;
[0201] The processing module is specifically used for:
[0202] Processing at least one code structure included in the second RPA code based on the large model to obtain context semantics of the second RPA code;
[0203] Identifying a function to be annotated from at least one code structure included in the first RPA code;
[0204] Determine first function function information of the function to be annotated based on the code semantics of the first RPA code;
[0205] identifying second function functional information related to the function to be annotated from the context semantics of the second RPA code;
[0206] A function annotation corresponding to the function to be annotated is determined based on the first function function information and the second function function information, and the function annotation is used as the target code annotation.
[0207] The functions of each module in each device in the embodiments of the present disclosure can be found in the corresponding description of any of the above methods, and will not be repeated here.
[0208] It should be noted here that the code annotation generation device based on AI, RPA and AI Agent provided by the embodiment of the present disclosure can implement all the method steps implemented by any of the above-mentioned method embodiments, and can achieve the same technical effects. The parts and beneficial effects of this embodiment that are the same as the method embodiment will not be described in detail here.
[0209] In this embodiment, the RPA code to be annotated is obtained from the initial RPA code based on the code annotation type, wherein the RPA code to be annotated includes at least one code structure, and at least one code structure is processed based on AI and the code annotation type to obtain the target code annotation of the RPA code to be annotated, determine the code annotation position of the RPA code to be annotated, and insert the target code annotation into the code annotation position in the initial RPA code. Based on AI, RPA and AI Agent technologies, the time consumption of generating code annotations can be effectively shortened, and the accuracy of generating code annotations can be effectively improved.
[0210] Figure 6 FIG. 1 is a block diagram showing a structure of an electronic device according to an embodiment of the present disclosure. Figure 6 As shown, the electronic device includes: a memory 610 and a processor 620, wherein the memory 610 stores a computer program that can be run on the processor 620. When the processor 620 executes the computer program, the code annotation generation method based on AI, RPA and AI Agent in the above embodiment is implemented. The number of the memory 610 and the processor 620 can be one or more.
[0211] The electronic device also includes:
[0212] The communication interface 630 is used to communicate with external devices and perform data exchange transmission.
[0213] If the memory 610, the processor 620 and the communication interface 630 are implemented independently, the memory 610, the processor 620 and the communication interface 630 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0214] Optionally, in a specific implementation, if the memory 610, the processor 620 and the communication interface 630 are integrated on a chip, the memory 610, the processor 620 and the communication interface 630 can communicate with each other through an internal interface.
[0215] An embodiment of the present disclosure provides a computer-readable storage medium storing a computer program, which implements the method provided in any embodiment of the present disclosure when the program is executed by a processor.
[0216] An embodiment of the present disclosure also provides a chip, which includes a processor for calling and executing instructions stored in the memory from the memory, so that a communication device equipped with the chip executes a method provided by any embodiment of the present disclosure.
[0217] The embodiment of the present disclosure also provides a chip, including: an input interface, an output interface, a processor and a memory. The input interface, the output interface, the processor and the memory are connected through an internal connection path. The processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the method provided in the embodiment of the application.
[0218] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor supporting the advanced RISC machines (ARM) architecture.
[0219] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory, and may also include a non-volatile random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct rambus RAM (DR RAM).
[0220] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the present disclosure is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
[0221] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples, unless they are contradictory.
[0222] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0223] Any process or method description described in the flowchart or otherwise herein can be understood to represent a module, segment or portion of code including one or more executable instructions for implementing the steps of a specific logical function or process. And the scope of the preferred embodiments of the present disclosure includes other implementations, in which the functions may not be performed in the order shown or discussed, including in a substantially simultaneous manner or in a reverse order according to the functions involved.
[0224] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a system including a processor or other system that can fetch instructions from an instruction execution system, apparatus or device and execute instructions), or used in combination with these instruction execution systems, apparatuses or devices.
[0225] It should be understood that the various parts of the present disclosure may be implemented with hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods may be implemented with software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above embodiment method may be completed by instructing the relevant hardware through a program, which may be stored in a computer-readable storage medium, and when the program is executed, includes one or a combination of the steps of the method embodiment.
[0226] In addition, each functional unit in each embodiment of the present disclosure may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the above-mentioned integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium. The storage medium may be a read-only memory, a disk or an optical disk, etc.
[0227] The above is only a specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any technician familiar with the technical field can easily think of various changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.< / lang>
Claims
1. A code comment generation method based on artificial intelligence AI, robotic process automation RPA and digital labor platform intelligent assistant AIAgent, It is characterized in that include: Acquire the RPA code to be annotated from the initial RPA code based on the code annotation type, wherein the RPA code to be annotated includes at least one code structure; Processing the at least one code structure based on AI and the code annotation type to obtain a target code annotation of the RPA code to be annotated; Determining a code annotation position of the RPA code to be annotated; and The target code comment is inserted into the initial RPA code at the code comment position.
2. The method according to claim 1, It is characterized in that The method is performed by an RPA robot.
3. The method according to any one of claims 1 to 2, It is characterized in that The code annotation types include: full code annotation; The obtaining the RPA code to be annotated from the initial RPA code based on the code annotation type includes: Determine the maximum number of tokens supported by RPA grammar rules and large models; Segmenting the initial RPA code based on the RPA grammar rule and the maximum number of tokens to obtain a plurality of RPA code segments, wherein each of the RPA code segments includes at least one code structure; The RPA code segment is used as the RPA code to be annotated.
4. The method according to any one of claims 1 to 2, It is characterized in that The code annotation types include: full code annotation; The processing of the at least one code structure based on AI and the code annotation type to obtain a target code annotation of the RPA code to be annotated includes: Performing semantic analysis on the at least one code structure based on the big model to obtain semantic content of the RPA code to be annotated; Segmenting the RPA code to be annotated again according to the semantic content to obtain multiple sub-RPA code segments; Determining sub-code annotations corresponding to each of the sub-RPA code segments; The target code annotation is generated according to the sub-code annotation and the semantic content.
5. The method according to any one of claims 1 to 2, It is characterized in that The code annotation types include: partial code annotation and / or function annotation; The obtaining the RPA code to be annotated from the initial RPA code based on the code annotation type includes: Receiving instruction information based on the AI Agent, wherein the instruction information includes code selection information; selecting a first RPA code corresponding to the code selection information from the initial RPA codes; Identify the code semantics of the first RPA code based on AI; identifying, from the RPA code based on the code semantics, a second RPA code that is contextually associated with the first RPA code; The first RPA code is marked, and the marked first RPA code and the second RPA code are synthesized into the RPA code to be annotated.
6. The method according to any one of claims 1 to 2, It is characterized in that The code annotation types include: partial code annotation; The processing of the at least one code structure based on AI and the code annotation type to obtain a target code annotation of the RPA code to be annotated includes: Processing at least one code structure included in the second RPA code based on the big model to obtain context semantics of the second RPA code; The target code annotation is determined based on code semantics of the first RPA code, context semantics of the second RPA code, and at least one code structure included in the first RPA code.
7. The method according to any one of claims 1 to 2, It is characterized in that The code annotation types include: function annotation; The processing of the at least one code structure based on AI and the code annotation type to obtain a target code annotation of the RPA code to be annotated includes: Processing at least one code structure included in the second RPA code based on the big model to obtain context semantics of the second RPA code; Identifying a function to be annotated from at least one code structure included in the first RPA code; Determine first function function information of the function to be annotated based on the code semantics of the first RPA code; Identifying second function function information related to the function to be annotated from the context semantics of the second RPA code; A function annotation corresponding to the to-be-annotated function is determined based on the first function function information and the second function function information, and the function annotation is used as the target code annotation.
8. A code comment generation device based on artificial intelligence AI, robotic process automation RPA and digital labor platform intelligent assistant AIAgent, It is characterized in that include: An acquisition module, configured to acquire RPA code to be annotated from the initial RPA code based on the code annotation type, wherein the RPA code to be annotated includes at least one code structure; A processing module, configured to process the at least one code structure based on the AI and the code annotation type to obtain a target code annotation of the RPA code to be annotated; A determination module, used to determine the code annotation position of the RPA code to be annotated; and An insertion module is used to insert the target code comment into the code comment position in the initial RPA code.
9. An electronic device, It is characterized in that include: A processor and a memory, wherein the memory stores instructions, and the instructions are loaded and executed by the processor to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Code annotation generation method and device, electronic equipment, storage medium and product
CN120144167A
Code annotation generation method, device, electronic device, storage medium and product
CN120144167B
Method and apparatus for managing code data, device, and medium
WO2026188421A1
