diff --git a/backend/src/main/java/com/shyashyashya/refit/batch/service/QuestionCategoryBatchService.java b/backend/src/main/java/com/shyashyashya/refit/batch/service/QuestionCategoryBatchService.java index e0d1ca8c7..dc42c4e2e 100644 --- a/backend/src/main/java/com/shyashyashya/refit/batch/service/QuestionCategoryBatchService.java +++ b/backend/src/main/java/com/shyashyashya/refit/batch/service/QuestionCategoryBatchService.java @@ -63,6 +63,15 @@ public void createCategories() { Long categoryId = tempIdToCategoryId.get(tempCategoryId); String categoryName = tempIdToCategoryName.get(tempCategoryId); + if (categoryId == null || categoryName == null) { + log.warn( + "[createCategories] category id or category name not exists: temp id = {}, real id = {}, category name = {}", + tempCategoryId, + categoryId, + categoryName); + continue; + } + log.debug("[createCategories] save question category vector"); CategoryVectorDocument categoryVectorDocument = CategoryVectorDocument.of( categoryId, tempCategory.getCentroidVector(), Map.of("categoryName", categoryName)); diff --git a/backend/src/main/java/com/shyashyashya/refit/global/util/PromptGenerateUtil.java b/backend/src/main/java/com/shyashyashya/refit/global/util/PromptGenerateUtil.java index 0720796c4..7f6812e97 100644 --- a/backend/src/main/java/com/shyashyashya/refit/global/util/PromptGenerateUtil.java +++ b/backend/src/main/java/com/shyashyashya/refit/global/util/PromptGenerateUtil.java @@ -80,7 +80,10 @@ private List convertToReques .map(category -> { List questionIds = category.getQuestionDocumentIds(); List questions = questionVectors.stream() - .filter(questionVector -> questionIds.contains(questionVector.getId())) + .filter(questionVector -> { + List subList = questionIds.size() > 30 ? questionIds.subList(0, 30) : questionIds; + return subList.contains(questionVector.getId()); + }) .map(QuestionVectorDocument::getQuestion) .toList(); return new PromptGenerateUtil.CategoryNameCreatePromptRequest(category.getId(), questions);