The ChatGPT API is actually already set up for chat dialogs, so rather than pasting the user input into the same text stream, you write your prompt as a "system message", then the user input as a "user message". and the system responds with a third one. See: https://platform.openai.com/docs/guides/chat/introduction