mirror of
https://github.com/Expand-sys/expandchatbotv2
synced 2025-12-15 13:32:15 +11:00
commit
This commit is contained in:
parent
1d28f06913
commit
98b43729d7
4 changed files with 65 additions and 10 deletions
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
|
@ -3,7 +3,9 @@ const { sendResponse } = require('../../../utils/utils');
|
|||
const path = require('path');
|
||||
const { Ollama } = require('ollama')
|
||||
const ollama = new Ollama({host: 'http://localhost:11434'})
|
||||
|
||||
const axios = require("axios")
|
||||
|
||||
|
||||
module.exports = {
|
||||
name: `prompt`,
|
||||
description: `prompt the bot for for a snarky response`,
|
||||
|
|
@ -14,31 +16,53 @@ module.exports = {
|
|||
description: `The question you want to ask the ai`,
|
||||
type: ApplicationCommandOptionType.String,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: `attachment`,
|
||||
description: `attach an image to describe`,
|
||||
type: ApplicationCommandOptionType.Attachment ,
|
||||
required: false,
|
||||
}],
|
||||
/**
|
||||
* @param {CommandInteraction} interaction
|
||||
*/
|
||||
async execute(interaction) {
|
||||
const { member, options } = interaction;
|
||||
|
||||
let b64 = ""
|
||||
|
||||
await interaction.deferReply({ ephemeral: false }).catch(err => console.error(`${path.basename(__filename)} There was a problem deferring an interaction: `, err));
|
||||
console.log(options.get("prompt"))
|
||||
console.log(options.get("attachment"))
|
||||
let response = await ollama.generate({
|
||||
model: 'llama2-uncensored',
|
||||
model: 'llava',
|
||||
prompt: options.get("prompt").value,
|
||||
stream: false,
|
||||
options: {
|
||||
num_predict: 128,
|
||||
temperature: 2,
|
||||
repeat_penalty: 2
|
||||
num_predict: -1,
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
const responseout = new EmbedBuilder()
|
||||
.setColor('#32BEA6')
|
||||
.setAuthor({ name: `${member.user.displayName }`, iconURL: member.user.displayAvatarURL({ dynamic: true }) })
|
||||
.setTitle("Prompt: " + options.get("prompt").value)
|
||||
.setTitle("Prompt: " + options.get("prompt").value.slice(0,240))
|
||||
.setDescription(response.response)
|
||||
console.log(response)
|
||||
if(options.get("attachment")){
|
||||
let image = await axios.get(options.get("attachment").attachment.url, {responseType: 'arraybuffer'});
|
||||
let returnedB64 = Buffer.from(image.data);
|
||||
b64 = returnedB64
|
||||
response = await ollama.generate({
|
||||
model: 'llava',
|
||||
prompt: options.get("prompt").value,
|
||||
images: [b64],
|
||||
stream: false,
|
||||
options: {
|
||||
num_predict: -1,
|
||||
}
|
||||
})
|
||||
responseout.setThumbnail(options.get("attachment").attachment.url)
|
||||
}
|
||||
|
||||
|
||||
sendResponse(interaction, ``, [responseout]);
|
||||
}
|
||||
}
|
||||
29
index.js
29
index.js
|
|
@ -6,6 +6,35 @@ client.setMaxListeners(0);
|
|||
client.commands = new Discord.Collection();
|
||||
client.events = new Discord.Collection();
|
||||
|
||||
/*const { MongoClient, ServerApiVersion } = require('mongodb');
|
||||
const uri = "";
|
||||
// Create a MongoClient with a MongoClientOptions object to set the Stable API version
|
||||
const client = new MongoClient(uri, {
|
||||
serverApi: {
|
||||
version: ServerApiVersion.v1,
|
||||
strict: true,
|
||||
deprecationErrors: true,
|
||||
}
|
||||
});
|
||||
async function run() {
|
||||
try {
|
||||
// Connect the client to the server (optional starting in v4.7)
|
||||
await client.connect();
|
||||
// Send a ping to confirm a successful connection
|
||||
await client.db("admin").command({ ping: 1 });
|
||||
console.log("Pinged your deployment. You successfully connected to MongoDB!");
|
||||
} finally {
|
||||
// Ensures that the client will close when you finish/error
|
||||
await client.close();
|
||||
}
|
||||
}
|
||||
run().catch(console.dir);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
["command_handler", "event_handler"].forEach(handler => {
|
||||
require(`./handlers/${handler}`)(client, Discord);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
"@discordjs/voice": "^0.8.0",
|
||||
"@improbable-eng/grpc-web": "^0.15.0",
|
||||
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
|
||||
"axios": "^1.6.8",
|
||||
"console-stamp": "^3.1.2",
|
||||
"cron": "^1.8.2",
|
||||
"deepai": "^1.0.21",
|
||||
|
|
@ -26,6 +27,7 @@
|
|||
"gifencoder": "^2.0.1",
|
||||
"glob": "^7.2.0",
|
||||
"got": "^12.5.3",
|
||||
"mongodb": "^6.5.0",
|
||||
"nodemon": "^2.0.19",
|
||||
"ollama": "^0.5.0",
|
||||
"openai": "^3.2.1",
|
||||
|
|
|
|||
Loading…
Reference in a new issue