Skip to content

Conversation

@ggamnunq
Copy link
Contributor

@ggamnunq ggamnunq commented Aug 21, 2025

챗봇 기능 구현

  • 채팅 요청 스펙 변경 -> 요청 시 body에 type 넣지 않도록 변경
  • '/'로 시작 시 챗봇 기능 작동
  • openAi service 코드 작성( openai api 호출 )
  • redis에 프롬프트 메시지 캐싱

채팅 조회

  • 일반 채팅만 조회하도록 수정

Summary by CodeRabbit

  • New Features
    • 채팅에 “/”로 시작하는 메시지로 챗봇 호출 지원. 챗봇 답변은 WebSocket이 아닌 API 응답으로 즉시 제공.
  • Changes
    • 메시지 전송 API가 처리 결과를 반환하도록 개선(챗봇 답변 포함).
    • 채팅 기록은 일반 채팅만 표시(봇 메시지 제외).
    • 메시지 입력은 내용만 필요하며 공백 불가로 검증 강화.
  • Chores
    • 서버 기본 시간대를 Asia/Seoul로 설정(표시 시간 일관성 향상).
    • WebSocket 허용 오리진에 ws://localhost 및 ws://127.0.0.1 추가.

  - 채팅 요청 스펙 변경 -> 요청 시 body에 type 넣지 않도록 변경
  - '/'로 시작 시 챗봇 기능 작동
  - openAi service 코드 작성( openai api 호출 )
  - redis에 프롬프트 메시지 캐싱
@ggamnunq ggamnunq self-assigned this Aug 21, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 21, 2025

Walkthrough

애플리케이션 시작 시 기본 타임존을 Asia/Seoul로 설정. 채팅 REST API가 응답 DTO를 반환하도록 변경되고, 메시지 앞의 “/”로 BOT 여부를 판별. OpenAI 연동을 WebClient 기반 OpenAiService로 도입하며 기존 ChatGPTService와 ChatRequest 삭제. 채팅 히스토리를 CHAT 타입으로 필터링. WebSocket 허용 오리진 확장 및 로깅 정비.

Changes

Cohort / File(s) Change Summary
앱 초기화/타임존
src/main/kotlin/busanVibe/busan/BusanApplication.kt
CommandLineRunner 빈 추가로 JVM 기본 타임존 Asia/Seoul 설정.
채팅 REST 컨트롤러 응답 변경
.../domain/chat/controller/ChatRestController.kt
POST /api/chat/send가 ApiResponse 반환. “/”로 시작 시 챗봇 응답은 API로 반환, 일반 채팅은 WebSocket 사용.
OpenAI DTO 도입/정리
.../domain/chat/dto/openai/OpenAiDTO.kt, .../domain/chat/dto/openai/ChatRequest.kt
ChatRequest 삭제. WebSearchRequest, Message, Tool, ApproximateLocation, WebSearchResponse, Choice 데이터 클래스 추가(SnakeCase).
송신 DTO 단순화
.../domain/chat/dto/websocket/ChatMessageSendDTO.kt
message를 비널 문자열로 변경, type/time 필드 제거.
Mongo 레포 필터 추가
.../domain/chat/repository/ChatMongoRepository.kt
MessageType 기준 조회 메소드 2종 추가(정렬/페이지네이션 포함).
OpenAI 연동 서비스 신설/교체
.../domain/chat/service/OpenAiService.kt, .../domain/chat/service/ChatGPTService.kt, .../global/config/WebClientConfig.kt
WebClient 기반 OpenAiService 추가(시스템 프롬프트 Redis 캐시 포함). 기존 ChatGPTService 삭제. WebClientConfig에 OpenAI WebClient 빈 및 API Key 주입 추가.
채팅 서비스 로직 변경
.../domain/chat/service/ChatMongoService.kt
saveAndPublish가 ChatMessageReceiveDTO 반환. “/” ⇒ BOT, 그 외 ⇒ CHAT 판별. CHAT은 Redis publish, BOT은 OpenAI 호출 결과를 API로만 반환(미발행). 히스토리는 CHAT 타입만 조회.
Redis 구독자 역직렬화 정비
.../domain/chat/service/RedisSubscriber.kt
DTO로 직접 역직렬화, 전송-로그 순서 조정.
WebSocket 구성/로깅/인터셉터
.../global/config/webSocket/WebSocketConfig.kt, .../global/config/webSocket/AuthChannelInterceptorAdapter.kt, .../global/config/webSocket/JwtHandshakeInterceptor.kt
허용 오리진에 ws 프로토콜 추가. AuthChannelInterceptorAdapter에 SLF4J 로깅 도입. JwtHandshakeInterceptor 파일 삭제(핸드셰이크 JWT 인증 제거).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as REST Client
  participant Controller as ChatRestController
  participant Service as ChatMongoService
  participant Repo as ChatMongoRepository
  participant Redis as Redis(Pub/Sub)
  participant OpenAI as OpenAiService

  Client->>Controller: POST /api/chat/send (ChatMessageSendDTO)
  Controller->>Service: saveAndPublish(dto)
  Service->>Service: 메시지 타입 판별 ("/" ⇒ BOT, else ⇒ CHAT)
  Service->>Repo: save(ChatMessage)
  Repo-->>Service: 저장됨

  alt CHAT 메시지
    Service->>Redis: publish(ChatMessageReceiveDTO)
    Service-->>Controller: ChatMessageReceiveDTO(사용자 메시지)
  else BOT 메시지
    Service->>OpenAI: chatToOpenAI(query)
    OpenAI-->>Service: 답변 문자열
    Service-->>Controller: ChatMessageReceiveDTO(챗봇 응답, name="챗봇", userId=-1)
  end

  Controller-->>Client: ApiResponse<ChatMessageReceiveDTO>
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

