I am getting weird repetitive results where it gives me the same answer over and over until it times out

here is an example 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
    }
}

scroll to the right so that you can see the “answer” seems to be stuck in a loop, repeating the same text over and over until it runs out of tokens or times out.

the “text” value in the JSON above is:
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//"

the request that game me the above results was a simple question:

  const response = await openai.createCompletion({
    model: 'text-davinci-003',
    prompt: 'show me how to use the javascript array method reduce()',
    temperature: 0.2,
    max_tokens: 2000,
  });

What am i doing wrong?