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