updating for openai
This commit is contained in:
@@ -27,6 +27,8 @@ It should be assumed every server will need its own Airtable Base and the coresp
|
||||
|
||||
* **!help** - Lists the available commands: *!help*
|
||||
|
||||
* **!chat** - Queries OpenAI Model: *!chat what is a pizza*
|
||||
|
||||
* **!search** - Searches the RSS Sources: *!search google*
|
||||
|
||||
* **!get** - Retrieves Search By Index: *!get 25*
|
||||
|
||||
21
commands/chat.js
Normal file
21
commands/chat.js
Normal file
@@ -0,0 +1,21 @@
|
||||
var libFlayer = require("../libFlayer.js");
|
||||
|
||||
module.exports = {
|
||||
name: 'chat',
|
||||
description: 'Chat',
|
||||
async execute(message, args) {
|
||||
if (args.length < 1) {
|
||||
message.reply(`Please use in !chat [chat query]`);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var question = encodeURIComponent(args.join(" "));
|
||||
|
||||
var response = await libFlayer.getChat(question);
|
||||
message.reply(`${message.author.username} ${response}`);
|
||||
|
||||
} catch (err) {
|
||||
//message.reply(err.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
26
libFlayer.js
26
libFlayer.js
@@ -6,6 +6,14 @@ var jsonfile = require('jsonfile');
|
||||
var fs = require('fs');
|
||||
var file = ('./feeds.json');
|
||||
var Airtable = require('airtable');
|
||||
const { Configuration, OpenAIApi } = require('openai');
|
||||
const configuration = new Configuration({
|
||||
organization: process.env.OPENAI_ORG,
|
||||
apiKey: process.env.OPENAI_API
|
||||
});
|
||||
|
||||
const openai = new OpenAIApi(configuration);
|
||||
|
||||
|
||||
// Data Structures
|
||||
var feeds = [];
|
||||
@@ -29,6 +37,7 @@ let answerData = {
|
||||
source: ``
|
||||
}
|
||||
|
||||
|
||||
//Local DB for quotes
|
||||
const {
|
||||
quotes
|
||||
@@ -420,6 +429,23 @@ exports.getStock = async function (stock) {
|
||||
return stockData;
|
||||
}
|
||||
|
||||
/**
|
||||
* getChat - Returns libFlayer feed sources
|
||||
* @constructor
|
||||
*/
|
||||
|
||||
exports.getChat = async function (question) {
|
||||
const response = await openai.createCompletion({
|
||||
model: "text-davinci-003",
|
||||
prompt: question,
|
||||
temperature: 0,
|
||||
max_tokens: 100
|
||||
});
|
||||
|
||||
|
||||
var responseData = response.data.choices[0].text;
|
||||
return responseData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
1458
package-lock.json
generated
1458
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "link-flayer",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"description": "Discord RSS News Bot",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
@@ -8,6 +8,7 @@
|
||||
"@discordjs/rest": "^0.5.0",
|
||||
"airtable": "^0.11.1",
|
||||
"axios": "^0.24.0",
|
||||
"chatgpt": "^1.4.0",
|
||||
"discord-api-types": "^0.35.0",
|
||||
"discord.js": "^13.8.1",
|
||||
"dotenv": "^10.0.0",
|
||||
@@ -16,6 +17,7 @@
|
||||
"js-doc": "^0.5.0",
|
||||
"jsonfile": "^6.1.0",
|
||||
"mathjs": "^10.6.4",
|
||||
"openai": "^3.1.0",
|
||||
"parse-files": "^0.1.1",
|
||||
"rss-parser": "^3.12.0"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user