(•̀ᴗ•́)و✧
슬래시 한 줄에 토끼가 쿵,
챗봇은 API로 말하고 중—
웹소켓엔 수다꽃 퐁퐁 피고,
부산의 바람은 서울 시간에 쉬고.
캐시된 프롬프트 깡총깡총,
답장도 빠르게 통!

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

💡 Knowledge Base configuration:

  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0a0e78c and ca692c0.

📒 Files selected for processing (14)
  • src/main/kotlin/busanVibe/busan/BusanApplication.kt (1 hunks)
  • src/main/kotlin/busanVibe/busan/domain/chat/controller/ChatRestController.kt (2 hunks)
  • src/main/kotlin/busanVibe/busan/domain/chat/dto/openai/ChatRequest.kt (0 hunks)
  • src/main/kotlin/busanVibe/busan/domain/chat/dto/openai/OpenAiDTO.kt (1 hunks)
  • src/main/kotlin/busanVibe/busan/domain/chat/dto/websocket/ChatMessageSendDTO.kt (1 hunks)
  • src/main/kotlin/busanVibe/busan/domain/chat/repository/ChatMongoRepository.kt (1 hunks)
  • src/main/kotlin/busanVibe/busan/domain/chat/service/ChatGPTService.kt (0 hunks)
  • src/main/kotlin/busanVibe/busan/domain/chat/service/ChatMongoService.kt (2 hunks)
  • src/main/kotlin/busanVibe/busan/domain/chat/service/OpenAiService.kt (1 hunks)
  • src/main/kotlin/busanVibe/busan/domain/chat/service/RedisSubscriber.kt (1 hunks)
  • src/main/kotlin/busanVibe/busan/global/config/WebClientConfig.kt (2 hunks)
  • src/main/kotlin/busanVibe/busan/global/config/webSocket/AuthChannelInterceptorAdapter.kt (3 hunks)
  • src/main/kotlin/busanVibe/busan/global/config/webSocket/JwtHandshakeInterceptor.kt (0 hunks)
  • src/main/kotlin/busanVibe/busan/global/config/webSocket/WebSocketConfig.kt (1 hunks)
💤 Files with no reviewable changes (3)
  • src/main/kotlin/busanVibe/busan/domain/chat/service/ChatGPTService.kt
  • src/main/kotlin/busanVibe/busan/domain/chat/dto/openai/ChatRequest.kt
  • src/main/kotlin/busanVibe/busan/global/config/webSocket/JwtHandshakeInterceptor.kt

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Join our Discord community for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ggamnunq ggamnunq merged commit dfc7500 into main Aug 21, 2025
2 checks passed
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