An AI large model-based automatic code review system, method, device and medium

The automated code review system based on AI large models has achieved automation and intelligence in the review of uploaded code, solving the problems of low efficiency and lag in manual review in existing technologies, improving code quality and collaboration efficiency, and enhancing the depth and breadth of code review.

CN119576392BActive Publication Date: 2025-11-21SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411301369.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2025-11-21
Estimated Expiration
2044-09-18

AI Technical Summary

Technical Problem

Current technologies primarily rely on manual methods for code inspection in databases, which is inefficient, prone to delays and omissions, and lacks AI integration technology, making it difficult to guarantee code quality and increasing the likelihood of conflicts.

Method used

An automated code review system based on an AI-powered large model is adopted, including a CI interaction module, an LLM interaction module, a session management module, a pre-inspection module, and a result extraction module. This system automates the process from code submission to review feedback, performs in-depth and broad code reviews through LLM, supports multiple CI tools and LLM, and provides flexible configuration and session management.

Benefits of technology

It improved the efficiency and accuracy of code reviews, enhanced the depth and breadth of code reviews, reduced invalid reviews, improved the collaboration efficiency and code quality of the development team, ensured code quality, and avoided conflicts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576392B_ABST
    Figure CN119576392B_ABST
Patent Text Reader

Abstract

The application provides an automatic code review system, method, device and medium based on an AI large model, belongs to the technical field of code checking, and comprises the following: a CI interaction module which interacts with a CI tool, acquires code related information submitted by a user, and returns code review results to the CI tool; an LLM interaction module which sends code information and an interactive session to an LLM and receives review feedback results returned by the LLM; a session management module which maintains and manages the interactive session with the LLM; a pre-checking module which performs pre-checking before submitting the code information to the LLM; a configuration module which is configured by a user according to requirements; and a result extraction module which extracts code review results from the review feedback results returned by the LLM and returns the code review results to the CI interaction module. The application realizes automatic review of a large model in the library by interacting with the LLM, has high review efficiency, ensures code quality, and avoids code conflicts.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of code inspection technology, specifically relating to an automatic code inspection system, method, device, and medium based on an AI large model. Background Technology

[0002] LLM stands for Large Language Model.

[0003] In the software development process, code merging, also known as code submission, is the process by which each member of the software development team merges their code into the main project repository. Code merging ensures seamless workflow among team members and allows for control over code history. Low-quality code may contain errors, redundancy, or inconsistent coding styles, impacting the overall project quality and requiring more time and resources for fixing and maintaining. Furthermore, code conflicts are inevitable in collaborative environments. Code merging, through code inspection, ensures code quality and stability while preventing conflicts.

[0004] Current code review mechanisms are manual and lack automation. Many potential problems may only be discovered by users after the software is released to the production environment, which not only harms the user experience but may also increase repair costs. Furthermore, manual code review is not only time-consuming but also prone to missing issues. While AI integration technology is already used in relevant R&D management tools or platforms, it is not yet used in the code merging process for adding code to the repository.

[0005] This is a shortcoming of the existing technology. Therefore, it is very necessary to provide an automatic code inspection system, method, device and medium based on AI large model to address the above-mentioned defects in the existing technology. Summary of the Invention

[0006] In the existing code uploading process, code inspection plays a crucial role in ensuring code quality and avoiding code conflicts. However, current code inspection is performed manually, which is inefficient and suffers from delays and omissions. Furthermore, it lacks the integration of AI technology. This invention provides an automatic code inspection system, method, device, and medium based on a large AI model to solve the aforementioned technical problems.

[0007] In a first aspect, the present invention provides an automatic code review system based on an AI large model, comprising: a CI interaction module, which interacts with a CI tool to obtain information related to code submitted by the user and to return and display the code review results to the CI tool;

[0008] The LLM interaction module sends code-related information and interaction sessions to the LLM and receives the inspection feedback results returned by the LLM.

[0009] The session management module maintains and manages the interaction sessions with the LLM.

[0010] The pre-check module performs pre-checks on code-related information before submitting it to the LLM.

[0011] The configuration module allows system users to set configuration files according to their needs, configuring CI tools, user input, and LLM.

[0012] The result extraction module extracts the code review results from the inspection feedback returned by the LLM and returns them to the CI interaction module. By integrating the CI interaction module, LLM interaction module, session management module, pre-inspection module, configuration module, and result extraction module, the system automates the code submission to review feedback process. This system not only improves the efficiency and accuracy of code review but also enhances the depth and breadth of code review through the application of the AI ​​large-scale model LLM. Users can flexibly configure the system according to their needs to adapt to different project environments and review standards, improving the collaboration efficiency and code quality of the development team. Furthermore, the CI interaction module interacts with CI tools through a first interaction interface, which supports several types of CI tools.

