[Refactor] OpenAI 클라이언트 공통 호출 레이어 추출#154
Merged
marshmallowing merged 2 commits intodevelopfrom Feb 19, 2026
Merged
Conversation
Contributor
|
Caution Review failedThe pull request is closed. WalkthroughOpenAI 통합을 새로운 OpenAiClient 중심의 아키텍처로 리팩토링했습니다. OpenAiRequest 레코드, OpenAiException, OpenAiClient 클래스를 신규 추가했으며, 세 개의 AI 서비스(AiMaterialService, AiReviewGeneratorService, AiSearchService)에서 이 새로운 클라이언트를 사용하도록 변경했습니다. SizeReviewPrompter의 프롬프트는 구조화된 단일 문장 생성 형식으로 전면 재작성되었습니다. Changes
Sequence DiagramsequenceDiagram
participant Service as AI Service
participant OpenAiClient
participant OpenAiService
participant OpenAI API
Service->>OpenAiClient: call(OpenAiRequest)
activate OpenAiClient
OpenAiClient->>OpenAiClient: construct ChatCompletionRequest
OpenAiClient->>OpenAiService: call OpenAI API
activate OpenAiService
OpenAiService->>OpenAI API: POST /chat/completions
activate OpenAI API
OpenAI API-->>OpenAiService: response
deactivate OpenAI API
OpenAiService-->>OpenAiClient: ChatCompletionResponse
deactivate OpenAiService
alt Success
OpenAiClient->>OpenAiClient: log execution time
OpenAiClient-->>Service: extracted content
else Exception
OpenAiClient->>OpenAiClient: log error with duration
OpenAiClient-->>Service: throw OpenAiException
end
deactivate OpenAiClient
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes 새로운 인프라 계층(OpenAiClient, OpenAiException, OpenAiRequest) 추가와 함께 세 개의 독립적인 서비스에서 서로 다른 패턴의 리팩토링이 발생합니다. 각 서비스별 예외 처리 방식, 프롬프트 구성 로직, 응답 파싱이 다르므로 개별 검토가 필요하며, SizeReviewPrompter의 프롬프트 변경사항도 의도와 정확성을 확인해야 합니다. Possibly related PRs
✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
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.
🔍️ 작업 내용
✨ 상세 설명
OpenAI를 호출하는 방식이 서비스마다 달라 유지보수가 어려운 문제를 개선했습니다.
기존 문제
같은 OpenAI API를 호출하는데 클라이언트가 사실상 3개였고,
에러 처리와 로깅도 각 서비스마다 중복 구현되어 있었습니다.
해결
global/openai패키지에 공통 레이어를 추가하고 3개 서비스를 일원화했습니다.OpenAiClient: API 호출 / 에러 처리 / 소요시간 로깅을 한 곳에서 관리OpenAiRequest: model, systemPrompt, userMessage, temperature를 묶는 값 객체 (record)OpenAiException: AI 호출 실패 전용 예외, 서비스별 fallback 처리 가능🛠️ 추후 리팩토링 및 고도화 계획
📸 스크린샷 (선택)
💬 리뷰 요구사항
Summary by CodeRabbit
릴리스 노트
버그 수정
개선 사항