我很抱歉基本的问题,但没有得到什么似乎是一个非常基本的代码块在哪里。我有npm安装了最新版本的openai。我得到了一个不断的错误在我的终端:
TypeError: Cannot read properties of undefined (reading 'create')
at Object.<anonymous> (/Users/michalchojnacki/Desktop/Coding/OpenAi2/code.js:9:20)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
代码:
const openai = require('openai');
openai.apiKey = "my API here";
const prompt = "What is the capital of France?";
const model = "davinci";
openai.completions.create({
engine: model,
prompt: prompt,
max_tokens: 2048,
n: 1,
stop: '.',
temperature: 0.5,
}, (error, response) => {
if (error) {
console.log(error);
} else {
console.log(response.choices[0].text);
}
});
会很感激任何帮助!
我以为终端会给我提示的回应
1条答案
按热度按时间uemypmqf1#
根据库中的文档,您似乎需要类似下面的内容: