Skip to content

[고객지원 챗봇 만들기] 이창희 제출합니다.#7

Open
chxghee wants to merge 20 commits into
cho-log:mainfrom
chxghee:chxghee
Open

[고객지원 챗봇 만들기] 이창희 제출합니다.#7
chxghee wants to merge 20 commits into
cho-log:mainfrom
chxghee:chxghee

Conversation

@chxghee
Copy link
Copy Markdown

@chxghee chxghee commented May 23, 2026

안녕하세요! 챗봇 구현 내용 PR 제출합니다 🙋‍♂️

구현 내용

  • Spring AI + SimpleVectorStore 기반 RAG 챗봇 구현
  • FAQ / 정책 문서 / 챗로그 3개 레이어로 문서를 분리하여 관리
  • 청킹 전략: 마크다운 헤더(##) 기준 청킹 + 상위 헤더(#) 접두어로 카테고리 맥락 포함
  • Top-k 설정 : 레이어별 top-k 독립 설정으로 정책 문서가 챗로그에 밀리지 않도록 보장
    • FAQ: 4 / 정책 문서: 4 / 챗로그: 3 = 총 11개
  • 평가 스크립트 수정: 여러 축의 KPI 평가 기준을 설계하고, 항목별 루브릭 평가 진행

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

ObjectMapper를 클래스 내부에서 직접 생성하기보다 Spring의 의존성 주입(DI)을 통해 주입받아 사용하는 것이 좋습니다. 이를 통해 애플리케이션 전반의 JSON 설정 일관성을 유지할 수 있으며, 테스트 시 모킹(Mocking)이 용이해집니다.

    private final ObjectMapper objectMapper;

    public ChatlogParser(ObjectMapper objectMapper) {
        this.objectMapper = objectMapper;
    }

Comment on lines +14 to +20
Usage usage = response.getMetadata().getUsage();
return new ChatbotResult(
response.getResult().getOutput().getText(),
usage.getPromptTokens(),
usage.getCompletionTokens(),
usage.getTotalTokens()
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

챗봇 요청의 핵심인 question 필드에 대한 유효성 검사가 누락되었습니다. 빈 문자열이나 null이 전달될 경우 RAG 검색 과정에서 예외가 발생할 수 있으므로, @NotBlank와 같은 제약 조건을 추가하여 입력을 검증하는 것이 좋습니다. (참고: 이를 위해 spring-boot-starter-validation 의존성 추가가 필요할 수 있습니다.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant