在 OpenAI API 中,我想运行 3 个提示,将结果添加到一个名为 text 的变量中,并同时显示它们。现在,问题是我一次只能做 1 个提示。有没有办法一次运行 3 个提示?如果是这样,请添加一些示例代码供我使用。谢谢。
import { Configuration, OpenAIApi } from "openai";
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
export default async function (req, res) {
const completion = await openai.createCompletion({
model: "text-davinci-002",
temperature: 1,
max_tokens: 3000,
top_p: 1,
frequency_penalty: 2,
presence_penalty: 2,
prompt: "tell me about one. tell me about two. tell me about three.",
});
res.status(200).json({ result: completion.data.choices[0].text });
}
最佳答案
将提示放入一个数组中:
prompt: ["tell me about one.", "tell me about two.", "tell me about three."]
关于javascript - 在 OpenAI 中运行超过 1 个提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74202804/