[0013] The LLM interaction module interacts with the LLM through a second interaction interface, which supports several types of LLM.

[0014] The configuration module includes:

[0015] The CI tool configuration unit configures the CI tool type, CI tool location, and supported protocols; the user input configuration unit configures the documentation for the code repository entered by software project personnel, as well as the code style guidelines.

[0016] The LLM configuration unit configures the code repository and branches for LLM inspection, sets the LLM type and API key, and enables or disables each LLM via switches. Through the design of the first and second interaction interfaces, the system supports various types of CI tools and LLMs, enhancing system compatibility and scalability. The detailed configuration units within the configuration module allow users to fine-tune the system according to specific needs, including specifying the location, protocol, code repository, and branches of CI tools, thereby improving the system's flexibility and adaptability.

[0017] Furthermore, the session management module includes:

[0018] The basic session management unit manages session content related to code repository documentation and code style requirements;

[0019] The historical session management unit has a pre-set threshold N to manage the first N sessions of code submissions and modification suggestions, and updates them through a sliding window mechanism.

[0020] The new input session management unit manages the current code information, commit information, and the format of the LLM feedback review results. The session management module effectively manages interaction sessions with the LLM, including basic session content, historical session records, and the management of new input sessions. The basic session management unit ensures the accurate delivery of code repository documentation and coding style requirements; the historical session management unit keeps the most recent N sessions updated through a sliding window mechanism, helping to track historical changes in code reviews; the new input session management unit focuses on the format management of the current commit's code information and LLM feedback results, ensuring a smooth review process. These features collectively enhance the consistency and traceability of code reviews.

[0021] Furthermore, the pre-inspection module includes:

[0022] The pre-screening unit uses regular expressions to check the user-submitted code information and identify whether it conforms to the user's predefined specifications.

[0023] The post-check submission unit submits the code to the LLM when the relevant information of the user-submitted code conforms to the user's predefined specifications.

[0024] The post-check return unit returns a failure message and a reminder to resubmit after modification when the user's submitted code does not conform to the user's predefined specifications, using CI tools. The pre-check module enables rapid checking and filtering of user-submitted code. The pre-check unit uses regular expressions to ensure code conforms to user-defined specifications, effectively reducing invalid submissions and erroneous reviews. The post-check submission unit, after passing the pre-check, submits the code to the LLM for further review, improving the efficiency and accuracy of the review process. The post-check return unit, when the pre-check fails, returns a clear failure message and modification suggestions to the user through CI tools, guiding them to perform the correct submission operation and improving the user experience.

[0025] Furthermore, the results extraction module extracts modification suggestions and comment information from the inspection feedback results returned by LLM and provides them to the CI interaction module;

[0026] The CI interaction module integrates modification suggestions and comments into a format supported by the CI tool and returns it for display. The results extraction module accurately extracts modification suggestions and comments from the review feedback returned by the LLM and integrates this information into a format supported by the CI tool through the CI interaction module. This design allows code review results to be presented intuitively to users, facilitating quick understanding and appropriate improvement measures. Simultaneously, the support of the CI interaction module ensures that review results can be seamlessly integrated into the existing CI process, improving the automation level of the overall development process.

[0027] Secondly, the present invention provides an automatic code inspection method based on an AI large model, comprising the following steps: S1. The system user sets the configuration file according to the requirements, and configures the CI tool, user input and LLM;

[0028] S2. After the system starts, the CI interaction module interacts with the CI tools to obtain information related to the code submitted by the user;

[0029] S3. The pre-check module performs a pre-check on code-related information;

[0030] The S4.LLM interaction module sends the code information that has passed the pre-check to the LLM and provides the inspection feedback results returned by the LLM to the result extraction module. At the same time, the session management module maintains and manages the interaction session between the LLM module and the LLM.

[0031] S5. After the result extraction module extracts the code review results from the inspection feedback results, the CI interaction module returns them and displays the code review results to the user through CI tools.

[0032] Furthermore, the specific steps of step S1 are as follows:

[0033] S11. Obtain and configure the documentation and code style guidelines for the code repository output by the software project personnel;

[0034] S12. Configure the CI tool type, CI tool location, and supported protocols;

[0035] S13. Configure the code repository and branches for inspecting LLMs, configure LLM types and API keys, and enable or disable each LLM using switches;

[0036] The specific steps of step S2 are as follows:

[0037] S21. The system starts running and sets up the webhook service for the corresponding CI tool according to the configured CI tool type and CI tool location;

