How to construct the prompt for a standalone question?

I finally got the concept of the “standalone question” here: Chat Completion Architechture - #2 by AgusPG

Given my architecture in the flowchart below, I have one remaining question:

How do I construct the API prompt to request the standalone question? I mean, I know it’s essentially: “chat history + new question → submit to gpt to generate new standalone question"

But, what does that message array with chat history + new question look like? What should it say?

With all the experts here, I thought someone might have accidently bumped into this question and helped. Nevertheless, figured out a solution (with the help, of course, of ChatGPT4):

	$instruction = "Generate a standalone question which is based on the new question plus the chat history. Just create the standalone question without commentary. New question: ".$question;
	$chatHistory[] = ["role" => "user", "content" => $instruction];

This appears to work. Thank you GPT-4! and GPT-3.5-turbo! And OpenAI!

It’s crazy watching the computer screen carry on a conversation with me about various documents which reside in a number of formats on my site. But, I’m loving it!


This is how I’m using it. It appears to be working on a variety of documents. And does really, really well in maintaining the conversation context, as you can see below: