From 97ed5ea45f61fed7654d1e1dc37760ff000c0622 Mon Sep 17 00:00:00 2001 From: koosco Date: Sat, 7 Dec 2024 23:07:20 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20prompt=20=EA=B0=92=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/groom/orbit/ai/app/openai/OpenAiService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/groom/orbit/ai/app/openai/OpenAiService.java b/src/main/java/com/groom/orbit/ai/app/openai/OpenAiService.java index 6248a39..cd39c5b 100644 --- a/src/main/java/com/groom/orbit/ai/app/openai/OpenAiService.java +++ b/src/main/java/com/groom/orbit/ai/app/openai/OpenAiService.java @@ -2,6 +2,8 @@ import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.stream.Stream; import org.springframework.ai.chat.model.ChatModel; import org.springframework.ai.chat.model.ChatResponse; @@ -88,7 +90,13 @@ public RecommendGoalListResponseDto recommendGoal(Long memberId) { "goalList", String.join( PARAMETER_LIST_DELIMITER, - othersVector.stream().flatMap(vector -> vector.goals().stream()).toList()), + othersVector.stream() + .filter(Objects::nonNull) + .flatMap( + vector -> + vector.goals() != null ? vector.goals().stream() : Stream.empty()) + .filter(Objects::nonNull) + .toList()), "format", format)); return converter.convert(response);