[0038] The S22.CI tool uses a webhook service to trigger the identification of user code modifications.

[0039] The S23.CI tool triggers the identification of code-related information submitted by users through a webhook service.

[0040] The S24.CI interaction module receives webhook service requests, obtains relevant information about the code submitted by the user, and provides it to the pre-inspection module.

[0041] The specific steps of step S3 are as follows:

[0042] S31. The pre-inspection module obtains information related to the code submitted by the user and identifies whether the code-related information matches the code repository and branch inspected by LLM based on the configuration file.

[0043] If so, proceed to step S32;

[0044] If not, do not process, print the log record, and end;

[0045] S32. The preflight module identifies the code change context and commit information from code-related information and determines whether the commit information conforms to the user-defined specifications;

[0046] If so, proceed to step S34;

[0047] If not, return to step S22. This invention, through the integration of CI tools and LLM, and the setting of a pre-screening module, effectively reduces invalid reviews and improves review quality. Simultaneously, this method provides flexible configuration options and a session management mechanism, enabling users to adjust the review process according to their own needs, thereby improving system applicability and user satisfaction.

[0048] Furthermore, the specific steps of step S4 are as follows:

[0049] The S41.LLM interactive module determines whether the submission information contains code style guidance documentation.

[0050] If so, add the code style guidance document type to the message to be sent and proceed to step S44;

[0051] If not, proceed to step S42;

[0052] The S42.LLM interactive module determines whether the submission information contains a path to a code style guidance document;

[0053] If so, add the path to the code style guidance document to the message to be sent, and proceed to step S44;

[0054] If not, proceed to step S43;

[0055] S43. Do not add code style-related content to the message to be sent;

[0056] The S44.LLM interaction module integrates the messages to be sent and sends them to the LLM;

[0057] The S45.LLM interaction module obtains the inspection feedback results returned by the LLM and provides them to the result extraction module;

[0058] S46. The conversation management module updates the content of this conversation to the conversation history of the code repository and displays the updated content according to the preset quantity threshold N.

[0059] The specific steps of step S5 are as follows:

[0060] S51. The results extraction module extracts the code review results from the inspection feedback results;

[0061] S52. The result extraction module identifies whether there are any modification suggestions in the code review results;

[0062] If so, return to step S22;

[0063] If not, the process ends. This invention, through flexible handling of code style guidelines and meticulous analysis of review results, further enhances the targeting and effectiveness of code reviews. Before sending code information to the LLM, the method dynamically adjusts the information to be sent based on whether the submission includes code style guidelines or their paths, ensuring that the LLM can conduct reviews based on accurate context. In the result extraction phase, by identifying modification suggestions in the review results and deciding whether to re-trigger the review process, this method achieves closed-loop control of the review process, improving the iteration speed and accuracy of reviews.

[0064] Thirdly, the present invention provides an electronic device, a processor, and a memory;

[0065] The memory is used to store computer programs, and the processor is used to retrieve and run the computer programs from the memory, causing the electronic device to perform the method described in the second aspect above.

[0066] Fourthly, the present invention provides a storage medium,

[0067] The storage medium stores instructions that, when run on a computer, cause the computer to perform the method described in the second aspect above.

[0068] The beneficial effects of this invention are as follows:

[0069] This invention provides an automated code review system, method, device, and medium based on an AI large-scale model. Through interaction with an LLM (Large-Scale Management Library), it achieves automated review of large-scale models in the database, resulting in high review efficiency, ensuring code quality, and avoiding code conflicts. The invention provides a UI interface for users to directly upload configuration files, enabling rapid identification of code defects and modification suggestions through the LLM. Optimized dialogue management functions reduce token consumption, improving cost-effectiveness. This invention effectively reduces invalid code review and improves review quality. Furthermore, through the application of an AI large-scale model LLM, it enhances the depth and breadth of code review.

[0070] Furthermore, the design principle of this invention is reliable, the structure is simple, and it has a very wide range of application prospects.

[0071] Therefore, it is evident that the present invention has outstanding substantive features and significant progress compared with the prior art, and the beneficial effects of its implementation are also obvious. Attached Figure Description

[0072] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0073] Figure 1 This is a schematic diagram of the automatic code inspection system based on AI large model of the present invention.

[0074] Figure 2 This is a flowchart illustrating the automatic code inspection method based on a large AI model according to the present invention. Detailed Implementation

