Hacker News new | ask | show | jobs
by Hakkin 1287 days ago
I believe ChatGPT has some kind of response token limit, which is why longer code snippets commonly get cut off. I've seen some people recommend to enter something like "Continue your previous message starting from the last token", which sometimes works, but even when it does, it often breaks formatting, making it difficult to read the resulting code without copying it somewhere else. What I found to work better is instructing it to output a single function at a time, this usually results in short enough code that it can output all of it in a single message. Something like:

  I want you to send a single function in each response, I will say "Next" when I want you to send the next function.
I was able to get it to generate decently lengthy programs using this (on the order of a few hundred lines) that were syntactically and logically correct without any modification. This may work for some languages better than others, though I imagine you can find some way to logically split up the program for most.
1 comments

All you need is to prompt it with "Continue" and it will keep going exactly where it left off.
I've heard this quite a lot too, but it commonly doesn't work. I've had it respond thinking I was talking about using a `continue` statement somewhere in the code, and other times it simply just reprinted the whole code starting from the beginning. If you hit the "Try again" button enough it will usually eventually work, but it again has the problem where a lot of the time the formatting of the text gets messed up.
I've had no problems just writing: "continue the code from above example" or something akin to that - across 25+ full app prompts.

There has been a few times where the app hangs with the three dots jumping - but that seems to be an issue with server overload.

I've been able to make lots of mini apps in JS/HTML/CSS that with very little tweaking could be dropped into codepen fully working.

Most of these required ~3 "continue the code example" and were started with at prompt like "Show me the code for an app in js, html, css where a user can input his weight in kg, and his daily calorie deficit. Then a canvas element shows a graph of his future weight loss changing live according to the changed input."

Absolutely amazing that it works. You can even dump an error from the console if it needs tweaking and it often fixes the error from the msg on the first try.

You can also say "give me just X function" or "continue above example from the line with 'someFunction or something'" or "give me just the css again but make it more modern" and it just works.

That's due to the front-end markdown codeblock ending and the model not outputting it again since it's continuing from the last token. I believe if you tell it to continue but include code blocks again, it will do it