Incorrectly identifying line numbers in code

Am trying to make a GPT that can make code changes and post them back to an API. Was trying to have the GPT send the line numbers in the code file it had made changes at, but it consistently gets the line numbers wrong. It says it identifies line numbers by counting \n, which seems like it should work and when it outputs the file it splits the lines correctly, so a bit puzzled why it seems to be unable to identify code sections by line number.

Anyone run into this or have any suggestions on how to get past this?

The model sucks at counting

what you can do is to send the line numbers with your code. Alternatively, instead of line numbers, you can ask the model to note the beginning and end of a snippet to be replaced, and then identify the line numbers from that.

Passing the line numbers with the code seems to work somewhat better, thanks for the suggestion.

1 Like