[0075] The AI-based large-scale model-based automatic code inspection method can be applied to one or more devices. The device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0076] Electronic devices can be any electronic product capable of human-computer interaction, such as personal computers, tablets, smartphones, personal digital assistants (PDAs), and interactive network television (IPTV). The networks on which electronic devices operate include, but are not limited to, the Internet, wide area networks (WANs), metropolitan area networks (MANs), local area networks (LANs), and virtual private networks (VPNs).

[0077] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0078] Please see Figure 1 The image shows an automated code review system based on an AI large model in a specific implementation, including: a CI interaction module, which interacts with CI tools to obtain information related to the code submitted by the user and returns the code review results to the CI tools for display;

[0079] The LLM interaction module sends code-related information and interaction sessions to the LLM and receives the inspection feedback results returned by the LLM.

[0080] The session management module maintains and manages the interaction sessions with the LLM.

[0081] The pre-check module performs pre-checks on code-related information before submitting it to the LLM.

[0082] The configuration module allows system users to set configuration files according to their needs, configuring CI tools, user input, and LLM.

[0083] The results extraction module extracts the code review results from the inspection feedback results returned by LLM and returns the code review results to the CI interaction module.

[0084] This invention relates to an automated large-scale model inspection system based on AI large-scale models. It serves as an intermediate layer between current CI tools, such as Gerrit and GitLab, and LLM (Large Module Management). The system checks the code in the uploaded library by calling the LLM large-scale model and submits inspection suggestions. This invention supports integration with mainstream CI tools such as Gerrit / GitLab, inspecting large-scale models in the uploaded library using the LLM large-scale model. The inspection results are displayed on the relevant review interface of the CI tool. This invention supports various LLM large-scale models.

[0085] In this invention, the CI interaction module is mainly responsible for interacting with CI tools such as Gerrit and GitLab to obtain submission-related information, and can support multiple CI tools; the LLM interaction module is mainly responsible for sending relevant information to the LLM and obtaining the LLM's review feedback results, and can support multiple LLMs simultaneously; the session management module is mainly responsible for maintaining the information content sent to the LLM; the pre-check module is mainly responsible for checking the relevant information of the submitted code, and will not interact with the LLM if it fails; the configuration module is mainly responsible for the user's configuration of this system, including CI tool-related configuration, user input configuration, and LLM-related configuration; the result extraction module is used to extract code review results from the LLM feedback results and send them to the CI tool through the CI interaction module, prompting the CI tool to display the code review results.

[0086] This invention automates the code submission and review feedback process by integrating a CI interaction module, an LLM interaction module, a session management module, a pre-inspection module, a configuration module, and a result extraction module. This system not only improves the efficiency and accuracy of code review but also enhances the depth and breadth of code review through the application of an AI large-scale model LLM. Users can flexibly configure the system according to their needs to adapt to different project environments and review standards, thereby improving the collaboration efficiency and code quality of development teams.

[0087] In this embodiment, the CI interaction module interacts with the CI tool through a first interaction interface, which supports several types of CI tools.

[0088] The LLM interaction module interacts with the LLM through a second interaction interface, which supports several types of LLM.

[0089] It's worth noting that when developers submit code, this system uses the Flask framework as the receiving end. It notifies the receiving end of the submission by setting up webhook services for CI tools like Gerrit / Gitlab. For example, in the CI interaction module, this system updates the Gerrit webhooks.config file by sending a PUT request, adding a subscription to the patchset-created event. The branch parameter can be used to specify the triggering branch. Similarly, for Gitlab, webhooks are created using the project ID and the / projects / :id / hooks endpoint, and can be set to be triggered by push_events, with branch_filter specifying the triggering branch.

[0090] When a developer submits code using `git push`, it triggers a Gerrit / Gitlab Webhook to send an HTTP POST request to the system. This request contains patch information, including repo, branch, change, revision, and owner.

[0091] Based on the revision information of the patch set, request the diff information (REST API parameter is diff?context=100) and commit information (REST API parameter is commit) from Gerrit for this submission;

[0092] The corresponding GitLab method is:

[0093] projects / $PROJECT_ID / merge_requests / $MERGE_REQUEST_IID / diff? context_line=100 and / projects / :id / merge_requests / :merge_request_iid / commits;

[0094] The configuration module includes:

[0095] The CI tool configuration unit configures the CI tool type, CI tool location, and supported protocols; the user input configuration unit configures the documentation for the code repository entered by software project personnel, as well as the code style guidelines.

[0096] The documentation for the code repository details the directory structure, the main purpose of each code file, the functional logic of the main interfaces, and their inputs and outputs. The level of detail in this documentation is determined by the user, and if necessary, it can describe the implementation logic of all functions for key functions and their calling relationships.

[0097] The code style guidelines can be specified as well-known industry code style standards, such as PEP8 or Google Java Style, or you can define your own relevant standards and describe them clearly in the documentation.

