小编Wyn*_*ars的帖子

OpenAI ChatGPT (GPT-3.5) API 错误:“openai.createChatCompletion 不是函数”

我的 MERN 堆栈代码文件中有这个,并且运行良好。

exports.chatbot = async (req, res) => {
  console.log("OpenAI Chatbot Post");

  const { textInput } = req.body;

  try {

    const response = await openai.createCompletion({
      model: "text-davinci-003",
      prompt: `
            What is your name?
            My name is Chatbot.
            How old are you?
            I am 900 years old.
            ${textInput}`,
      max_tokens: 100,
      temperature: 0,
    });
    if (response.data) {
      if (response.data.choices[0].text) {
        return res.status(200).json(response.data.choices[0].text);
      }
    }
  } catch (err) {
    return res.status(404).json({ message: err.message });
  }
};
Run Code Online (Sandbox Code Playgroud)

当我更改API请求时,使用新的API来完成聊天,这个不起作用(API代码来自openAI网站,并且适用于postman)


exports.chatbot = async (req, res) …
Run Code Online (Sandbox Code Playgroud)

axios openai-api chatgpt-api

5
推荐指数
2
解决办法
6938
查看次数

标签 统计

axios ×1

chatgpt-api ×1

openai-api ×1