Fix Historial de conversación

This commit is contained in:
2025-12-09 12:18:52 -03:00
parent 2a36093dfb
commit 6f8686fb03
2 changed files with 12 additions and 5 deletions

View File

@@ -154,7 +154,7 @@ namespace ChatbotApi.Services
var sb = new StringBuilder(); var sb = new StringBuilder();
foreach (var article in articles.Take(15)) sb.AppendLine($"- {article.Title} ({article.Url})"); foreach (var article in articles.Take(15)) sb.AppendLine($"- {article.Title} ({article.Url})");
context = sb.ToString(); context = sb.ToString();
promptInstructions = "Actúa como un editor de noticias. Selecciona las 5 noticias más relevantes del <contexto>. 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 <historial_conversacion>, 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 <contexto>, escribe una frase breve para cada una e INCLUYE el enlace con formato [Título](URL).";
} }
break; break;
} }
@@ -204,6 +204,14 @@ namespace ChatbotApi.Services
promptBuilder.AppendLine("</instrucciones_sistema>"); promptBuilder.AppendLine("</instrucciones_sistema>");
// Incluir historial de conversación para referencias contextuales
if (!string.IsNullOrWhiteSpace(request.ConversationSummary))
{
promptBuilder.AppendLine("<historial_conversacion>");
promptBuilder.AppendLine(SanitizeInput(request.ConversationSummary));
promptBuilder.AppendLine("</historial_conversacion>");
}
promptBuilder.AppendLine("<contexto>"); promptBuilder.AppendLine("<contexto>");
promptBuilder.AppendLine(context); promptBuilder.AppendLine(context);
promptBuilder.AppendLine("</contexto>"); promptBuilder.AppendLine("</contexto>");

View File

@@ -7,14 +7,13 @@
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"Gemini": { "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": "" "GeminiApiKey": ""
}, },
"ConnectionStrings": { "ConnectionStrings": {},
},
"Jwt": { "Jwt": {
"Key": "", "Key": "",
"Issuer": "", "Issuer": "",
"Audience": "" "Audience": ""
} }
} }