[0098] The LLM configuration unit configures the code repository and branches for LLM inspection, configures the LLM type and API key, and enables or disables each LLM through switches.

[0099] The configuration file also includes configuration of the CI tool type, such as Gerrit / Gitlab or other CI tools; and configuration of the CI tool's URL;

[0100] The configuration file also includes configuration of the documentation path and the code style guide path. Through the configuration file, this invention supports multiple LLMs and hides the configuration differences between multiple LLMs. Each LLM is enabled by configuring the enabled field.

[0101] The session management module includes:

[0102] The basic session management unit manages session content related to code repository documentation and code style requirements;

[0103] The historical session management unit has a pre-set threshold N to manage the first N sessions of code submissions and modification suggestions, and updates them through a sliding window mechanism.

[0104] The new input session management unit manages the session for the current code information, commit information, and the format of the LLM feedback review results.

[0105] If the commit information meets expectations, then send the conversation-related message to the LLM.

[0106] The session management module maintains a conversation information structure, which includes user-provided LLM_Model information (such as LLM-related information in the configuration file), repo information (the repo and branch that are being followed), and message information.

[0107] Specifically, the LLM_Model information is used for authentication when connecting with the LLM, the repo information is used by this system to determine whether to respond to the Gerrit webhook, and the messages information is the token sent to the LLM.

[0108] The messages consist of three parts. The first part is Basic_Conversation, which contains the documentation and code style requirements for the corresponding repository to be sent beforehand. If the configuration file sets the code style requirement code_style_guide_type, then that type will be sent directly to the LLM. If it is null, then the code_style_guide_path document will be used. This system will convert the documentation and code style document into text and store them. If both code_style_guide_type and code_style_guide_path are null, then the code style review requirement will not be sent to the LLM.

[0109] The second part is History_Conversation, which is a sliding window containing the first ten commit messages and the returned modification suggestions. When the stored content has been interacted with ten times, the last interaction history is discarded, and the latest New_Input and its corresponding modification suggestions are stored.

[0110] The third part is New_Input, which contains specific code information and commit-related information for this submission. In addition, the LLM is required to provide feedback according to a specific format: for review results, fix_suggestions / message correspond to the definitions in Gerrit CommentInfo: fix_suggestions: Suggested fixes for this comment, and message: The comment message. For example: "Please review content of the code displayed in Gerrit diff format and feedback in the Gerrit FixSuggestionInfoformat"; for GitLab, the LLM is required to provide review results feedback according to the note, path, line (or line_range), and line_type formats.

[0111] The commit information is obtained from Gerrit or GitLab APIs. Gerrit uses two methods: one is "GET changes / {change-id} / revisions / {revision-id} / commit" to retrieve commit-related information, including the commit message; the other is "GET / changes / {change-id} / revisions / {revision-id} / files / {file-id} / diff?context=100" to retrieve the code changes before and after the commit, along with the corresponding 100 lines of context. The corresponding GitLab information method is as follows:

[0112] / projects / :id / merge_requests / :merge_request_iid / commits and

[0113] projects / $PROJECT_ID / merge_requests / $MERGE_REQUEST_IID / diff?

[0114] context_line = 100

[0115] The pre-inspection module includes:

[0116] The pre-screening unit uses regular expressions to check the user-submitted code information and identify whether it conforms to the user's predefined specifications.

[0117] The post-check submission unit submits the code to the LLM when the relevant information of the user-submitted code conforms to the user's predefined specifications.

[0118] After receiving an HTTP POST request for patch information, this system determines whether repo+branch is the target of this system's inspection. If it is, it proceeds to the next step; otherwise, it returns directly and logs the information. Information such as repo+branch is set in the configuration file, and users can configure it according to their needs. repo is the code repository, and branch is the branch.

[0119] This system uses regular expression scripts to determine whether the commit information conforms to the user-defined specifications. If it does not conform, the review information is refreshed and the commit message check failed.

[0120] The method to return the review-2 result is as follows: POST / changes / {change-id} / revisions / {revision-id} / review: "Code-Review": -1; "message": commit message check failed. Developers can modify the commit message using `git commit --amend` and resubmit. For GitLab, use the endpoint ` / projects / :id / merge_requests / :merge_request_iid / notes` to create a global comment, with the same content: "commit message check failed".

[0121] It should be noted that developers need to fill in the commit message according to the following specifications when submitting, including the commit subject, a description of the reason for the commit, etc.:

[0122] <type> ( <scope> ): <subject> / / part1:Header;

[0123] / *blank line* /

