feat(ai): 자연어 한 줄 입력 파싱 — Claude Haiku 프록시(키 서버보관·실패 시 규칙 폴백)

- AiEntryParser: /v1/messages(Haiku) 호출로 '어제 스타벅스 5천원'→{type,amount,merchant,date} 추출
- AccountService.parseText: AI 우선 시도, 미설정/실패/미인식 시 기존 규칙기반 파서로 폴백(무중단)
- app.anthropic-api-key/anthropic-model 설정(키 없으면 AI 비활성)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
sb
2026-07-05 11:24:14 +09:00
co-authored by Claude Opus 4.8
parent 0082e647c2
commit 811cc1b391
3 changed files with 120 additions and 3 deletions
@@ -49,6 +49,7 @@ public class AccountService {
private final WalletMapper walletMapper;
private final InvestService investService;
private final CardNotificationParser notificationParser;
private final AiEntryParser aiEntryParser;
private final PointService pointService;
/* ===================== 항목 ===================== */
@@ -299,10 +300,18 @@ public class AccountService {
* 카드 결제 푸시 알림 → 미확인(pending) 지출 내역 생성.
* 결제 알림이 아니거나 중복이면 null 반환(생성 안 함). 취소 알림도 일단 무시(v1).
*/
/** 문자/푸시 텍스트만 파싱해 폼 자동채움용 결과 반환 (저장 안 함). iPhone 등 알림 자동수집 불가 대비. */
/**
* 문자/푸시·자연어 한 줄 텍스트를 파싱해 폼 자동채움용 결과 반환 (저장 안 함).
* AI 파서(Claude Haiku)가 설정돼 있으면 우선 시도("어제 스타벅스 5천원" 같은 자유 입력 처리),
* 미설정/실패/미인식이면 기존 규칙기반 카드알림 파서로 폴백.
*/
public ParsedEntryResponse parseText(NotificationRequest req) {
CardNotificationParser.Parsed p =
notificationParser.parse(req.getTitle(), req.getText(), java.time.LocalDate.now());
java.time.LocalDate today = java.time.LocalDate.now();
java.util.Optional<ParsedEntryResponse> ai = aiEntryParser.parse(req.getText(), today);
if (ai.isPresent() && ai.get().isRecognized()) {
return ai.get();
}
CardNotificationParser.Parsed p = notificationParser.parse(req.getTitle(), req.getText(), today);
return ParsedEntryResponse.builder()
.recognized(p.isRecognized())
.type(p.isIncome() ? "INCOME" : "EXPENSE")