here is a logged example of my request and response log:
REQUEST:
const response = await openai.createCompletion({
model: 'code-davinci-002',
prompt: 'show me how to use the javascript array method reduce()',
temperature: 0.2,
max_tokens: 2000,
});
here is the RESPONSE:
{
"id": "cmpl-6gwB7jonbKx4bABdw19TO6p5pfACC",
"object": "text_completion",
"created": 1675691433,
"model": "code-davinci-002",
"choices": [
{
"text": " to sum up the total price of all the products in the cart.\n\n// the reduce() method
reduces the array to a single value.\n\n// the reduce() method executes a provided function for each
value of the array (from left-to-right).\n\n// the return value of the function is stored in an accumulator
(result/total).\n\n// note: reduce() does not execute the function for array elements without values.\n\n//
note: reduce() does not change the original array.\n\n// the reduce() method takes two arguments:\n\n//
1. a callback function\n// 2. an initial value (optional)\n\n// the callback function takes four
arguments:\n\n// 1. the initial value (or value from the previous callback function)\n// 2. the value of the
current element\n// 3. the current index\n// 4. the array over which iteration is occurring\n\n// the
callback function can return a value to be used as the initial value in the next call to the callback
function.\n\n// the initial value is optional. if no initial value is supplied, the first element in the array will
be used and skipped.\n\n// if the array is empty and no initial value is provided, a TypeError will be
thrown.\n\n// the reduce() method does not change the original array.\n\n// the reduce() method can be
used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum
of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the values in
an array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find
the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an
array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find
the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an
array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find
the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an
array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find
the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an
array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find
the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an
array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find
the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an
array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find
the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an
array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find
the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an
array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find
the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an
array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find
the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an
array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n// the reduce() method can be used to find
the sum of all the values in an array.\n\n// the reduce() method can be used to find the sum of all the
values in an array.\n\n// the reduce() method can be used to find the sum of all the values in an
array.\n\n// the reduce() method can be used to find the sum of all the values in an array.\n\n// the
reduce() method can be used to find the sum of all the values in an array.\n\n// the reduce() method
can be used to find the sum of all the values in an array.\n\n//",
"index": 0,
"logprobs": null,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 2000,
"total_tokens": 2010
}
}
You can see how the API seems to have gotten stuck and repeats itself over and over until it runs out of tokens (or my endpoint times out). I get this regularly in different kinds of requests and even on different models (even text-davinci-003). What am I missing?