var collector = new MessageCollector(message.channel, filter, { max: 10, time: 60000,})
start_sequence = "\nAI: "
retart_sequence = "\nHuman: "
collector.on("collect", (msg) => {
console.log(msg.content)
openai.Completion.create({
engine: "davinci",
prompt: msg.content,
temperature: 0.9,
max_tokens: 150,
top_p: 1,
frequency_penalty: 0.35,
presence_penalty: 0.6,
stop: ["\n", " Human:", " AI:"]
}).then((response) => {
message.channel.send(response.choices[0].text)
})
})}
我尝试过这种方法,但它只返回完成内容,就像默认预设而不是GPT-3的”playground”中的聊天预设。我使用openai-node在javascript中编程,而不是使用python来调用OpenAI API。
回答:
你的prompt
需要提供更多信息,让GPT-3理解你想要什么。你提供的消息提示,例如
My message!
但你真正应该提供的是类似于这样的内容:
以下是与AI助手的对话。助手乐于助人,富有创造力,聪明且非常友好。Human: 你好,你是谁?AI: 我是由OpenAI创建的AI。今天我能帮你什么?Human: My message!AI:
此外,如果你希望它具有上下文感知能力,你需要继续向提示中添加信息,例如:
以下是与AI助手的对话。助手乐于助人,富有创造力,聪明且非常友好。Human: 你好,你是谁?AI: 我是由OpenAI创建的AI。今天我能帮你什么?Human: My message!AI: 这里的回应Human: 这里的另一条消息AI:
请注意令牌限制和成本。你可能需要选择让它不具有上下文,或者在某个时候开始删除之前的消息。