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)