Codium-ai / pr-agent

🚀CodiumAI PR-Agent: An AI-Powered 🤖 Tool for Automated Pull Request Analysis, Feedback, Suggestions and More! 💻🔍
Apache License 2.0
5.64k stars 520 forks source link

still see "remove unused imports" code suggestion even if the system prompt asks it not to suggest anything on unused imports #1181

Closed chuanran closed 1 day ago

chuanran commented 2 weeks ago

In https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/pr_code_suggestions_prompts.toml#L42C3-L42C88, , you can see the system prompt says clearly that do not suggest to remove unused imports, however, the pr code suggestion still tips # Remove the unused import, and this is actually a hallucination too, because the library was actually used in the later code.

mrT23 commented 2 weeks ago

This is not a proper way to open an issue.

I have no idea which model you used and what the code was. If you used bad models, for example, they may struggle with the prompt.

I have not encountered this problem lately, with top models (Claude 3.5)

Share a reproducible example from a public code to address this issue

chuanran commented 2 weeks ago

sorry for any confusion @mrT23

I was using llama-3.1-70b-instruct model and encountered this issue. I have some simple code lie following, and it gave me some suggestion that vcloud_util was never been used, but actually you can find that it's used in the function reconnect_vcenter.

import common.utils.pyvcloud_utils_v2 as vcloud_util

def reconnect_vcenter(logger, vcd_info):
    try:
        client = None
        vcd_url = vcd_info['vcd_url']
        client = vcloud_util.get_client(vcd_url)
mrT23 commented 2 weeks ago

llama-3.1-70b-instruct is a weak code model. You can use whatever model you want, but for good results, use top code models like GPT4 or Claude Sonnet

chuanran commented 2 weeks ago

@mrT23, after I change the system prompts to the following, which means I move it to a separate like to emphasize not suggest to remove unused imports, seems the issue is resolved and I do not see any complaints on unused imports anymore. I am using the same llama3-1 model. do you think if it's a good idea to make Don't suggest to remove unused imports. a separate line in system prompts?

- Don't suggest to add docstring, type hints, or comments.
- Don't suggest to remove unused imports.
mrT23 commented 2 weeks ago

you are welcome to change and adapt the prompt to your model in your local deployemnt