Update handleDirectMessage function to include knowledge base in messageCreate.js

This commit is contained in:
ShadowVirtual 2024-04-30 18:52:51 -08:00
parent 3c61ca3d41
commit b8e0a40f73

View file

@ -3,6 +3,7 @@ const openAI = require('openai');
const chalk = require('chalk');
const ms = require('ms');
const fs = require('node:fs');
const path = require('node:path');
const func = require('../utils/functions');
const settings = require('../utils/settings');
const config = require('../configs/config.json');
@ -349,12 +350,14 @@ if (message.content.toLowerCase().startsWith(config.Prefix)) {
// Function to handle direct messages
async function handleDirectMessage(message) {
const knowledge = fs.readFileSync(path.join(__dirname, 'completion.txt'), 'utf-8');
if (conversations.has(message.author.id)) {
const oldMessages = conversations.get(message.author.id);
let messages = [{
"role": "system",
"content": completionPrompt
"content": `You are a unique user in a Discord server. Engage in conversations naturally, considering the context and your surroundings. Share your thoughts, opinions, and experiences as if you were a real person. Use emojis, slang, and a casual tone to blend in with other users. Avoid sounding robotic or generic, and aim to create a distinct personality that others can relate to and enjoy interacting with. Your knowledge base: ${knowledge}`
}];
messages = messages.concat(oldMessages);