-
-
Save SuhailTechInfo/09150cd8d979d39c644305b9a827ac68 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: "aii", | |
desc: "chat with an AI", | |
category: "general", | |
use: '<Hii,Secktor>', | |
filename: __filename, | |
}, | |
async(Void, citel,text) => { | |
if (!text) return citel.reply(`Please Write text\nExample:*.aii How Are You?* `); | |
const configuration = new Configuration({ | |
apiKey: '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', | |
}); | |
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