From d65dd88bba006841c5f52ae6027fd37cd4863668 Mon Sep 17 00:00:00 2001 From: sb Date: Sun, 5 Jul 2026 12:36:40 +0900 Subject: [PATCH] =?UTF-8?q?chore(ai):=20=ED=8C=8C=EC=8B=B1=20=EC=A0=84?= =?UTF-8?q?=EA=B3=BC=EC=A0=95=20=EC=A7=84=EB=8B=A8=20=EB=A1=9C=EA=B7=B8(?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=ED=85=8D=EC=8A=A4=ED=8A=B8=C2=B7=EB=AA=A8?= =?UTF-8?q?=EB=8D=B8=EC=9B=90=EB=AC=B8=C2=B7=EA=B2=B0=EA=B3=BC)=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- .../com/sb/web/account/service/AiEntryParser.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sb/web/account/service/AiEntryParser.java b/src/main/java/com/sb/web/account/service/AiEntryParser.java index 495c237..42fabe1 100644 --- a/src/main/java/com/sb/web/account/service/AiEntryParser.java +++ b/src/main/java/com/sb/web/account/service/AiEntryParser.java @@ -51,7 +51,11 @@ public class AiEntryParser { /** 자유 텍스트 → 파싱 결과. 실패/미설정 시 empty. */ public Optional parse(String text, LocalDate today) { - if (!enabled() || text == null || text.isBlank()) return Optional.empty(); + if (!enabled() || text == null || text.isBlank()) { + log.info("[ai-parse] 건너뜀 — enabled={}, textBlank={}", enabled(), (text == null || text.isBlank())); + return Optional.empty(); + } + log.info("[ai-parse] 요청 수신 — text='{}'", text); try { String system = (""" 너는 한국어 가계부 입력 도우미다. 사용자가 자연어로 쓴 한 줄 지출/수입 메모를 구조화한다. @@ -81,6 +85,7 @@ public class AiEntryParser { .body(JsonNode.class); String out = stripFences(resp.path("content").path(0).path("text").asText("")).trim(); + log.info("[ai-parse] 모델 원문='{}'", out); JsonNode j = om.readTree(out); String type = "INCOME".equalsIgnoreCase(j.path("type").asText("EXPENSE")) ? "INCOME" : "EXPENSE"; @@ -90,13 +95,16 @@ public class AiEntryParser { } catch (Exception e) { date = today; } - return Optional.of(ParsedEntryResponse.builder() + ParsedEntryResponse result = ParsedEntryResponse.builder() .recognized(j.path("recognized").asBoolean(false)) .type(type) .amount(Math.max(0, j.path("amount").asLong(0))) .merchant(j.path("merchant").asText("")) .date(date) - .build()); + .build(); + log.info("[ai-parse] 결과 — recognized={}, type={}, amount={}, merchant={}, date={}", + result.isRecognized(), result.getType(), result.getAmount(), result.getMerchant(), result.getDate()); + return Optional.of(result); } catch (Exception e) { log.warn("[ai-parse] 실패 → 규칙기반 폴백: {}", e.toString()); return Optional.empty();