A way to make GPT-3's "davinci" converse with a user(s) through a bot in discord using discord.js?

Viewed 147
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)
        })

    })
}

I tried this but it only gives back completions, like the default preset rather than the chat preset in GPT-3's "playground". I'm using openai-node to code in javascript rather than python to call openAI API.

1 Answers

Your prompt needs to be given more information for GPT-3 to understand what you want. You're providing a prompt of the message, such as

My message!

But what you really should be giving it is something like:

The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly.

Human: Hello, who are you?
AI: I am an AI created by OpenAI. How can I help you today?
Human: My message!
AI:

In addition, if you it to be contextually aware, you need to continue adding information to the prompt, such as:

The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly.

Human: Hello, who are you?
AI: I am an AI created by OpenAI. How can I help you today?
Human: My message!
AI: Response here
Human: Another message here
AI:

Be aware of the token limits and costs. You may to choose to make it not contextual, or at some point start cutting out previous messages.

Related