题意:“Firebase OpenAI API 错误:‘openai.createCompletion is not a function’”
问题背景:
I am having an issue with running my Firebase function. It needs to generate a challenge once a day (I have it set up to run every minute now for debug) and to save it in my realtime database. This code is like this:
“我在运行 Firebase 函数时遇到了问题。它需要每天生成一次挑战(我现在将其设置为每分钟运行一次以进行调试),并将其保存到我的实时数据库中。代码如下:”
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const OpenAI = require("openai");
admin.initializeApp();
// Create a new instance of the OpenAI API client
const openai = new OpenAI({
apiKey: functions.config().openai.key,
});
exports.generateDailyChallenge = functions.p