[0124] Why: Reason for submission / / part2:Body What: Description of changes made / / part2:Body What: Description of changes made

[0125] The concepts of Header, type, scope, subject, and Body mentioned above are consistent with the definitions in Angular's commit message specification.

[0126] After inspection, the return unit will return inspection failure information and a reminder message to resubmit the code after modification through the CI tool when the relevant information of the user's submitted code does not conform to the user's predefined specifications.

[0127] The results extraction module extracts modification suggestions and comments from the inspection feedback results returned by LLM and provides them to the CI interaction module;

[0128] After receiving the LLM response, the returned content is evaluated; finally, keywords are extracted from "description" and "replacement" in the newly added fix_suggestions in the Gerrit CommentInfo entity.

[0129] The CI interaction module integrates modification suggestions and comments into a format supported by the CI tool and returns it to the CI tool for display.

[0130] For Gerrit, the inspection results are returned via the Gerrit CommentInfo interface. For GitLab, the inspection results are returned to GitLab via curlPOST with the relevant note attributes: note, path, line (or line_range), and line_type.

[0131] Developers determine whether the review results need modification. If modification is required, they use `git commit --amend` to modify the code and recommit, which will trigger another review. If no code modification is needed, the review process ends.

[0132] The following are embodiments of the automatic code inspection method based on AI large model provided in this disclosure. This method and the automatic code inspection system based on AI large model in the above embodiments belong to the same inventive concept. For details not described in detail in the embodiments of the automatic code inspection system based on AI large model, please refer to the embodiments of the automatic code inspection method based on AI large model described above.

[0133] like Figure 2 As shown, the method includes the following steps:

[0134] S1. System users configure the configuration file according to their needs, including CI tools, user input, and LLM;

[0135] S2. After the system starts, the CI interaction module interacts with the CI tools to obtain information related to the code submitted by the user;

[0136] S3. The pre-check module performs a pre-check on code-related information;

[0137] The S4.LLM interaction module sends the code information that has passed the pre-check to the LLM and provides the inspection feedback results returned by the LLM to the result extraction module. At the same time, the session management module maintains and manages the interaction session between the LLM module and the LLM.

[0138] S5. After the result extraction module extracts the code review results from the inspection feedback results, the CI interaction module returns them and displays the code review results to the user through CI tools.

[0139] This invention presents an automated code review method based on an AI large-scale model, which automates and intelligently performs code review through a series of detailed steps. From system configuration, code information acquisition, pre-inspection, LLM interaction, result extraction to the final result display, each step is carefully designed to ensure the accuracy and efficiency of the review.

[0140] In this embodiment, step S1 is specifically as follows:

[0141] S11. Obtain and configure the documentation and code style guidelines for the code repository output by the software project personnel;

[0142] S12. Configure the CI tool type, CI tool location, and supported protocols;

[0143] S13. Configure the code repository and branches for inspecting LLMs, configure LLM types and API keys, and enable or disable each LLM using switches;

[0144] The specific steps of step S2 are as follows:

[0145] S21. The system starts running and sets up the webhook service for the corresponding CI tool according to the configured CI tool type and CI tool location;

[0146] The S22.CI tool uses a webhook service to trigger the identification of user code modifications.

[0147] The S23.CI tool triggers the identification of code-related information submitted by users through a webhook service.

[0148] The S24.CI interaction module receives webhook service requests, obtains relevant information about the code submitted by the user, and provides it to the pre-inspection module.

[0149] The webhook informs the system of basic submission information;

[0150] The specific steps of step S3 are as follows:

[0151] S31. The pre-inspection module obtains information related to the code submitted by the user and identifies whether the code-related information matches the code repository and branch inspected by LLM based on the configuration file.

[0152] If so, proceed to step S32;

[0153] If not, do not process, print the log record, and end;

[0154] Check if the repository and branch information in the submission message are consistent with the configuration file. If they are inconsistent, log the information and do not process it.

[0155] S32. The preflight module identifies the code change context and commit information from code-related information and determines whether the commit information conforms to the user-defined specifications;

[0156] If so, proceed to step S34;

[0157] If not, return to step S22;

[0158] Based on the basic commit information (refs information, or MRIID information for GitLab), request the code changes and context for this commit, and the commit message information;

[0159] Check if the commit message complies with the rules. If it does not, refresh the review information and indicate "commit message check failed," requiring the developer to make modifications.

[0160] The specific steps of step S4 are as follows:

[0161] The S41.LLM interactive module determines whether the submission information contains code style guidance documentation.

[0162] If so, add the code style guidance document type to the message to be sent and proceed to step S44;

[0163] If not, proceed to step S42;

