Untitled

 avatar
unknown
plain_text
2 years ago
1.1 kB
5
Indexable
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
module.exports.run = async (args, api, db, event, input, msgID, senderID, threadID, src, prefix) => {
  if (!(args.length === 0)) {
    try {
      let query = args.join(" ");
     const configuration = new Configuration({
        apiKey: process.env.OPENAI_API_KEY,
      });

      const openai = new OpenAIApi(configuration);
      openai.createChatCompletion({
      const {data} = await openai.createCompletion({
        model: "gpt-3.5-turbo",
        messages:[{role: "user", content:"Hello world"}],
        prompt: query,
        temperature: 0.0,
        max_tokens: 1500,
        top_p: 1,
        frequency_penalty: 0.0,
        presence_penalty: 0.0,
      });
  
      console.log(completion.data.choices[0].message.content);
    } catch (error) {
      api.sendMessage(`⚠️An error has occured!\n${error.message}`)
    }
  } else {
    api.sendMessage(`⚠️Invalid Use Of Command!\n💡Usage: ${prefix}ai query`, threadID, msgID);
  }
}
Editor is loading...