@@ -264,7 +264,7 @@ def handle_input_collection(self, user_input: str) -> str:
264264 price_display = f"{ original_price } { original_unit } ({ price :,.0f} 원)"
265265 response = scenario_guide + f"상품묘사: { parsed ['product_name' ]} \n 국가: { parsed ['country' ]} \n 가격: { price_display } \n 수량: { parsed .get ('quantity' , 1 )} 개\n \n { RESPONSE_MESSAGES ['hs6_code_prediction_prompt' ]} \n " + '\n ' .join ([
266266 f"{ i + 1 } . { c ['description' ]} ({ RESPONSE_MESSAGES ['hs6_confidence' ]} { c ['confidence' ]:.1%} )" for i , c in enumerate (resp .hs6_candidates or [])
267- ]) + f"\n \n { RESPONSE_MESSAGES [ 'hs6_code_selection_prompt' ] } \n 예시: \" 1번 \" , \" 2번 \" , \" 3번 \" 등 "
267+ ]) + f"\n \n { self . format_selection_guide ( 'hs6_code_selection_prompt' ) } "
268268 self .state ['responses' ].append (response )
269269 return response
270270
@@ -279,6 +279,14 @@ def format_hs6_candidates(self) -> str:
279279 formatted += f"{ i } . { candidate ['code' ]} - { candidate ['description' ]} ({ RESPONSE_MESSAGES ['hs6_confidence' ]} { candidate ['confidence' ]:.1%} )\n "
280280 return formatted
281281
282+ def format_selection_guide (self , selection_prompt_key : str ) -> str :
283+ """번호 선택 안내 + 예시 + 재예측 안내를 포맷팅합니다."""
284+ return (
285+ f"{ RESPONSE_MESSAGES [selection_prompt_key ]} \n "
286+ f"{ RESPONSE_MESSAGES ['number_example' ]} \n "
287+ f"{ RESPONSE_MESSAGES ['reprediction_guide' ]} "
288+ )
289+
282290 def handle_hs6_selection (self , user_input : str ) -> str :
283291 from core .tariff_prediction .tools .parse_hs_results import parse_hs6_result
284292 from core .shared .utils .llm import get_llm
@@ -303,11 +311,11 @@ def handle_hs6_selection(self, user_input: str) -> str:
303311 self .state ['current_step' ] = STEPS ['hs10_selection' ]
304312 response = f"{ RESPONSE_MESSAGES ['hs6_code_selected' ]} { selected ['code' ]} \n \n { RESPONSE_MESSAGES ['hs10_code_prediction_prompt' ]} \n " + '\n ' .join ([
305313 f"{ i + 1 } . { c ['code' ]} - { c ['description' ]} " for i , c in enumerate (resp .hs10_candidates or [])
306- ]) + f"\n \n { RESPONSE_MESSAGES [ 'hs10_code_selection_prompt' ] } \n 예시: \" 1번 \" , \" 2번 \" , \" 3번 \" 등 "
314+ ]) + f"\n \n { self . format_selection_guide ( 'hs10_code_selection_prompt' ) } "
307315 self .state ['responses' ].append (response )
308316 return response
309317 else :
310- response = f" { RESPONSE_MESSAGES [ 'invalid_number' ] } \n \n { RESPONSE_MESSAGES [ ' hs6_code_selection_prompt'] } \n 예시: \" 1번 \" , \" 2번 \" , \" 3번 \" 등"
318+ response = self . format_selection_guide ( ' hs6_code_selection_prompt')
311319 self .state ['responses' ].append (response )
312320 return response
313321 else :
@@ -323,12 +331,12 @@ def handle_hs6_selection(self, user_input: str) -> str:
323331 if answer .lower () in ["네" , "yes" , "true" , "1" ]:
324332 return self ._perform_hs6_reprediction (user_input )
325333 else :
326- response = f" { RESPONSE_MESSAGES [ 'hs6_code_selection_prompt' ] } \n 예시: \" 1번 \" , \" 2번 \" , \" 3번 \" 등 \n \n { RESPONSE_MESSAGES [ 'hs6_code_reprediction_hint' ] } "
334+ response = self . format_selection_guide ( 'hs6_code_selection_prompt' )
327335 self .state ['responses' ].append (response )
328336 return response
329337
330338 except Exception :
331- response = f"{ RESPONSE_MESSAGES ['input_processing_error' ]} \n { RESPONSE_MESSAGES [ 'hs6_code_selection_prompt' ] } \n 예시: \" 1번 \" , \" 2번 \" , \" 3번 \" 등 "
339+ response = f"{ RESPONSE_MESSAGES ['input_processing_error' ]} \n { self . format_selection_guide ( 'hs6_code_selection_prompt' ) } "
332340 self .state ['responses' ].append (response )
333341 return response
334342
0 commit comments