Created
April 5, 2023 15:15
-
-
Save xIKRATOSx/e5589c9ba09cba2f6ba41f290bfed4b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Thanks to xIKRATOSx for codes | |
const { Configuration, OpenAIApi } = require{"openai"} | |
const { tlang, botpic,cmd, prefix, runtime,Config } = require('../lib') | |
const axios = require('axios') | |
const speed = require('performance-now') | |
cmd({ | |
pattern: "gpt", | |
desc: "chat with an AI", | |
category: "general", | |
use: '<Hii,Secktor>', | |
filename: __filename, | |
}, | |
async(Void, citel,text) => { | |
if (!text) return citel.reply(`Please Write text\n\nExample:\n${usedPrefix}${command} How Are You? `); | |
const configuration = new Configuration({ | |
apiKey: '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', // Create Your Key | |
}); // https://platform.openai.com/account/api-keys | |
const openai = new OpenAIApi(configuration); | |
const response = await openai.createChatCompletion({ | |
model: "gpt-3.5-turbo", | |
messages: [{role: "user", content: text}], | |
}); | |
citel.reply(`${response.data.choices[0].message.content}`); | |
} catch (error) { | |
if (error.response) { | |
console.log(error.response.status); | |
console.log(error.response.data); | |
console.log(`${error.response.status}\n\n${error.response.data}`); | |
} else { | |
console.log(error); | |
citel.reply("Please Wait I'm Getting API update rn... Please Try Later\n\tError Message :"+ error.message); | |
} | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment