After months of watching tutorial videos and studying documentation, examples, blogs and papers, learning how to extract and chunk and embed my data, learning how to make the correct api calls to do all of this, and doing all of this in PHP, I’ve finally come to the point where I’m ready to do my chat completion.
I figure there are dozens of you who have already gone way past this point, so I will hopefully get a little assistance here.
Below is my flowchart. I understand each step, what I need to do and how, except for one thing: How do I configure the prompt consisting of my question and it’s associated context texts in order to submit a chat completion request to the OpenAI model?
So, this is what I need to submit:
a. The question
b. The texts (3) that provide the context for the question.
So, let’s say this is my starting point:
$data = array(
"model" => "gpt-3.5-turbo",
"messages" => array(
array("role" => "system", "content" => "You are a helpful assistant. Your goal is to answer the following question, using the associated texts as context, as truthfully as you can."),
array("role" => "user", "content" => $prompt),
),
How the heck to I format $prompt?
$prompt = '
Question: "My question here."
Context document 1: "My first context text."
Context document 2: "My second context text"
Context document 3: "My 3rd context text"
';
How do you guys who’ve been doing this for a while handle this?