#Discord Chatbot using OpenAI's GPT-3 Model

14 messages · Page 1 of 1 (latest)

woeful fossil
#

my current code is

const { SlashCommandBuilder } = require('@discordjs/builders');
const openai = require('openai');

openai.apiKey = 'XX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

module.exports = {
  data: new SlashCommandBuilder()
    .setName('chat')
    .setDescription('Chat with a chatbot')
    .addStringOption(option => option.setName('prompt').setDescription('Prompt of the message').setRequired(true)),

  async execute(interaction) {
    const { options } = interaction;

    const input = interaction.options.getString('prompt');
    openai.completions.create({
        model: 'davinci',
        prompt: input,
        max_tokens: 256,
        n: 1,
        stop: '\n',
        temperature: 0.5,
      }).then((gpt3Response) => {
        const responseText = gpt3Response.data.text[0];
        interaction.reply(responseText);
      });      
  },
};

im getting the error

TypeError: Cannot read properties of undefined (reading 'completions')
ancient sleet
#

test

#

hello

fluid blaze
#
const completion = await openai.createCompletion({
  model: "text-davinci-003",
  prompt: input,
  temperature: 0.6,
})```
#

Try this one

#

@woeful fossil

woeful fossil
#

getting the error

TypeError: openai.createCompletion is not a function
#

@fluid blaze

fluid blaze
#

Try installing the latest version of openai

woeful fossil
#

nope ssame error

#

@fluid blaze

fluid blaze
#

Check the properties of openai

#

If there even something called createCompletion

woeful fossil