gpt4 book ai didi

javascript - 在 OpenAI 中运行超过 1 个提示

转载 作者:行者123 更新时间:2023-12-02 22:46:11 26 4
gpt4 key购买 nike

在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com