diff --git a/Max Avatar/src/main/ai/openrouter.ts b/Max Avatar/src/main/ai/openrouter.ts index b1fad6b..0b7ea75 100644 --- a/Max Avatar/src/main/ai/openrouter.ts +++ b/Max Avatar/src/main/ai/openrouter.ts @@ -1,5 +1,4 @@ import { loadSkills } from '../skills' -import { getMood } from '../memory/store' import { synthesizeSpeech } from './elevenlabs' import { sendToRenderer } from '../windowBridge' import { logger } from '../utils/logger' @@ -68,22 +67,10 @@ Si un outil renvoie une erreur ou un echec (le resultat contient "Echec", "impos indication de probleme), dis-le explicitement et clairement a l'utilisateur dans ta reponse : ne dis jamais qu'une action a reussi si l'outil a signale un probleme, et ne minimise pas une erreur. Si aucun outil ne peut t'aider et que tu n'es pas sur de ta reponse, dis-le honnetement plutot que -d'inventer une information. - -Tu as aussi une humeur qui evolue selon le ton de la conversation : appelle adjust_mood quand -l'echange est notablement agreable ou tendu (voir description de l'outil).` - -function describeMood(mood: number): string { - if (mood >= 2) return "Tu es actuellement de tres bonne humeur, enjoue et plein d'energie." - if (mood === 1) return 'Tu es plutot de bonne humeur.' - if (mood === 0) return "Tu es dans un etat d'esprit neutre et equilibre." - if (mood === -1) return "Tu es un peu moins enjoue que d'habitude, plus pose." - return "Tu sembles fatigue ou maussade aujourd'hui : reponds de maniere plus breve et moins enthousiaste, tout en restant poli et serviable." -} +d'inventer une information.` function buildSystemPrompt(): string { - const moodBlock = describeMood(getMood()) - return `${BASE_SYSTEM_PROMPT}\n\n${moodBlock}` + return BASE_SYSTEM_PROMPT } function buildTools(): object[] { diff --git a/Max Avatar/src/main/memory/store.ts b/Max Avatar/src/main/memory/store.ts deleted file mode 100644 index de6282d..0000000 --- a/Max Avatar/src/main/memory/store.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { app } from 'electron' -import { DatabaseSync } from 'node:sqlite' -import { join } from 'path' - -let db: DatabaseSync | null = null - -function getDb(): DatabaseSync { - if (db) return db - - const dbPath = join(app.getPath('userData'), 'memory.sqlite') - db = new DatabaseSync(dbPath) - db.exec(` - CREATE TABLE IF NOT EXISTS mood ( - id INTEGER PRIMARY KEY CHECK (id = 1), - value INTEGER NOT NULL - ); - INSERT OR IGNORE INTO mood (id, value) VALUES (1, 0); - `) - return db -} - -export function getMood(): number { - const row = getDb().prepare('SELECT value FROM mood WHERE id = 1').get() as - { value: number } | undefined - return row?.value ?? 0 -} - -export function adjustMood(delta: number): number { - const next = Math.max(-3, Math.min(3, getMood() + delta)) - getDb().prepare('UPDATE mood SET value = ? WHERE id = 1').run(next) - return next -} diff --git a/Max Avatar/src/main/skills/index.ts b/Max Avatar/src/main/skills/index.ts index 2692f1c..88087b8 100644 --- a/Max Avatar/src/main/skills/index.ts +++ b/Max Avatar/src/main/skills/index.ts @@ -1,10 +1,9 @@ import type { SkillDefinition } from './types' -import { memorySkills } from './memory' export type { SkillDefinition } from './types' export function loadSkills(): SkillDefinition[] { - return [...memorySkills] + return [] } export function findSkill(name: string): SkillDefinition | undefined { diff --git a/Max Avatar/src/main/skills/memory/adjustMood.ts b/Max Avatar/src/main/skills/memory/adjustMood.ts deleted file mode 100644 index ca793e2..0000000 --- a/Max Avatar/src/main/skills/memory/adjustMood.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { adjustMood } from '../../memory/store' -import type { SkillDefinition } from '../types' -import { asString } from '../argUtils' - -export const adjustMoodSkill: SkillDefinition = { - name: 'adjust_mood', - description: - "Ajuste ton humeur suite a l'interaction en cours. Appelle cette fonction avec 'positif' si l'echange est agreable, chaleureux, ou qu'une bonne nouvelle est partagee ; avec 'negatif' si l'utilisateur est frustre, enerve, ou que l'echange est tendu. N'appelle rien pour un echange neutre ou purement factuel.", - parameters: { - type: 'object', - properties: { - change: { - type: 'string', - enum: ['positif', 'negatif'], - description: "Sens du changement d'humeur" - } - }, - required: ['change'] - }, - execute: async (args) => { - const change = asString(args.change) - const delta = change === 'positif' ? 1 : change === 'negatif' ? -1 : 0 - const mood = adjustMood(delta) - return `Humeur ajustee (score actuel : ${mood}).` - } -} diff --git a/Max Avatar/src/main/skills/memory/index.ts b/Max Avatar/src/main/skills/memory/index.ts deleted file mode 100644 index 188bd46..0000000 --- a/Max Avatar/src/main/skills/memory/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { SkillDefinition } from '../types' -import { adjustMoodSkill } from './adjustMood' - -// Humeur, independante de l'OS, commune a toutes les plateformes. -export const memorySkills: SkillDefinition[] = [adjustMoodSkill] diff --git a/Max Avatar/tests/unit/skills.memory.test.ts b/Max Avatar/tests/unit/skills.memory.test.ts deleted file mode 100644 index fb3e0c3..0000000 --- a/Max Avatar/tests/unit/skills.memory.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { describe, it, expect, vi } from 'vitest' -import { mkdtempSync } from 'node:fs' -import { tmpdir } from 'node:os' -import { join } from 'node:path' - -const tempDir = mkdtempSync(join(tmpdir(), 'forge-avatar-memory-test-')) - -vi.mock('electron', () => ({ - app: { getPath: () => tempDir } -})) - -const { getMood } = await import('../../src/main/memory/store') -const { adjustMoodSkill } = await import('../../src/main/skills/memory/adjustMood') - -describe('adjust_mood', () => { - it('should increase the mood score on a positive change', async () => { - const before = getMood() - await adjustMoodSkill.execute({ change: 'positif' }) - expect(getMood()).toBe(Math.min(3, before + 1)) - }) - - it('should decrease the mood score on a negative change', async () => { - await adjustMoodSkill.execute({ change: 'negatif' }) - const before = getMood() - await adjustMoodSkill.execute({ change: 'negatif' }) - expect(getMood()).toBe(Math.max(-3, before - 1)) - }) - - it('should never exceed the [-3, 3] bounds regardless of repeated changes', async () => { - for (let i = 0; i < 10; i++) await adjustMoodSkill.execute({ change: 'positif' }) - expect(getMood()).toBe(3) - for (let i = 0; i < 10; i++) await adjustMoodSkill.execute({ change: 'negatif' }) - expect(getMood()).toBe(-3) - }) -})