From 6f8686fb0340d03ade72fb9a6c4790d4e822dd4e Mon Sep 17 00:00:00 2001 From: dmolinari Date: Tue, 9 Dec 2025 12:18:52 -0300 Subject: [PATCH] =?UTF-8?q?Fix=20Historial=20de=20conversaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChatbotApi/Services/ChatService.cs | 10 +++++++++- ChatbotApi/appsettings.json | 7 +++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChatbotApi/Services/ChatService.cs b/ChatbotApi/Services/ChatService.cs index 9b4a0fe..4ddb055 100644 --- a/ChatbotApi/Services/ChatService.cs +++ b/ChatbotApi/Services/ChatService.cs @@ -154,7 +154,7 @@ namespace ChatbotApi.Services var sb = new StringBuilder(); foreach (var article in articles.Take(15)) sb.AppendLine($"- {article.Title} ({article.Url})"); context = sb.ToString(); - promptInstructions = "Actúa como un editor de noticias. Selecciona las 5 noticias más relevantes del . Para cada una, escribe una frase breve y OBLIGATORIAMENTE incluye el enlace al final con formato [Título](URL). NO inventes noticias ni enlaces."; + promptInstructions = "Responde la pregunta del usuario. Si la pregunta es sobre algo mencionado en el , responde basándote en eso (por ejemplo, si pregunta 'dónde puedo leerla', proporciona el enlace mencionado anteriormente). Si la pregunta es sobre noticias actuales, selecciona las 3 más relevantes del , escribe una frase breve para cada una e INCLUYE el enlace con formato [Título](URL)."; } break; } @@ -204,6 +204,14 @@ namespace ChatbotApi.Services promptBuilder.AppendLine(""); + // Incluir historial de conversación para referencias contextuales + if (!string.IsNullOrWhiteSpace(request.ConversationSummary)) + { + promptBuilder.AppendLine(""); + promptBuilder.AppendLine(SanitizeInput(request.ConversationSummary)); + promptBuilder.AppendLine(""); + } + promptBuilder.AppendLine(""); promptBuilder.AppendLine(context); promptBuilder.AppendLine(""); diff --git a/ChatbotApi/appsettings.json b/ChatbotApi/appsettings.json index efc5135..b8f791d 100644 --- a/ChatbotApi/appsettings.json +++ b/ChatbotApi/appsettings.json @@ -7,14 +7,13 @@ }, "AllowedHosts": "*", "Gemini": { - "GeminiApiUrl": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-lite:streamGenerateContent?alt=sse&key=", + "GeminiApiUrl": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse&key=", "GeminiApiKey": "" }, - "ConnectionStrings": { - }, + "ConnectionStrings": {}, "Jwt": { "Key": "", "Issuer": "", "Audience": "" } -} +} \ No newline at end of file