feat(ai): Ask Chat RAG 답변 생성 파이프라인 추가#199
Open
1Seob wants to merge 10 commits into
Open
Conversation
Ask Chat 답변 생성 성공 시 assistant message와 RAG document의 근거 관계를 ask_chat_message_references에 저장하도록 추가하고, prompt augmentation 경계를 AskChatAnswerPromptAugmenter로 분리해 추후 Spring AI Advisor 전환 지점을 명확화함
Ask Chat 답변 프롬프트의 말투와 직전 질문 참조 규칙을 보강하고, 현재 질문 저장 전에 답변 컨텍스트를 생성하도록 순서를 조정함. RAG 검색에서 interestCode가 null일 때 PostgreSQL 파라미터 타입 추론에 실패하던 문제를 CAST(:interestCode AS VARCHAR)로 수정함
AskChatAnswerPromptLoader와 local/dev-prod 구현체를 추가하고, AskChatAnswerPromptComposer가 프롬프트 원문 대신 로더 템플릿 치환만 담당하도록 책임 분리
POST /ask-chat/sessions/new에서 기존 ACTIVE 세션을 ENDED로 종료한 뒤 새 ACTIVE 세션을 생성하도록 추가
dev/prod 배포 워크플로우에서 ASK_CHAT_ANSWER_SYSTEM_PROMPT_B64와 ASK_CHAT_ANSWER_USER_PROMPT_B64를 디코딩해 런타임 환경 변수로 주입하도록 추가
ask_chat_messages에 generation_duration_ms 컬럼을 추가하고, ASSISTANT 메시지 저장 시 RAG 컨텍스트 구성부터 LLM 답변 생성까지의 소요 시간을 ms 단위로 저장하도록 추가
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 요약(Summary)
주요 변경사항
RAG 답변 생성
AskChatAnswerContextService추가ChatClient기반AskChatAnswerLlmClient추가answer,followUpQuestions반환 처리질문 전송 플로우
POST /ask-chat/messages에서 USER 메시지 저장 후 AI 답변 생성 및 ASSISTANT 메시지 저장 연결answeredTurnCount증가interestCode타입 추론 오류 보정근거 문서와 운영 지표
ask_chat_message_references테이블 및 엔티티/레포지토리 추가ask_chat_messages.generation_duration_ms컬럼 추가프롬프트 품질 및 관리 구조
AskChatAnswerPromptLoader인터페이스 추가AskChatAnswerPromptComposer는 템플릿 치환과 컨텍스트 직렬화만 담당하도록 책임 분리세션 API
POST /ask-chat/sessions/new추가배포/설정
application.yml,application-test.yml에 추가ASK_CHAT_ANSWER_SYSTEM_PROMPT_B64,ASK_CHAT_ANSWER_USER_PROMPT_B64디코딩 및 export 추가테스트
검증
./gradlew.bat compileJava./gradlew.bat test --tests "com.devkor.ifive.nadab.domain.askchat.application.helper.AskChatAnswerPromptComposerTest" --tests "com.devkor.ifive.nadab.domain.askchat.infra.AskChatAnswerLlmClientTest"./gradlew.bat test --tests "com.devkor.ifive.nadab.domain.askchat.application.AskChatSessionServiceTest" --tests "com.devkor.ifive.nadab.domain.askchat.application.helper.AskChatAnswerPromptComposerTest" --tests "com.devkor.ifive.nadab.domain.askchat.infra.AskChatAnswerLlmClientTest"./gradlew.bat test --tests "com.devkor.ifive.nadab.domain.askchat.application.AskChatMessageCommandServiceTest" --tests "com.devkor.ifive.nadab.domain.askchat.application.AskChatAnswerContextServiceTest"./gradlew.bat test --tests "com.devkor.ifive.nadab.domain.askchat.core.repository.AskChatMessageReferenceRepositoryTest" --tests "com.devkor.ifive.nadab.domain.askchat.core.repository.AskChatSessionRepositoryTest"git diff --check참고 / 리스크
ASK_CHAT_ANSWER_SYSTEM_PROMPT_B64,ASK_CHAT_ANSWER_USER_PROMPT_B64등록이 필요하여 등록할 예정입니다.src/main/resources/secret/아래에서 관리되며 git 추적 대상이 아닙니다.🔗 Related Issue
💬 공유사항
✅ PR Checklist
PR이 다음 요구 사항을 충족하는지 확인하세요.