首页 > 解决方案 > 如何让“msg.content”不断地添加新字符串而不是替换?

问题描述

 var collector = new MessageCollector(message.channel, filter, {
    max: 10,
    time: 60000,
})

        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”实现到一个不和谐的机器人中,看看它是如何工作的,但是 GPT-3 需要一直知道提示(基本上是对话的上下文)。通过我设置它的方式,一旦变量(msg.content)被“MessageCollector”抓取,它就会不断用新字符串替换变量(msg.content)。我需要这样做,以便每当检测到消息时,它都会将该字符串添加到变量中并不断这样做,直到,假设计时器关闭。

标签: javascriptnode.jsdiscord.jsopenaigpt-3

解决方案


推荐阅读