feat(ai): Ask Chat 히스토리 저장/조회 및 RAG 기반 추가#196
Merged
Conversation
Ask Chat 세션과 메시지 저장을 위한 Flyway migration 및 JPA 엔티티 추가, 대화 상태와 메시지 역할/상태 enum 정의, LLM provider/model 및 토큰 사용량 기록 필드 추가
AskChatSessionRepository와 AskChatMessageRepository를 추가해 세션 소유권 확인, 활성 세션 조회, 히스토리 목록 조회, 세션별 메시지 조회, 완료된 assistant 메시지 수 집계 지원
AskChatHistoryController와 AskChatHistoryQueryService를 추가해 히스토리 목록 및 상세 조회를 지원하고, 세션 소유권 검증과 ASK_CHAT_SESSION_NOT_FOUND 오류 응답 처리 추가
AskChatHistoryQueryServiceTest를 추가해 히스토리 목록 pagination, 첫 사용자 메시지 제목 매핑, 상세 메시지 시간순 조회, 세션 소유권 실패, 잘못된 page/size 요청 검증
ask_chat_rag_documents 테이블과 pgvector 기반 embedding 컬럼 및 HNSW 인덱스를 추가하고, RAG 문서 source/metadata/embedding 상태 관리를 위한 엔티티와 enum 추가
AskChatRagDocumentRepository와 AskChatRagVectorRepository를 추가해 RAG 문서 중복 조회, embedding 상태 갱신, 사용자 및 관심사 기준 pgvector 유사도 검색 지원
Ask Chat RAG용 embedding 설정과 Spring AI OpenAiEmbeddingModel 호출 래퍼를 추가해 embedding model/version 관리와 pgvector 저장용 벡터 변환 지원
완료된 assistant 메시지를 RAG 문서로 저장하고 embedding 생성 후 pgvector 컬럼을 갱신하는 indexing 흐름 추가
AskChatRagIndexingService의 정상 색인, 비대상 메시지 스킵, 중복 version 스킵, embedding 실패 마킹, 메시지 미존재 예외 검증
Ask Chat RAG migration의 vector extension 사용으로 CI 테스트 Flyway migration이 실패하던 문제를 해결하기 위해 Testcontainers PostgreSQL 이미지를 pgvector/pgvector:pg16으로 변경
Collaborator
|
고생하셨어요! |
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)
주요 변경사항
ask_chat_sessions,ask_chat_messages테이블 및 JPA 엔티티 추가GET /ask-chat/historiesGET /ask-chat/histories/{sessionId}ask_chat_rag_documents테이블 추가pgvectorextension 활성화VECTOR(1536)embedding 컬럼검증
git diff --check./gradlew.bat --no-daemon compileJava./gradlew.bat --no-daemon test --tests "com.devkor.ifive.nadab.domain.askchat.application.AskChatHistoryQueryServiceTest"./gradlew.bat --no-daemon test --tests "com.devkor.ifive.nadab.domain.askchat.infra.AskChatEmbeddingClientTest"./gradlew.bat --no-daemon test --tests "com.devkor.ifive.nadab.domain.askchat.application.AskChatRagIndexingServiceTest"참고 / 리스크
pgvectorextension을 사용하므로 배포 DB에 extension 생성 권한/지원 여부 확인이 필요합니다.🔗 Related Issue
💬 공유사항
✅ PR Checklist
PR이 다음 요구 사항을 충족하는지 확인하세요.