From 760ba34fa8e894f4f7898d64517db95e7dc37e02 Mon Sep 17 00:00:00 2001 From: leninner Date: Tue, 7 Oct 2025 09:55:02 -0500 Subject: [PATCH 1/2] chore: pause AI integration; --- .../controllers/voice-command.controller.ts | 66 ++++++++++++------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/src/features/ai-agents/infrastructure/controllers/voice-command.controller.ts b/src/features/ai-agents/infrastructure/controllers/voice-command.controller.ts index b024541..714b5e8 100644 --- a/src/features/ai-agents/infrastructure/controllers/voice-command.controller.ts +++ b/src/features/ai-agents/infrastructure/controllers/voice-command.controller.ts @@ -52,35 +52,51 @@ app.post("/voice-command", async (c) => { }, 401); } - const user = payload as { id: number; email: string }; - const body = await c.req?.formData(); - const audioFile = body?.get("audio") as File; + return c.json({ + "success": true, + "intent": "CREATE_TRANSACTION", + "extractedData": { + "user_id": 1, + "amount": 25, + "type": "EXPENSE", + "description": "desayuno", + "category_id": null, + "payment_method_id": null, + "date": "2025-10-07T13:18:32.623Z" + }, + "confidence": 0.95, + "message": "He identificado una transacción: Gasto de $25 en desayuno" +}); - if (!audioFile) { - return c.json({ - success: false, - message: "No se recibió archivo de audio" - }, 400); - } + // const user = payload as { id: number; email: string }; + // const body = await c.req?.formData(); + // const audioFile = body?.get("audio") as File; - const audioBlob = new Blob([await audioFile.arrayBuffer()], { - type: audioFile.type || 'audio/wav' - }); + // if (!audioFile) { + // return c.json({ + // success: false, + // message: "No se recibió archivo de audio" + // }, 400); + // } - const result = await processVoiceCommandUseCase.execute({ - audioBlob, - userId: user.id - }); + // const audioBlob = new Blob([await audioFile.arrayBuffer()], { + // type: audioFile.type || 'audio/wav' + // }); - return c.json({ - success: result.success, - intent: result.intent, - extractedData: result.extractedData, - confidence: result.confidence, - message: result.message, - validationErrors: result.validationErrors, - suggestedCorrections: result.suggestedCorrections - }); + // const result = await processVoiceCommandUseCase.execute({ + // audioBlob, + // userId: user.id + // }); + + // return c.json({ + // success: result.success, + // intent: result.intent, + // extractedData: result.extractedData, + // confidence: result.confidence, + // message: result.message, + // validationErrors: result.validationErrors, + // suggestedCorrections: result.suggestedCorrections + // }); } catch (error) { console.error("Error processing voice command:", error); From 8861e0d46618808999829690b4a0d00ba29b6cb2 Mon Sep 17 00:00:00 2001 From: leninner Date: Thu, 9 Oct 2025 17:15:35 -0500 Subject: [PATCH 2/2] chore: update --- .../adapters/openai-llm.adapter.ts | 9 +++++---- .../controllers/voice-command.controller.ts | 17 +++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/features/ai-agents/infrastructure/adapters/openai-llm.adapter.ts b/src/features/ai-agents/infrastructure/adapters/openai-llm.adapter.ts index ba3e876..0b74053 100644 --- a/src/features/ai-agents/infrastructure/adapters/openai-llm.adapter.ts +++ b/src/features/ai-agents/infrastructure/adapters/openai-llm.adapter.ts @@ -36,7 +36,7 @@ Responde SOLO con un JSON en este formato: } async extractData(transcription: string, intent: string): Promise<{ data: Record; confidence: number }> { - let prompt = ''; + let prompt = 'category_id=1,comida;2,viajes;3,education;4,otro\n'; switch (intent) { case 'CREATE_TRANSACTION': @@ -49,7 +49,7 @@ Responde SOLO con un JSON con estos campos: "amount": número, "type": "INCOME" o "EXPENSE", "description": "descripción", - "category": "nombre de categoría si se menciona", + "category_id": "nombre de categoría si se menciona", "payment_method": "método de pago si se menciona", "confidence": 0.0-1.0 } @@ -82,7 +82,8 @@ Responde SOLO con un JSON con estos campos: "limit_amount": número, "category": "nombre de categoría", "month": "mes/año si se menciona", - "confidence": 0.0-1.0 + "confidence": 0.0-1.0, + "category_id": id de la categoria segun corresponda } `; break; @@ -120,7 +121,7 @@ Responde SOLO con un JSON con estos campos: model: 'gpt-3.5-turbo-instruct', prompt: fullPrompt, temperature: 0.3, - max_tokens: 500 + max_tokens: 400 }), }); diff --git a/src/features/ai-agents/infrastructure/controllers/voice-command.controller.ts b/src/features/ai-agents/infrastructure/controllers/voice-command.controller.ts index 714b5e8..97b6eb1 100644 --- a/src/features/ai-agents/infrastructure/controllers/voice-command.controller.ts +++ b/src/features/ai-agents/infrastructure/controllers/voice-command.controller.ts @@ -52,20 +52,21 @@ app.post("/voice-command", async (c) => { }, 401); } - return c.json({ + return c.json({ "success": true, - "intent": "CREATE_TRANSACTION", + "intent": "CREATE_GOAL", "extractedData": { "user_id": 1, - "amount": 25, - "type": "EXPENSE", - "description": "desayuno", + "name": "meta de ahorro para comida", + "target_amount": 600, + "current_amount": 0, + "end_date": "2026-10-09T21:58:33.460Z", "category_id": null, - "payment_method_id": null, - "date": "2025-10-07T13:18:32.623Z" + "contribution_frequency": null, + "contribution_amount": null }, "confidence": 0.95, - "message": "He identificado una transacción: Gasto de $25 en desayuno" + "message": "He identificado una meta de ahorro: \"meta de ahorro para comida\" con objetivo de $600" }); // const user = payload as { id: number; email: string };