devchat-ai / devchat

Automate your dev tasks with AI-powered scripts, from your IDE's chat panel.
https://www.devchat.ai
Apache License 2.0
342 stars 39 forks source link

Large Models Drop Function Code When Adding Docstrings to Large Functions #290

Closed yangbobo2021 closed 6 months ago

yangbobo2021 commented 6 months ago

Description

When attempting to refactor by adding docstrings to large functions, it was observed that the large model tends to drop the original function implementation in the output while adding new comments. This seems to primarily occur due to the interference of visible code information. During the process of generating function comments, the context related to visible code is not necessary.

Expected Behavior

The ideal behavior would be for the large model to output both the original function implementation and the newly added docstrings without losing any part of the function's code.

Actual Behavior

Currently, when adding docstrings to large functions, the large model loses the function code in the output and only presents the newly added comments.

Possible Cause

It appears that the interference from visible code information might be causing the large model to drop the original function code during the docstring addition process. The model possibly prioritizes adding the comments over retaining the original code, leading to loss of function code.

Suggested Solution

A potential solution could involve adjusting the model's handling of visible code information during the docstring generation process, ensuring that it does not interfere with the output of the original function code. Alternatively, introducing a mechanism that specifically preserves the function code while appending the generated docstrings could also be effective.