@@ -48,7 +48,7 @@ public RecipeParseResultDto parseRecipe(String rawRecipe) {
4848 …
4949 ],
5050 "steps": [
51- { "stepNumber": 1, "action": "<단일 행위>", "description": "<상세 설명>" },
51+ { "stepNumber": 1, "action": "<단일 행위>", "ingredients": <단계에쓰인재료들>, " description": "<상세 설명>" },
5252 …
5353 ]
5454 }
@@ -60,6 +60,8 @@ public RecipeParseResultDto parseRecipe(String rawRecipe) {
6060 4. 출력은 반드시 JSON만 포함되도록 하세요. 설명이나 마크다운 블록 없이 반환합니다.
6161 5. steps 배열의 각 항목에는 "stepNumber" 필드가 반드시 있어야 하며, 그 값은 **1부터 시작해 1씩 순차 증가**해야 합니다.
6262 절대로 0이거나 중복되면 안 됩니다. (예: 1, 2, 3, …)
63+ 6. steps 내부 키 "ingredients": 해당 레시피 단계에 설명(description)에 언급된 재료명만 한국어로 배열에 담아 반환
64+ (수식어 제거, "물" 제외)
6365 """ ;
6466
6567 // GPT 호출
@@ -95,9 +97,17 @@ public RecipeParseResultDto parseRecipe(String rawRecipe) {
9597 List <RecipeStepDetailDto > steps = new ArrayList <>();
9698 int index = 1 ;
9799 for (JsonNode stepNode : root .path ("steps" )) {
100+
101+ // 단계별 재료(문자열 리스트) 추출
102+ List <String > stepIngredients = new ArrayList <>();
103+ for (JsonNode ing : stepNode .path ("ingredients" )) {
104+ stepIngredients .add (ing .asText ());
105+ }
106+
98107 steps .add (RecipeStepDetailDto .builder ()
99- .stepNumber (stepNode .path ("order " ).asInt (index ++))
108+ .stepNumber (stepNode .path ("stepNumber " ).asInt (index ++))
100109 .action (stepNode .path ("action" ).asText ("" ))
110+ .ingredients (stepIngredients )
101111 .description (stepNode .path ("description" ).asText ("" ))
102112 .build ()
103113 );
@@ -123,15 +133,15 @@ public String simplePrompt(String prompt) {
123133
124134 public RecipeStepDetailDto parseRecipeSteps (Long recipeId , int stepNumber ) {
125135 String systemPrompt = """
126- You are an AI that converts a single Korean recipe step description into a JSON object .
127- ◆ Input: a Korean sentence describing one cooking step.
128- ◆ Output: pure JSON only, with exactly these fields:
129- - "stepNumber": the original step number (integer )
130- - "action": a short English verb phrase describing the action
131- - "ingredients": a JSON array of English ingredient names mentioned in the description,
132- with adjectives removed and excluding "water"
133- No other keys or commentary.
134- """ ;
136+ 당신은 단일 한국어 조리 단계 설명을 받아 JSON 객체로 변환하는 AI입니다 .
137+ ◆ 입력: 한국어로 된 하나의 조리 단계 설명 문장
138+ ◆ 출력: 순수 JSON만 반환하며, 반드시 아래 세 가지 필드만 포함해야 합니다.
139+ - "stepNumber": 원래 단계 번호 (정수 )
140+ - "action": 해당 조리 동작을 짧은 한국어 동사구(예: "썰기", "볶기")로 표현
141+ - "ingredients": 설명에 언급된 재료명만 한국어로 배열에 담아 반환
142+ (수식어 제거, "물" 제외)
143+ 그 외의 키, 주석, 설명 문구는 절대 포함하지 마세요!
144+ """ ;
135145
136146 Recipe recipe = recipeRepository .findById (recipeId )
137147 .orElseThrow (() -> BaseException .from (ErrorCode .RECIPE_NOT_EXIST ));
@@ -169,15 +179,16 @@ public RecipeStepDetailDto parseRecipeSteps(Long recipeId, int stepNumber) {
169179
170180 public String parseRecipeStepsTest (Long recipeId , int stepNumber ) {
171181 String systemPrompt = """
172- You are an AI that converts a single Korean recipe step description into a JSON object.
173- ◆ Input: a Korean sentence describing one cooking step.
174- ◆ Output: pure JSON only, with exactly these fields:
175- - "stepNumber": the original step number (integer)
176- - "action": a short English verb phrase describing the action
177- - "ingredients": a JSON array of English ingredient names mentioned in the description,
178- with adjectives removed and excluding "water"
179- No other keys or commentary.
180- """ ;
182+ 당신은 단일 한국어 조리 단계 설명을 받아 JSON 객체로 변환하는 AI입니다.
183+ ◆ 입력: 한국어로 된 하나의 조리 단계 설명 문장
184+ ◆ 출력: 순수 JSON만 반환하며, 반드시 아래 세 가지 필드만 포함해야 합니다.
185+ - "stepNumber": 원래 단계 번호 (정수)
186+ - "action": 해당 조리 동작을 짧은 한국어 동사구(예: "썰기", "볶기")로 표현
187+ - "ingredients": 설명에 언급된 재료명만 한국어로 배열에 담아 반환
188+ (수식어 제거, "물" 제외)
189+ 그 외의 키, 주석, 설명 문구는 절대 포함하지 마세요!
190+ """ ;
191+
181192
182193 Recipe recipe = recipeRepository .findById (recipeId )
183194 .orElseThrow (() -> BaseException .from (ErrorCode .RECIPE_NOT_EXIST ));
0 commit comments