I encountered an issue while trying to execute the test code from a tutorial on building a chat app with GPT-3, ReactJS, and Next.js. The error message I received was:
TypeError: openai.completions is not a function
This occurred when running the following code in my.js using "node my.js" in Git Bash on Windows 10:
const openai = require('openai');
openai.apiKey = "api-key";
openai.completions({
engine: "text-davinci-003",
prompt: "Hello, how are you?",
max_tokens: 32,
n: 1,
stop: ".",
temperature: 0.5,
}).then((response) => {
console.log(response.data.choices[0].text);
});
I have attempted multiple alternative code snippets from OpenAI docs and other sources but have been unsuccessful in resolving the issue.