Untitled
unknown
javascript
2 years ago
932 B
3
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: db.openaikey, }); const openai = new OpenAIApi(configuration); const {data} = await openai.createChatCompletion({ model: "gpt-3.5-turbo", messages:[{role: "user", content: query}], temperature: 0.7, }); api.sendMessage(completion.data.choices[0].message.content, threadID, msgID) } catch (error) { api.sendMessage(`⚠️An error has occured!\n${error.message}`, threadID, msgID) } } else { api.sendMessage(`⚠️Invalid Use Of Command!\n💡Usage: ${prefix}ai query`, threadID, msgID); } }
Editor is loading...