Update brain.mjs

This commit is contained in:
Arma-Damna-Dillo 2025-02-08 02:14:57 +00:00
parent acb49e00c2
commit a7ec4f7a01

View file

@ -11,7 +11,7 @@ export class ConsciousnessSimulator {
this.currentEmotion = "happy";
// Initialize other properties with "Unknown"
this.opinions = {
ai: "Unknown"
computers: "Unknown"
};
this.quantumStates = [];
this.perception = {
@ -31,24 +31,32 @@ export class ConsciousnessSimulator {
ollama = new Ollama({ host: finalURL})
}
redefineOpinions(opinions, newValues) {
for (const key in opinions) {
if (opinions.hasOwnProperty(key) && newValues[key]) {
opinions[key] = newValues[key];
redefineOpinions(newValues) {
for (const key in this.opinions) {
if (this.opinions.hasOwnProperty(key) && newValues[key]) {
this.opinions[key] = newValues[key];
}
}
this.logAIContextMemory()
}
redefineSpecificOpinion(opinions, opinionKey, newValue) {
if (opinions.hasOwnProperty(opinionKey)) {
opinions[opinionKey] = newValue;
redefineSpecificOpinion(opinionKey, newValue) {
if (this.opinions.hasOwnProperty(opinionKey)) {
this.opinions[opinionKey] = newValue;
} else {
console.log(`Opinion key "${opinionKey}" not found.`);
}
this.logAIContextMemory()
}
resetOpinions() {
this.opinions = {
computers: "Unknown"
}
}
// Method to generate opinions using Ollama
async automaticRedefineOpinion(opinions, targetOpinionKey, newAbout) {
async automaticRedefineOpinion(targetOpinionKey, newAbout) {
try {
const response = await ollama.chat({
@ -59,7 +67,7 @@ export class ConsciousnessSimulator {
AI MEMORY CONTEXT ARRAY:
${this.memoryLog}` }]
});
redefineSpecificOpinion(opinions, targetOpinion, response.message.content)
redefineSpecificOpinion(targetOpinion, response.message.content)
return response.message.content
} catch (error) {
console.error("Error generating thought:", error);
@ -89,9 +97,7 @@ export class ConsciousnessSimulator {
${this.memoryLog}` }]
});
this.logMemory('THOUGHT', `${response.message.content}`);
this.logMemory('AI CONTEXT', `Current emotion: ${this.currentEmotion},
Opinions:
Quantum state: ${this.getQuantumState()}`);
this.logAIContextMemory()
return response.message.content;
} catch (error) {
console.error("Error generating thought:", error);
@ -113,7 +119,7 @@ export class ConsciousnessSimulator {
this.logMemory('CHAT', `USER: ${prompt}
AI: ${response.message.content}`);
this.logMemory('AI CONTEXT', `Current emotion: ${this.currentEmotion}, Quantum state: ${this.getQuantumState()}`);
this.logAIContextMemory()
return `USER: ${prompt}
AI: ${response.message.content}`;
} catch (error) {
@ -163,7 +169,7 @@ export class ConsciousnessSimulator {
console.log(`**EMOTION DEBUG** - ${this.getLastWordLowerCase(emotion.message.content)}`)
const emotion = emotion.message.content.toLowerCase()
this.currentEmotion = emotion
this.logMemory('AI CONTEXT', `Current emotion: ${this.currentEmotion}, Quantum state: ${this.getQuantumState()}`);
this.logAIContextMemory()
return emotion
} catch {
return "happy"
@ -189,6 +195,12 @@ export class ConsciousnessSimulator {
console.log(`Generated focus: ${this.intent.focus}`);
}
logAIContextMemory() {
this.logMemory('AI CONTEXT', `Current emotion: ${this.currentEmotion},
Current Opinions: ${this.opinions},
Quantum state: ${this.getQuantumState()}`);
}
// Memory logging with USA Format timestamps
logMemory(entryType, content) {
const timestamp = new Date().toLocaleString('en-US', { timeStyle: 'short' });