From c426aa5ace681b9f54c55959ed2762a1ff4a5dc4 Mon Sep 17 00:00:00 2001 From: Jose Henrique Date: Sun, 14 Jun 2026 16:35:28 -0300 Subject: [PATCH] fixing flashcard generation error --- Mindforge.API/Services/FlashcardService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Mindforge.API/Services/FlashcardService.cs b/Mindforge.API/Services/FlashcardService.cs index bde6744..5e1b0fd 100644 --- a/Mindforge.API/Services/FlashcardService.cs +++ b/Mindforge.API/Services/FlashcardService.cs @@ -193,9 +193,10 @@ namespace Mindforge.API.Services var rawResult = await _agentService.ProcessRequestAsync(systemPrompt, userPrompt); var cards = ParseFlashcardsFromJson(rawResult); - if (cards.Count < amount) + var minimumAcceptable = (int)Math.Ceiling(amount * 0.75); + if (cards.Count < minimumAcceptable) { - throw new Exception($"Quantidade insuficiente de flashcards gerados para {filePath}. Esperado: {amount}. Recebido: {cards.Count}."); + throw new Exception($"Quantidade insuficiente de flashcards gerados para {filePath}. Esperado: {amount}. Minimo aceitavel: {minimumAcceptable}. Recebido: {cards.Count}."); } if (cards.Count > amount)