[0164] The S42.LLM interactive module determines whether the submission information contains a path to a code style guidance document;

[0165] If so, add the path to the code style guidance document to the message to be sent, and proceed to step S44;

[0166] If not, proceed to step S43;

[0167] S43. Do not add code style-related content to the message to be sent;

[0168] Check if code_style_guide_type is null. If it is not null, send a message containing code_style_guide_type to the LLM. If it is null, proceed to the next step of checking code_style_guide_path.

[0169] Check if code_style_guide_path is null. If it is not null, send a message containing code_style_guide_path to the LLM. If it is null, the message does not contain any code style information. The S44.LLM interaction module integrates the messages to be sent and sends them to the LLM.

[0170] It should be noted that the LLM and LLM type are determined according to the configuration file. The corresponding type of LLM is determined according to the configuration file to inspect the code repository and branch, configure the API key, use the API key to authenticate the user to which the LLM interaction module to send the message belongs, and after successful authentication, the LLM analyzes the message sent by the LLM interaction module to identify the code change context, commit information, code repository documentation, and code style related content.

[0171] LLM reviews the code change context based on code rules, and when code style-related content exists, it retrieves the corresponding type of guidance document based on the guidance document path, performs an internal review of the code change context based on the guidance document, and adds the code change context to the corresponding branch of the corresponding code repository according to the code repository documentation after the review is passed, while generating the review results.

[0172] The S45.LLM interaction module obtains the inspection feedback results returned by the LLM and provides them to the result extraction module;

[0173] S46. The conversation management module updates the content of this conversation to the conversation history of the code repository and displays the updated content according to the preset quantity threshold N.

[0174] The specific steps of step S5 are as follows:

[0175] S51. The results extraction module extracts the code review results from the inspection feedback results;

[0176] S52. The result extraction module identifies whether there are any modification suggestions in the code review results;

[0177] If so, return to step S22;

[0178] If not, end;

[0179] Obtain the inspection suggestions returned by LLM and feed the results back to Gerrit / Gitlab;

[0180] Developers assess the review suggestions; if modifications are needed, they return to step S22; otherwise, the process ends. This invention, through the integration of CI tools with LLM and the setting of a pre-inspection module, effectively reduces invalid reviews and improves review quality. Simultaneously, this method provides flexible configuration options and a session management mechanism, allowing users to adjust the review process according to their needs, improving system applicability and user satisfaction. Through flexible handling of code style guidance documents and detailed analysis of review results, this method further enhances the targeting and effectiveness of code reviews. Before sending code information to the LLM, the information to be sent is dynamically adjusted based on whether the submission information contains code style guidance documents or paths, ensuring that the LLM can conduct reviews based on accurate context. In the result extraction stage, by identifying modification suggestions in the review results and deciding whether to re-trigger the review process, this method achieves closed-loop control of the review process, improving the iteration speed and accuracy of reviews.

[0181] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0182] The automatic code inspection method based on large AI models provided by this invention comprises modules and algorithmic steps of various examples described in conjunction with the embodiments disclosed herein. These modules and steps can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0183] Those skilled in the art will understand that the various aspects of the AI-based large-scale model-based automatic code inspection method provided by this invention can be implemented as a system, method, or program product. Therefore, the various aspects of this disclosure can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, collectively referred to herein as a "circuit," "module," or "system."

[0184] In a non-transitory computer-readable storage medium storing an automated code inspection method based on a large AI model, the medium may be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0185] Although the present invention has been described in detail with reference to the accompanying drawings and preferred embodiments, the present invention is not limited thereto. Various equivalent modifications or substitutions can be made to the embodiments of the present invention by those skilled in the art without departing from the spirit and essence of the invention, and such modifications or substitutions should all be within the scope of the present invention. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should also be covered within the protection scope of the present invention.< / subject> < / scope> < / type>

Claims

1. An AI large model-based automatic code review system, characterized in that, Comprise: CI interaction module, through interacting with CI tool, obtaining user submitted code related information and returning code review result to CI tool for display; CI interaction module interacts with CI tool through first interaction interface, and the first interaction interface supports several types of CI tools; LLM interaction module sends code related information and interaction session to LLM, and receives review feedback result returned by LLM; LLM interaction module interacts with LLM through second interaction interface, and the second interaction interface supports several types of LLM; Session management module maintains and manages the interaction session with LLM; Session management module comprises: Basic session management unit, managing the session content of the specification document of the code repository and the code style requirement; History session management unit, pre-setting a quantity threshold N, managing the first N submitted code information and returned modification suggestion session, and updating through sliding window mechanism; New input session management unit, managing the session of the current code information and submission information and the format of LLM feedback review result; Pre-check module, pre-checking before submitting code related information to LLM; Configuration module, system user sets configuration file according to demand, and configures CI tool, user input and LLM; Configuration module comprises: CI tool configuration unit, configuring CI tool type, CI tool position and supported protocol; User input configuration unit, configuring the specification document of the code repository and the guidance document of the code style input by the software project personnel; LLM configuration unit, configuring the code repository and branch for LLM review, configuring LLM type and API key, and enabling or disabling each LLM through switch; Result extraction module extracts code review result from review feedback result returned by LLM, and returns the code review result to CI interaction module.

