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";
|
||||
// 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' });
|
||||
|
|
Loading…
Reference in a new issue