Skip to content

Comments

refactor: OpenAiSttService 패키지 이동#224

Open
sudo-Terry wants to merge 1 commit intomainfrom
refactor/open-ai-stt-package
Open

refactor: OpenAiSttService 패키지 이동#224
sudo-Terry wants to merge 1 commit intomainfrom
refactor/open-ai-stt-package

Conversation

@sudo-Terry
Copy link
Member

@sudo-Terry sudo-Terry commented Feb 19, 2026

Desc

  • OpenAI Whisper API 호출은 케어콜이 아닌 다른 기능에서도 쓸 수 있고, 케어콜 도메인이 아니라 외부 API 래퍼이다
  • ai 패키지에 같은 계층의 AiSummaryService, OpenAiChatService가 이미 존재하니 OpenAiSttService도 패키지를 이동하자

Summary by CodeRabbit

  • 리팩토링
    • 내부 코드 구조를 개선하기 위한 조직화 작업이 완료되었습니다. 이 변경사항은 시스템의 안정성을 유지하면서 코드베이스의 유지보수성을 향상시킵니다.

사용자에게 미치는 영향: 없음

### Desc
- OpenAI Whisper API 호출은 케어콜이 아닌 다른 기능에서도 쓸 수 있고, 케어콜 도메인이 아니라 외부 API 래퍼이다
- ai 패키지에 같은 계층의 AiSummaryService, OpenAiChatService가 이미 존재하니 OpenAiSttService도 패키지를 이동하자
@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

📋 Walkthrough

OpenAiSttService 클래스가 com.example.medicare_call.service.carecall.inbound 패키지에서 com.example.medicare_call.service.ai 패키지로 이동되었습니다. 관련된 모든 import 문이 새로운 패키지 경로로 업데이트되었으며, 코드 로직은 변경되지 않았습니다.

🔄 Changes

Cohort / File(s) Summary
OpenAiSttService 패키지 이동
src/main/java/com/example/medicare_call/service/ai/OpenAiSttService.java
클래스 패키지를 service.carecall.inbound에서 service.ai로 변경했습니다.
Import 경로 업데이트 - 프로덕션 코드
src/main/java/com/example/medicare_call/service/carecall/inbound/CareCallUploadService.java
OpenAiSttService의 새로운 패키지 경로를 반영하여 import 문을 추가했습니다.
Import 경로 업데이트 - 테스트 코드
src/test/java/com/example/medicare_call/controller/CareCallControllerImmediateTest.java, src/test/java/com/example/medicare_call/controller/CareCallControllerTest.java, src/test/java/com/example/medicare_call/service/carecall/inbound/CareCallUploadServiceTest.java
OpenAiSttService import를 새로운 service.ai 패키지 경로로 변경했습니다.

🎯 Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🏷️ Suggested Labels

refactoring

👥 Suggested Reviewers

  • mjkhub
  • jyun-KIM
  • kisusu115

🎵 Poem

📦 패키지를 정리하고 정돈해서
AI 서비스는 새로운 집으로 이사 가고
Import들도 함께 따라가네요
깔끔한 구조, 마음도 개운해! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경 사항의 주요 목적을 명확하게 나타냅니다. OpenAiSttService의 패키지 이동이 정확히 무엇을 하고 있는지 잘 설명합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/open-ai-stt-package

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the refactoring Refactoring should not change Test codes label Feb 19, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/main/java/com/example/medicare_call/service/ai/OpenAiSttService.java (1)

80-84: 원본 예외를 CustomException cause로 연결하는 게 좋을 것 같아요

현재 catch (Exception e) 블록에서 elog.error에는 전달되지만, 새로 던지는 CustomException의 cause로는 연결되지 않아요. 로그 레벨 이상의 추적이 필요한 경우 스택 트레이스가 끊겨서 디버깅이 살짝 불편할 수 있어요.

♻️ 원본 예외 cause 체이닝 제안
- throw new CustomException(ErrorCode.STT_PROCESSING_FAILED, "STT 처리 실패");
+ throw new CustomException(ErrorCode.STT_PROCESSING_FAILED, "STT 처리 실패", e);

(CustomExceptionThrowable cause 파라미터를 지원하는 경우에 한함)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/com/example/medicare_call/service/ai/OpenAiSttService.java`
around lines 80 - 84, The catch block in OpenAiSttService currently logs the
original exception `e` but throws a new CustomException without chaining the
cause; modify the throw to pass `e` as the cause (e.g., new
CustomException(ErrorCode.STT_PROCESSING_FAILED, "STT 처리 실패", e)) so the
original stacktrace is preserved; if CustomException lacks a cause-taking
constructor, add one or wrap `e` appropriately in CustomException's constructor
and keep the existing log call that computes elapsed time using `startTime`.
src/main/java/com/example/medicare_call/service/carecall/inbound/CareCallUploadService.java (1)

37-43: getSegments() null 가드가 없어요

현재 코드는 sttResponse.getSegments() 반환값이 null이면 .stream() 호출 시 NPE가 발생해요. 이번 PR 변경은 아니지만 살짝 불안한 부분이에요.

🛡️ 방어 코드 제안
- java.util.List<CareCallDataProcessRequest.TranscriptionData.TranscriptionSegment> segments =
-         sttResponse.getSegments().stream()
+ java.util.List<OpenAiSttResponse.Segment> rawSegments =
+         sttResponse.getSegments() != null ? sttResponse.getSegments() : java.util.Collections.emptyList();
+ java.util.List<CareCallDataProcessRequest.TranscriptionData.TranscriptionSegment> segments =
+         rawSegments.stream()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/com/example/medicare_call/service/carecall/inbound/CareCallUploadService.java`
around lines 37 - 43, sttResponse.getSegments() can be null which will cause an
NPE when calling .stream(); in CareCallUploadService where you build
TranscriptionSegment from sttResponse.getSegments(), guard against null by
treating a null segments list as empty (e.g., use
Optional.ofNullable(sttResponse.getSegments()).orElse(Collections.emptyList())
or an explicit null check) before mapping to
CareCallDataProcessRequest.TranscriptionData.TranscriptionSegment.builder();
ensure the rest of the mapping logic (speaker/text) remains unchanged so you
produce an empty list instead of throwing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/main/java/com/example/medicare_call/service/ai/OpenAiSttService.java`:
- Around line 80-84: The catch block in OpenAiSttService currently logs the
original exception `e` but throws a new CustomException without chaining the
cause; modify the throw to pass `e` as the cause (e.g., new
CustomException(ErrorCode.STT_PROCESSING_FAILED, "STT 처리 실패", e)) so the
original stacktrace is preserved; if CustomException lacks a cause-taking
constructor, add one or wrap `e` appropriately in CustomException's constructor
and keep the existing log call that computes elapsed time using `startTime`.

In
`@src/main/java/com/example/medicare_call/service/carecall/inbound/CareCallUploadService.java`:
- Around line 37-43: sttResponse.getSegments() can be null which will cause an
NPE when calling .stream(); in CareCallUploadService where you build
TranscriptionSegment from sttResponse.getSegments(), guard against null by
treating a null segments list as empty (e.g., use
Optional.ofNullable(sttResponse.getSegments()).orElse(Collections.emptyList())
or an explicit null check) before mapping to
CareCallDataProcessRequest.TranscriptionData.TranscriptionSegment.builder();
ensure the rest of the mapping logic (speaker/text) remains unchanged so you
produce an empty list instead of throwing.

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

Labels

refactoring Refactoring should not change Test codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant