From 14d681d6b169472b4ef8e574b49cd443bca0dd6a Mon Sep 17 00:00:00 2001 From: sneedgroup-holder Date: Sun, 2 Feb 2025 23:23:45 +0000 Subject: [PATCH] Upload files to "/" --- brain.mjs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/brain.mjs b/brain.mjs index 6d7228d..5684a79 100644 --- a/brain.mjs +++ b/brain.mjs @@ -30,6 +30,16 @@ export class ConsciousnessSimulator { this.isUserActive = true; } + + // Function to load the array from a text file + loadArrayFromFile(filename) { + // Read the file synchronously + const data = fs.readFileSync(filename, 'utf8'); + + // Split the data by newline and return as an array + return data.split('\n').map(item => item.trim()); // `.map(item => item.trim())` to remove any extra spaces + } + // Method to generate thoughts using Ollama async generateThought(prompt) { try { @@ -111,7 +121,12 @@ export class ConsciousnessSimulator { // Continuity check and load from log loadMemory() { - return this.memoryLog; + try { + this.memoryLog = this.loadArrayFromFile("consciousness.log") + return this.memoryLog; + } catch { + return this.memoryLog; + } } // Helper method for emotions array access