Understand CodeReviewer tasks and data formats
masterCodeReviewer supports three primary tasks. All tasks utilize a data format containing old_file (the original code), diff_hunk (the code change), and optionally a comment or target.
- Quality Estimation (
cls): Predicts whether a code change is poor and requires a comment. Input:old_file,diff_hunk. - Comment Generation (
msg): Generates a review comment for a change. Input:old_file,diff_hunk. Expected output:comment. - Code Refinement (
ref): Changes the code based on a review comment. Input:old_file,diff_hunk,comment. Expected output:target(the refined code).
Example data structure:
{
"old_file": "import torch",
"diff_hunk": "@@ -1 +1,2 @@\n import torch\n +import torch.nn as nn",
"comment": "I don't think we need to import torch.nn here.",
"target": "import torch"
}{
"old_file": "import torch", # f1
"diff_hunk": "@@ -1 +1,2 @@\n import torch\n +import torch.nn as nn", # f1->f2
"comment": "I don't think we need to import torch.nn here.", # requirements for f2->f3
"target": "import torch" # f3
}