2. The AI large model-based automatic code review system of claim 1, wherein, Pre-check module comprises: Pre-check unit, checking user submitted code information through regular expression, and identifying whether it conforms to user pre-defined specification; After checking and submitting unit, when the code related information submitted by the user conforms to the specification pre-defined by the user, submitting to LLM; After checking and returning unit, when the code related information submitted by the user does not conform to the specification pre-defined by the user, returning review failure information and reminding information of re-submitting after modification through CI tool. 3.The AI large model-based automatic code review system of claim 1, wherein Result extraction module extracts modification suggestion and comment information from review feedback result returned by LLM, and provides it to CI interaction module; CI interaction module integrates modification suggestion and comment information into format supported by CI tool, and returns it to CI tool for display.

4. An AI large model-based automatic code review method, characterized by, Comprise the following steps: S1. System user sets configuration file according to demand, and configures CI tool, user input and LLM; Step S1 comprises the following steps: S11. Obtain the specification document of the code repository and the guidance document of the code style input by the software project personnel and configure them; S12. Configure CI tool type and CI tool position and supported protocol; S13. Configure the code repository and branch for review of the LLM, configure the LLM type and API key, and enable or disable each LLM through a switch; S2. After the system starts, the CI interaction module obtains the code-related information submitted by the user by interacting with the CI tool; the specific steps of step S2 are as follows: S21. After the system starts running, set the webhook service of the corresponding CI tool according to the configured CI tool type and the location of the CI tool; S22. The CI tool triggers the identification of the user's modified code through the webhook service; S23. The CI tool triggers the identification of the code-related information submitted by the user through the webhook service; S24. The CI interaction module receives the webhook service request, obtains the code-related information submitted by the user, and provides it to the pre-check module; S3. The pre-check module performs pre-checking on the code-related information; the specific steps of step S3 are as follows: S31. The pre-check module obtains the code-related information submitted by the user, and identifies whether the code-related information matches the code repository and branch for review of the LLM according to the configuration file; If yes, go to step S32; If no, do not process, print log record, and end; S32. The pre-check module identifies the code change context and submission information from the code-related information, and judges whether the submission information conforms to the user's pre-defined specification; If yes, go to step S34; If no, return to step S22; S4. The LLM interaction module sends the code-related information that passes the pre-check to the LLM, and provides the review feedback returned by the LLM to the result extraction module, while the session management module maintains and manages the interaction session of the LLM module and the LLM; the specific steps of step S4 are as follows: S41. The LLM interaction module judges whether the submission information contains a code style guide document type; If yes, add the code style guide document type to the to-be-sent information, and go to step S44; If no, go to step S42; S42. The LLM interaction module judges whether the submission information contains a code style guide document path; If yes, add the code style guide document path to the to-be-sent information, and go to step S44; If no, go to step S43; S43. Do not add code style-related content in the to-be-sent information; S44. The LLM interaction module sends the integrated to-be-sent message to the LLM; S45. The LLM interaction module obtains the review feedback returned by the LLM and provides it to the result extraction module; S46. The session management module updates the content of this time to the conversation history of the code repository, and displays the update according to the pre-set quantity threshold N; S5. After the result extraction module extracts the code review result from the review feedback result, the CI interaction module returns, and the CI interaction module displays the code review result to the user through the CI tool; the specific steps of step S5 are as follows: S51. The result extraction module extracts the code review result from the review feedback result; S52. The result extraction module identifies whether there is a modification suggestion in the code review result; If yes, return to step S22; If no, end.

5. An electronic device, comprising: A processor and a memory; The memory is configured to store a computer program, and the processor is configured to call and run the computer program from the memory, so that the electronic device executes the method in claim 4.

6. A storage medium, characterized in that, The storage medium has instructions stored therein, and when the instructions are run on a computer, the computer executes the method in claim 4.

Citation Information

Patent Citations

  • Code submission method and equipment

    CN106484606A

  • Code auditing method, system and equipment based on GitLab and medium

    CN118585451A