@@ -135,11 +135,10 @@ def create_prompt(file: PatchedFile, hunk: Hunk, pr_details: PRDetails) -> str:
135135 """Creates the prompt for the Gemini model."""
136136 return f"""Your task is reviewing pull requests. Instructions:
137137 - Provide the response in following JSON format: {{"reviews": [{{"lineNumber": <line_number>, "reviewComment": "<review comment>"}}]}}
138- - Do not give positive comments or compliments.
139138 - Provide comments and suggestions ONLY if there is something to improve, otherwise "reviews" should be an empty array.
140- - Write the comment in GitHub Markdown format.
141- - Use the given description only for the overall context and only comment the code.
142- - IMPORTANT: NEVER suggest adding comments to the code.
139+ - Use GitHub Markdown in comments
140+ - Focus on bugs, security issues, and performance problems
141+ - IMPORTANT: NEVER suggest adding comments to the code
143142
144143Review the following code diff in the file "{ file .path } " and take the pull request title and description into account when writing the response.
145144
@@ -216,15 +215,14 @@ def create_comment(file: FileInfo, hunk: Hunk, ai_responses: List[Dict[str, str]
216215 line_number = int (ai_response ["lineNumber" ])
217216 print (f"Original AI suggested line: { line_number } " )
218217
219- # Ensure the line number is within the hunk's range
220- if line_number < 1 or line_number > hunk .source_length :
221- print (f"Warning: Line number { line_number } is outside hunk range" )
222- continue
218+ # Adjust line number to be relative to the hunk's starting position
219+ adjusted_line_number = hunk .source_start + line_number - 1
220+ print (f"Adjusted line number: { adjusted_line_number } " )
223221
224222 comment = {
225223 "body" : ai_response ["reviewComment" ],
226224 "path" : file .path ,
227- "position" : line_number
225+ "position" : adjusted_line_number
228226 }
229227 print (f"Created comment: { json .dumps (comment , indent = 2 )} " )
230228 comments .append (comment )
0 commit comments