-
Notifications
You must be signed in to change notification settings - Fork 2
[feature] ai api 호출 부분 구현 #419
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: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @sese2204, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 응원톡(CheerTalk) 기능에 AI 기반 콘텐츠 필터링 시스템을 도입합니다. Huggingface와 Clarifai AI 모델을 활용하여 부적절한 콘텐츠를 감지하고, 필터링 이력을 저장하는 기능을 구현합니다. 이를 통해 응원톡의 건전한 환경을 조성하고, 향후 확장 가능한 AI 필터링 인프라를 마련합니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
이번 PR은 외부 AI API를 연동하여 응원톡의 비속어를 필터링하는 기능을 구현하셨네요. CheerTalkBotClient 인터페이스를 통해 여러 클라이언트를 지원할 수 있는 기반을 마련한 점이 좋습니다. 전반적으로 좋은 방향으로 개발되고 있지만, 코드의 유지보수성, 안정성, 그리고 성능을 더욱 향상시키기 위한 몇 가지 제안 사항을 드립니다. 주요 내용은 다음과 같습니다: 필터링 로직을 별도 서비스로 분리, 필터링 히스토리 데이터 보강, 하드코딩된 API 엔드포인트 외부 설정화, 그리고 비동기 API 호출 방식에 대한 고려입니다.
src/main/java/com/sports/server/command/cheertalk/application/CheerTalkService.java
Outdated
Show resolved
Hide resolved
| ); | ||
|
|
||
| return clarifaiWebClient.post() | ||
| .uri("/users/beomi/apps/text-moderation/models/moderation-abuse-korean/versions/f6fb536be02f4c34a92be44c1093ce55/outputs") |
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.
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.
yml 에 넣는 게 좋을 것 같아요~
예를 들어 갑자기 외부에서 엔드포인트를 변경해버리면 저희도 빠르게 대응해서 재배포 해야 할 수 있도록 yml 과 같은 설정 파일에 넣는 게 좋을 것 같습니당
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.
요거는 yml에 안 넣고 이렇게 직접 넣나용?
| @Override | ||
| public JsonNode detectAbusiveContent(String content) { | ||
| return huggingfaceWebClient.post() | ||
| .uri("/smilegate-ai/kor_unsmile") |
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.
src/main/java/com/sports/server/command/cheertalk/application/CheerTalkService.java
Outdated
Show resolved
Hide resolved
src/main/java/com/sports/server/command/cheertalk/application/CheerTalkService.java
Outdated
Show resolved
Hide resolved
| Map<String, Object> requestBody = Map.of( | ||
| "inputs", List.of( | ||
| Map.of( | ||
| "data", Map.of( | ||
| "text", Map.of( | ||
| "raw", content | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
| ); |
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.
src/main/java/com/sports/server/command/cheertalk/infra/BeomiClient.java
Show resolved
Hide resolved
src/main/java/com/sports/server/command/cheertalk/infra/KorUnsmileClient.java
Show resolved
Hide resolved
Jin409
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.
지금 secret key 가 local yml 에만 있는 것 같은데, 다른 yml 에도 추가가 필요할 것 같아요. 추가적으로, uri 들을 yml 에 넣는 게 좋을 것 같습니다~!
제외하고는 의존성 방향 흐름이나 인터페이스 구조도 좋은 것 같아요
src/main/java/com/sports/server/command/cheertalk/application/CheerTalkService.java
Outdated
Show resolved
Hide resolved
src/main/java/com/sports/server/command/cheertalk/application/CheerTalkService.java
Outdated
Show resolved
Hide resolved
| ); | ||
|
|
||
| return clarifaiWebClient.post() | ||
| .uri("/users/beomi/apps/text-moderation/models/moderation-abuse-korean/versions/f6fb536be02f4c34a92be44c1093ce55/outputs") |
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.
yml 에 넣는 게 좋을 것 같아요~
예를 들어 갑자기 외부에서 엔드포인트를 변경해버리면 저희도 빠르게 대응해서 재배포 해야 할 수 있도록 yml 과 같은 설정 파일에 넣는 게 좋을 것 같습니당
| @Bean | ||
| public WebClient clarifaiWebClient() { | ||
| return WebClient.builder() | ||
| .baseUrl("https://api.clarifai.com/v2") |
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.
요것도~!
src/main/java/com/sports/server/command/cheertalk/infra/KorUnsmileClient.java
Show resolved
Hide resolved
hyobin-yang
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.
구조 좋으네요~~ 수고하셨습니당~!👍
src/main/java/com/sports/server/command/cheertalk/application/CheerTalkService.java
Outdated
Show resolved
Hide resolved
src/main/java/com/sports/server/command/cheertalk/application/CheerTalkService.java
Outdated
Show resolved
Hide resolved
| BotType supports(); | ||
|
|
||
| JsonNode detectAbusiveContent(String content); | ||
| } No newline at end of file |
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.
👍👍👍
src/main/java/com/sports/server/command/cheertalk/infra/ClarifaiClient.java
Outdated
Show resolved
Hide resolved
| .retrieve() | ||
| .bodyToMono(JsonNode.class) | ||
| .block(); | ||
| } |
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.
여기서 예외처리 안 해도 되나요? 밖에서 잡나?
- 서비스 책임 분리 , cheertalk id 넘기도록 메소드 수정 - 봇에 의해 차단됨 상태 추가를 위해 cheertalk의 상태를 enum으로 변경 - ai 모델의 이름으로 클래스 네이밍 통일
hyobin-yang
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.
역시 필드 하나 추가하니 파생되는 로직이 많으네요 테스트까지 고생하셨습니당👍
| JsonNode rawResponse = korUnsmileClient.detectAbusiveContent(content); | ||
| int latencyMs = (int) (System.currentTimeMillis() - startTime); | ||
|
|
||
| BotType botType = korUnsmileClient.supports(); |
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.
흠 뭔가 다시 보니까 supports라는 메서드명이 좀 모호한 것 같기도 하네요
| ); | ||
|
|
||
| return clarifaiWebClient.post() | ||
| .uri("/users/beomi/apps/text-moderation/models/moderation-abuse-korean/versions/f6fb536be02f4c34a92be44c1093ce55/outputs") |
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.
요거는 yml에 안 넣고 이렇게 직접 넣나용?
| CheerTalk cheerTalk = entityUtils.getEntity(cheerTalkId, CheerTalk.class); | ||
|
|
||
| JsonNode rawResponse = korUnsmileClient.detectAbusiveContent(content); | ||
| int latencyMs = (int) (System.currentTimeMillis() - startTime); |
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.
int로 변환하는 이유는 어차피 int 최댓값을 넘어갈 일은 없기 때문인가요?
| package com.sports.server.command.cheertalk.domain; | ||
|
|
||
| public enum CheerTalkBlockStatus { | ||
| ACTIVE, |
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.
ACTIVE가 뭔가 활성상태.. 같은 느낌이라 개인적으로는 처음에 좀 헷갈렸어서 클래스명이 CheerTalkBlockStatus으로 블록 상태를 나타내는 거니까 NONE(차단 상태 X)는 어떠려나요? 이것도 약간 애매한 것 같기도 하고..??
흠 지금도 괜찮으려나
🌍 이슈 번호
#418
📝 구현 내용
🍀 확인해야 할 부분