Skip to content

Commit edcc4bf

Browse files
authored
refact: LuLu 관련 AI 서버 메시지 로깅, URL 매핑 (#114)
* refact: 바뀐 AI서버 API 주소에 따른 수정 * refact: 바뀐 AI 서버 주소 에 따른 수정 * refact: 이미지 업로드 코드 삭제 * refact: 불필요 S3 관련 코드 삭제 * refact: AI WebClient 코드 리팩토링, 로그 추가 * refact: LuLu 관련 AI 서버 메시지 로깅, URL 매핑
1 parent 5db8acd commit edcc4bf

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

gotcha/src/main/java/Gotcha/domain/lulu/service/LuLuAIClientService.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ public TaskStartRes generateTask(String gameId){
6060
.retrieve()
6161
.onStatus(httpStatusCode -> httpStatusCode.is4xxClientError() || httpStatusCode.is5xxServerError(
6262
)
63-
, clientResponse -> clientResponse.bodyToMono(String.class).flatMap(error -> Mono.error(
64-
new CustomException(LuLuExceptionCode.AI_SERVER_ERROR))))
63+
, clientResponse -> clientResponse.bodyToMono(String.class).flatMap(error -> {
64+
log.error("AI Server Error on Get: \"{}\", StatusCode: {}, Content: {}", "/lulu/task/" + gameId, clientResponse.statusCode(), error);
65+
return Mono.error(
66+
new CustomException(LuLuExceptionCode.AI_SERVER_ERROR));
67+
}))
6568
.bodyToMono(TaskStartRes.class)
6669
.block();
6770
if (res == null || res.keyword() == null || res.situation() == null){
@@ -93,8 +96,11 @@ private TaskEvalRes requestEvaluate(String gameId, String imageCaption){
9396
.retrieve()
9497
.onStatus(httpStatusCode -> httpStatusCode.is4xxClientError() || httpStatusCode.is5xxServerError(
9598
)
96-
, clientResponse -> clientResponse.bodyToMono(String.class).flatMap(error -> Mono.error(
97-
new CustomException(LuLuExceptionCode.AI_SERVER_ERROR))))
99+
, clientResponse -> clientResponse.bodyToMono(String.class).flatMap(error -> {
100+
log.error("AI Server Error on Post : \"{}\", StatusCode: {}, Content: {}", "/lulu/task/" + gameId, clientResponse.statusCode(), error);
101+
return Mono.error(
102+
new CustomException(LuLuExceptionCode.AI_SERVER_ERROR));
103+
}))
98104
.bodyToMono(TaskEvalRes.class)
99105
.block();
100106
if (res == null || res.score() == null || res.feedback() == null || res.gameId() == null)
@@ -114,15 +120,18 @@ private TaskEvalRes requestEvaluate(String gameId, String imageCaption){
114120
* 이미지 캡셔닝
115121
*/
116122
public String getImageCaption(String imageUrl){
117-
Map<String, String> body = Map.of("imageURL", imageUrl);
123+
Map<String, String> body = Map.of("image_url", imageUrl);
118124
return webClient.post()
119125
.uri(AI_SERVER_BASE_URL + "caption")
120126
.bodyValue(body)
121127
.retrieve()
122128
.onStatus(httpStatusCode -> httpStatusCode.is4xxClientError() || httpStatusCode.is5xxServerError(
123129
)
124-
, clientResponse -> clientResponse.bodyToMono(String.class).flatMap(error -> Mono.error(
125-
new CustomException(LuLuExceptionCode.AI_SERVER_ERROR))))
130+
, clientResponse -> clientResponse.bodyToMono(String.class).flatMap(error -> {
131+
log.error("AI Server Error on Post : \"{}\", StatusCode: {}, Content: {}", "/caption", clientResponse.statusCode(), error);
132+
return Mono.error(
133+
new CustomException(LuLuExceptionCode.AI_SERVER_ERROR));
134+
}))
126135
.bodyToMono(String.class)
127136
.block();
128137
}

0 commit comments

Comments
 (0)