[고객지원 챗봇 만들기] 이창희 제출합니다.#7
Conversation
구어체 변환 과정 추가 고객의 틀린정보 제공 방어 추가(hard 용)
There was a problem hiding this comment.
Code Review
This pull request introduces a RAG-based chatbot implementation using Spring AI, incorporating a multi-layered document retrieval system that searches across FAQ, policy, and chatlog data. It also includes a comprehensive evaluation suite to measure chatbot quality through specific KPIs and parallel processing. The review feedback suggests enhancing the implementation by using dependency injection for the ObjectMapper, adding defensive null checks for AI response metadata, and implementing input validation for the chatbot request DTO.
| private static final String LAYER_CHATLOG = "chatlog"; | ||
| private static final String ACCURACY_CORRECT = "correct"; | ||
|
|
||
| private final ObjectMapper objectMapper = new ObjectMapper(); |
There was a problem hiding this comment.
| Usage usage = response.getMetadata().getUsage(); | ||
| return new ChatbotResult( | ||
| response.getResult().getOutput().getText(), | ||
| usage.getPromptTokens(), | ||
| usage.getCompletionTokens(), | ||
| usage.getTotalTokens() | ||
| ); |
There was a problem hiding this comment.
AI 모델의 응답 메타데이터나 토큰 사용량(Usage) 정보는 상황에 따라 null일 수 있습니다. 또한 response.getResult() 등의 호출 결과에 대해서도 NPE(NullPointerException)가 발생하지 않도록 방어적인 코드를 추가하는 것이 안전합니다.
Usage usage = (response.getMetadata() != null) ? response.getMetadata().getUsage() : null;
String answer = (response.getResult() != null && response.getResult().getOutput() != null)
? response.getResult().getOutput().getText()
: "";
return new ChatbotResult(
answer,
usage != null ? usage.getPromptTokens() : 0,
usage != null ? usage.getCompletionTokens() : 0,
usage != null ? usage.getTotalTokens() : 0
);| package com.cholog.bootcamp.chatbot.presentation.dto; | ||
|
|
||
| public record ChatbotRequest( | ||
| String question |
안녕하세요! 챗봇 구현 내용 PR 제출합니다 🙋♂️
구현 내용
##) 기준 청킹 + 상위 헤더(#) 접두어로 카테고리 맥락 포함