Skip to content

[FEAT]: RAG 기반 채팅 서비스 및 Spring AI 연동 설정#16

Open
dydwls2227 wants to merge 4 commits into
developfrom
feat/chat
Open

[FEAT]: RAG 기반 채팅 서비스 및 Spring AI 연동 설정#16
dydwls2227 wants to merge 4 commits into
developfrom
feat/chat

Conversation

@dydwls2227

@dydwls2227 dydwls2227 commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

#️⃣연관된 이슈

ex) #10

📝작업 내용

Spring AI 의존성 추가

Spring AI BOM 1.1.0
비용 절감을 위해 Vertex AI (유료, GCP 서비스 계정) → Google AI Studio (무료, API 키) 방식으로 전환

  • ChatMessage 엔티티, ChatMessageRepository 구현
  • ChatService/ChatServiceImpl (RAG: 벡터 검색 → 컨텍스트 → Gemini 호출)
  • MockChatService (로컬 테스트용 더미 응답)
  • ChatController (Swagger 문서화 포함)
  • application.yml: Vertex AI Gemini/Embedding 설정
  • application-local.yml: Chroma 자동설정 exclude, 더미 AI 설정
  • ChatServiceImpl/ChatController에 @Profile(!local) 적용

스크린샷 (선택)

💬리뷰 요구사항(선택)

Chroma DB 연동 및 실제 RAG 테스트는 Data Pipeline 담당자 구현 후 진행해야 합니다.
현재 로컬에서는 MockChatService가 더미 응답 제공하고 있습니다.

- Spring AI 1.0.0 (Vertex AI Gemini + Embedding + Chroma) 의존성 추가
- ChatMessage 엔티티, ChatMessageRepository 구현
- ChatService/ChatServiceImpl (RAG: 벡터 검색 → 컨텍스트 → Gemini 호출)
- MockChatService (로컬 테스트용 더미 응답)
- ChatController (Swagger 문서화 포함)
- application.yml: Vertex AI Gemini/Embedding 설정
- application-local.yml: Chroma 자동설정 exclude, 더미 AI 설정
- ChatServiceImpl/ChatController에 @Profile(!local) 적용
- Spring AI BOM 1.0.0 → 1.1.0 업그레이드
- spring-ai-starter-model-vertex-ai-gemini/embedding 제거
- spring-ai-starter-model-google-genai 추가 (무료 API 키 방식)
- application.yml: Vertex AI 설정 → Google GenAI API 키 설정
- application-local.yml: 더미 Vertex AI 값 → 더미 GenAI API 키

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ChatMessage를 Role로 구분한 건 대화 문맥을 관리하기에 아주 좋은 것 같습니다. 그런데 현재 ASSISTANT 역할일 떄도 memberId가 필수여서 DB에 무조건 넣어야 하는 구조입니다. 이 부분 개선되면 좋을 것 같습니다!

- CurrentMemberProvider를 추가해 SecurityContext의 email로 현재 로그인 회원을 조회
- 프로필 조회/수정 API에서 임시 memberId 하드코딩 제거
- 회원 ID 조회 API는 본인 프로필만 조회 가능하도록 권한 검증 추가
- 채팅 API에서 현재 로그인 사용자 기준으로 메시지를 저장/조회하도록 변경
- 채팅 세션 메시지 조회 및 세션 삭제 API 추가
- ChatMessageResponse DTO와 memberId/sessionId 기반 repository 메서드 추가
- 정책 검색 결과가 없을 때 Gemini 호출 없이 안내 응답 반환
- 시스템 프롬프트를 resources/prompts/system-prompt.st 파일로 분리
- Swagger, H2 Console, 토큰 재발급 경로를 SecurityConfig 허용 목록에 추가
- 중복 SecurityConfig 제거
- 용진 담당 구현 가이드 문서 추가
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.

2 participants