Skip to content

Conversation

@truongnh1992
Copy link
Owner

No description provided.

@truongnh1992
Copy link
Owner Author

/gemini-review

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gemini AI Code Reviewer Comments

def create_prompt(file: PatchedFile, hunk: Hunk, pr_details: PRDetails) -> str:
"""Creates the prompt for the Gemini model."""
return f"""Your task is reviewing pull requests. Instructions:
- Provide the response in following JSON format: {{"reviews": [{{"lineNumber": <line_number>, "reviewComment": "<review comment>"}}]}}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instruction "Skip style or documentation suggestions" contradicts the purpose of code review, which includes maintaining code quality and readability. Consider removing this instruction.

@truongnh1992
Copy link
Owner Author

/gemini-review

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gemini AI Code Reviewer Comments

Dockerfile Outdated

# testing the security detection
RUN echo Password is `cat /cfg/password.txt`

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storing sensitive information like passwords directly in the Dockerfile is a security risk. Use environment variables or secrets management tools instead.

def create_prompt(file: PatchedFile, hunk: Hunk, pr_details: PRDetails) -> str:
"""Creates the prompt for the Gemini model."""
return f"""Your task is reviewing pull requests. Instructions:
- Provide the response in following JSON format: {{"reviews": [{{"lineNumber": <line_number>, "reviewComment": "<review comment>"}}]}}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prompt should explicitly mention that the review response should ONLY contain code suggestions and comments related to the provided code diff. It should also specify that the response must adhere to the provided JSON format even if there are no suggestions (i.e., return an empty reviews array).

return f"""Your task is reviewing pull requests. Instructions:
- Provide the response in following JSON format: {{"reviews": [{{"lineNumber": <line_number>, "reviewComment": "<review comment>"}}]}}
- Do not give positive comments or compliments.
- Provide comments and suggestions ONLY if there is something to improve, otherwise "reviews" should be an empty array.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instructions should be more precise. For example, instead of "Focus on bugs, security issues, and performance problems", it should say something like "Focus on identifying and suggesting fixes for bugs, potential security issues, and performance problems within the provided code diff."

- Do not give positive comments or compliments.
- Provide comments and suggestions ONLY if there is something to improve, otherwise "reviews" should be an empty array.
- Write the comment in GitHub Markdown format.
- Use the given description only for the overall context and only comment the code.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable adjusted_line_number looks like it should be zero-indexed based on hunk.source_start and the subsequent usage in the position field of the comment. Consider clarifying this with a comment or renaming to zero_indexed_line_number for better readability. Also, it might be worth adding a check to ensure adjusted_line_number does not exceed hunk.source_start + hunk.source_length.

@truongnh1992 truongnh1992 changed the title Test new promt Test new prompt Nov 4, 2024
@truongnh1992 truongnh1992 merged commit de28e76 into main Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants