-
Notifications
You must be signed in to change notification settings - Fork 0
[GOMO-39] LLM 퀘스트 생성 마이그레이션 #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
….com/growth-more/gomo-server into feature-39/quest-generator-migration
….com/growth-more/gomo-server into feature-39/quest-generator-migration
jhl221123
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
| @RequiredArgsConstructor | ||
| class GeminiGenerateTextUseCase implements GenerateTextPortIn { | ||
|
|
||
| private final GeminiApiAdapter geminiApiAdapter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헥사고날 도입을 결정한 만큼, application service가 adapter를 직접 의존하는 것은 피하면 좋을 것 같습니다!
- application 패키지 내, outbound-port 를 정의
GeminiGenerateTextUseCase는 outbound-port 의존infrastructure/adapter/GeminiApiAdapter가 outbound-port 구현
src/main/java/com/gomo/app/support/llm/exception/GenerateQuestErrorCode.java
Outdated
Show resolved
Hide resolved
src/main/java/com/gomo/app/support/llm/exception/GenerateQuestException.java
Outdated
Show resolved
Hide resolved
|
|
||
| return objectMapper.readValue(cleanText, typeRef); | ||
| } catch (JsonProcessingException e){ | ||
| throw new GenerateQuestException(GenerateQuestErrorCode.INVALID_JSON_FORMAT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quest content 뿐만 아닌 모든 llm 생성 데이터에 공통으로 해당되는 "예외"라면, 예외 이름을 변경하는 것이 좋을 것 같습니다. 만약 Quest content에만 해당되는 "규칙" 이라면, quest 모듈에서 검증해야하는 책임이라 생각합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 코드에서 사용된 Exception은 Gemini 응답과정에서 발생하는 JSON Parsing문제 등 이므로 변경된 LlmException와 LlmErrorCode로 변경하였습니다.
src/main/java/com/gomo/app/support/llm/infrastructure/GeminiApiAdapter.java
Show resolved
Hide resolved
src/main/java/com/gomo/app/support/llm/infrastructure/GeminiApiAdapter.java
Show resolved
Hide resolved
src/main/java/com/gomo/app/support/llm/infrastructure/GeminiRequest.java
Outdated
Show resolved
Hide resolved
src/main/java/com/gomo/app/support/llm/infrastructure/GeminiResponse.java
Outdated
Show resolved
Hide resolved
| } | ||
| } | ||
|
|
||
| private GeminiRequest createGeminiRequest(GenerateTextCommand command) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 클래스는 llm 호출과 응답 반환에 대한 책임만 가지는 것이 이상적이라 생각합니다.
무엇을 받고, 무엇을 생성하는지 구체적으로 알게 되면 확장성과 유지 보수성이 떨어질 것이라 생각합니다.
application 계층에서 요청에 적합한 프롬프트를 가공하고, llm 이 생성한 응답을 필요에 따라 파싱하면 조금 더 응집도가 높은 코드가 될 것 같습니다. 현재 driving, driven port 모두 GenerateTextCommand를 사용하고 있는데, 이것도 분리가 필요하겠군요!
| import com.gomo.app.support.llm.util.PromptLoader; | ||
| import com.gomo.app.core.quest.domain.model.quest.QuestType; | ||
|
|
||
| public record GeminiRequest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gemini 요청할 때만 필요한 레코드라면, GeminiClient 내부에서 중첩으로 관리하는 것도 고려해보면 좋을 것 같습니다!
| * @param object: API response object specification string( normally: "chat.completion") | ||
| * @param usage: Total Usage. | ||
| */ | ||
| public record GeminiResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요청 레코드와 마찬가지 입니다!
* fix: api 문서 수정 * fix: final 키워드 추가 * refactor: 테스트 이름 수정 * fix: http method 수정
fix: 회원 조회 시, 위젯도 함께 조회하도록 수정
* refactor: 전체 모듈 헥사고날 아키텍처로 전환 * refactor: 관심사 도메인 서비스 리팩터링 * refacter: 인증 코드, 인증 토큰 검증 기능 인증 모듈로 이동 * fix: 인증 코드 검증 api http method GET -> POST 수정 * refactor: 인증 모듈을 core 하위로 이동 * fix: OAuth 가입 시, 인증 토큰을 검증하지 않도록 수정
- AuthInfo를 SessionInfo로 변경 - 인증 정보를 주입하는 resolver를 공통 세션 모듈로 이전
* refactor: 비밀번호 초기화 기능 수정 - 임시 토큰 검증에 대한 책임은 인증 모듈로 이동 - 인증 모듈과 회원 모듈 간 순환 의존 제거 * feat: 스프링 모듈리스 도입 - 모듈간 순환 의존성 검증 자동화 - 모듈간 의존 방향 문서화 * docs: 문서 제목 수정 * fix: support-logging 모듈 패키지 공개 타입 수정
작업 사항
JIRA TICKET: #GOMO-39
내용