import process from "node:process";
export const complete = async (prompt: string | object, options = {}) => {
const { Configuration, OpenAIApi } = await import("https://esm.sh/openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI,
});
const openai = new OpenAIApi(configuration);
const completion = await openai.createCompletion({
model: "text-davinci-003",
prompt,
...options,
});
return completion.data.choices[0].text;
};