From ffc7dc68fe69a7d3858dd4f0edbf73c91cdafe0b Mon Sep 17 00:00:00 2001 From: Orionis312050 Date: Fri, 17 Apr 2026 12:08:59 +0200 Subject: [PATCH] Features --- debug_db.ts | 5 ++++- prisma/schema.prisma | 1 + src/index.ts | 10 ++++++---- src/routes/aiRoutes.ts | 7 ++++++- src/services/aiOrchestrator.ts | 2 ++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/debug_db.ts b/debug_db.ts index c07f2c8..4645786 100644 --- a/debug_db.ts +++ b/debug_db.ts @@ -15,8 +15,11 @@ async function main() { try { const services = await prisma.service.findMany(); console.log('Services found in DB:', JSON.stringify(services, null, 2)); + + const settings = await prisma.globalSettings.findMany(); + console.log('GlobalSettings found in DB:', JSON.stringify(settings, null, 2)); } catch (e) { - console.error('Error querying services:', e); + console.error('Error querying DB:', e); } finally { await prisma.$disconnect(); } diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 5d76c24..c690a5c 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -51,4 +51,5 @@ model GlobalSettings { ollamaUrl String? // e.g., http://localhost:11434 ollamaModel String? // e.g., qwen:7b searxngUrl String? // e.g., http://localhost:8080 + aiLanguage String? // e.g., Français, English } diff --git a/src/index.ts b/src/index.ts index 34aa9a5..7025872 100644 --- a/src/index.ts +++ b/src/index.ts @@ -122,17 +122,19 @@ app.get('/api/os/services', async (req, res) => { app.get('/api/settings', async (req, res) => { let settings = await prisma.globalSettings.findUnique({ where: { id: 1 } }); if (!settings) { - settings = await prisma.globalSettings.create({ data: { id: 1, notionToken: '', notionDbId: '', ollamaUrl: '', ollamaModel: '', searxngUrl: '' } }); + settings = await prisma.globalSettings.create({ + data: { id: 1, notionToken: '', notionDbId: '', ollamaUrl: '', ollamaModel: '', searxngUrl: '', aiLanguage: 'Français' } + }); } res.json(settings); }); app.post('/api/settings', async (req, res) => { - const { notionToken, notionDbId, ollamaUrl, ollamaModel, searxngUrl } = req.body; + const { notionToken, notionDbId, ollamaUrl, ollamaModel, searxngUrl, aiLanguage } = req.body; const settings = await prisma.globalSettings.upsert({ where: { id: 1 }, - update: { notionToken, notionDbId, ollamaUrl, ollamaModel, searxngUrl }, - create: { id: 1, notionToken, notionDbId, ollamaUrl, ollamaModel, searxngUrl } + update: { notionToken, notionDbId, ollamaUrl, ollamaModel, searxngUrl, aiLanguage }, + create: { id: 1, notionToken, notionDbId, ollamaUrl, ollamaModel, searxngUrl, aiLanguage } }); res.json(settings); }); diff --git a/src/routes/aiRoutes.ts b/src/routes/aiRoutes.ts index 729a690..225d692 100644 --- a/src/routes/aiRoutes.ts +++ b/src/routes/aiRoutes.ts @@ -24,6 +24,11 @@ router.post('/conversations', async (req: AuthRequest, res: Response) => { const { title } = req.body; try { const userId = req.user!.id; + + // Récupérer la langue préférée + const settings = await prisma.globalSettings.findUnique({ where: { id: 1 } }); + const language = settings?.aiLanguage || "Français"; + const conversation = await prisma.conversation.create({ data: { title: title || "Nouvelle discussion", @@ -31,7 +36,7 @@ router.post('/conversations', async (req: AuthRequest, res: Response) => { messages: { create: { role: 'system', - content: "Tu es un assistant expert DevOps intégré au système LogAI. Ton rôle est d'aider l'utilisateur à interpréter les logs, déboguer les services (Docker/OS) et conseiller sur l'infrastructure. Réponds de manière concise et technique en français." + content: `Tu es un assistant expert DevOps intégré au système LogAI. Ton rôle est d'aider l'utilisateur à interpréter les logs, déboguer les services (Docker/OS) et conseiller sur l'infrastructure. Réponds exclusivement en ${language}.` } } }, diff --git a/src/services/aiOrchestrator.ts b/src/services/aiOrchestrator.ts index d7f8c43..303247f 100644 --- a/src/services/aiOrchestrator.ts +++ b/src/services/aiOrchestrator.ts @@ -75,9 +75,11 @@ Requête de recherche (uniquement la requête ou "NORMAL") :`; } // ÉTAPE 2 : Analyse finale de chaque log du paquet + const language = settings.aiLanguage || "Français"; const finalPrompt = ` Tu es un expert DevOps. Analyse individuellement chaque log du paquet ci-dessous. Utilise les résultats de recherche web fournis pour proposer des solutions concrètes aux erreurs. +Réponds exclusivement en ${language}. ${webContext} ---