Skip to content

Commit

Permalink
Merge pull request #308 from Cloud-Code-AI/305-bug-merging-summary-do…
Browse files Browse the repository at this point in the history
…esnt-work-as-expected

bugfix: description generation bug fix
  • Loading branch information
sauravpanda authored Jul 8, 2024
2 parents b973bbc + f5a014e commit c3cbb9b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 14 deletions.
2 changes: 1 addition & 1 deletion kaizen/generator/pr_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _process_files(
user,
reeval_response,
):
file_descs.extend(file_descs)
file_descs.extend(file_review)

prompt = MERGE_PR_DESCRIPTION_PROMPT.format(DESCS=json.dumps(file_descs))
resp, usage = self.provider.chat_completion_with_json(prompt, user=user)
Expand Down
59 changes: 47 additions & 12 deletions kaizen/llms/prompts/code_review_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"comment": "<CONSICE_COMMENT_ON_WHATS_THE_ISSUE>",
"confidence": "<CONFIDENCE_LEVEL>",
"reason": "<YOUR_REASON_FOR_COMMENTING_THIS_ISSUE>"
"solution": "<SOLUTION_TO_THE_COMMENT>",
"solution": "<HIGH_LEVEL_SOLUTION>",
"fixed_code": "<FIXED_CODE>",
"start_line": "<CODE_START_LINE_INTEGER>",
"end_line": "<CODE_END_LINE_INTEGER>",
Expand All @@ -26,14 +26,25 @@
]
}}
For "solution", create a solution comment with actual code fix shown as markdown.
For "solution", create a solution comment with high level solution to this issue.
For "fixed_code", generated the fixed code script to replace the commented line. make sure you replace the exact changes code between start_line and end_line.
For "start_line", The line of the blob in the pull request diff that the comment applies to. Make sure "fixed_code" starts from this line.
For "end_line", this is the end line of the blob where pull request applies. Make sure the "fixed_code" ends at this line.
For "start_line", The first line of the code in that the comment applies to. Make sure "fixed_code" starts from this line.
For "end_line", this is the last line of the code that the comment applies to. Make sure the "fixed_code" ends at this line.
For "side", provide the side as LEFT or RIGHT based on deleted or added lines respectively. Need this for github review comment.
For "file_name" make sure to give the whole path so that developers can know exactly which file has issue.
For "severity_level" score in range of 1 to 10, 1 being not severe and 10 being critical.
Process the given patch data. Identify lines beginning with '+' (excluding the file header line starting with '+++') as additions.
Make sure the "fixed_code" applied to addition lines only.
When generating the description:
- Create a concise and clear summary highlighting the main purpose of the pull request.
- Use markdown formatting in the detailed description for better readability.
- Organize the details into relevant sections or bullet points.
- Focus on the most significant aspects of the changes.
- Avoid repeating information already present in the pull request ti
Confidence Levels based on severity of the issue:
[
"critical",
Expand Down Expand Up @@ -75,7 +86,7 @@
Pull Request Title: {PULL_REQUEST_TITLE}
Pull Request Description: {PULL_REQUEST_DESC}
Code Diff:
PATCH DATA:
```{CODE_DIFF}```
"""

Expand All @@ -90,7 +101,7 @@
"comment": "<CONSICE_COMMENT_ON_WHATS_THE_ISSUE>",
"confidence": "<CONFIDENCE_LEVEL>",
"reason": "<YOUR_REASON_FOR_COMMENTING_THIS_ISSUE>"
"solution": "<SOLUTION_TO_THE_COMMENT>",
"solution": "<HIGH_LEVEL_SOLUTION>",
"fixed_code": "<FIXED_CODE>",
"start_line": "<CODE_START_LINE_INTEGER>",
"end_line": "<CODE_END_LINE_INTEGER>",
Expand All @@ -100,17 +111,41 @@
"severity_level": <INTEGER_FROM_1_TO_10>
}},
...
]
],
"desc": "
### Summary
<Brief one-line summary of the pull request>
### Details
<Detailed multi-line description in markdown format>
- List of key changes
- New features
- Refactoring details
"
}}
For "solution", create a solution comment with actual code fix shown as markdown.
For "solution", create a solution comment with high level solution to this issue.
For "fixed_code", generated the fixed code script to replace the commented line. make sure you replace the exact changes code between start_line and end_line.
For "start_line", The line of the blob in the pull request diff that the comment applies to. Make sure "fixed_code" starts from this line.
For "end_line", this is the end line of the blob where pull request applies. Make sure the "fixed_code" ends at this line.
For "start_line", The first line of the code in that the comment applies to. Make sure "fixed_code" starts from this line.
For "end_line", this is the last line of the code that the comment applies to. Make sure the "fixed_code" ends at this line.
For "side", provide the side as LEFT or RIGHT based on deleted or added lines respectively. Need this for github review comment.
For "file_name" make sure to give the whole path so that developers can know exactly which file has issue.
For "severity_level" score in range of 1 to 10, 1 being not severe and 10 being critical.
Process the given patch data. Identify lines beginning with '+' (excluding the file header line starting with '+++') as additions
Make sure the "fixed_code" applied to addition lines only.
When generating the description:
- Create a concise and clear summary highlighting the main purpose of the pull request.
- Use markdown formatting in the detailed description for better readability.
- Organize the details into relevant sections or bullet points.
- Focus on the most significant aspects of the changes.
- Avoid repeating information already present in the pull request title or description.
- Ensure the output is in valid JSON format.
Confidence Levels based on severity of the issue:
[
"critical",
Expand Down Expand Up @@ -189,7 +224,7 @@
Pull Request Title: {PULL_REQUEST_TITLE}
Pull Request Description: {PULL_REQUEST_DESC}
Code Diff:
Patch Data:
{CODE_DIFF}
Analyze the information thoroughly and generate a comprehensive summary and detailed description.
Expand Down Expand Up @@ -230,7 +265,7 @@
Pull Request Title: {PULL_REQUEST_TITLE}
Pull Request Description: {PULL_REQUEST_DESC}
Code Diff:
Patch Data:
{CODE_DIFF}
Analyze the information thoroughly and generate a comprehensive summary and detailed description.
Expand Down
2 changes: 2 additions & 0 deletions kaizen/reviewer/code_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ def _process_file_chunk(
user: Optional[str],
reeval_response: bool,
) -> List[Dict]:
if not diff_data:
return []
prompt = FILE_CODE_REVIEW_PROMPT.format(
PULL_REQUEST_TITLE=pull_request_title,
PULL_REQUEST_DESC=pull_request_desc,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "kaizen-cloudcode"
version = "0.3.6"
version = "0.3.7"
description = "An intelligent coding companion that accelerates your development workflow by providing efficient assistance, enabling you to craft high-quality code more rapidly."
authors = ["Saurav Panda <saurav.panda@cloudcode.ai>"]
license = "Apache2.0"
Expand Down

0 comments on commit c3cbb9b

Please sign in to comment.