added ai-moderation image and text
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.krylov.refound.ai.client;
|
||||
|
||||
import com.krylov.refound.ai.dto.ImageModerationResponse;
|
||||
import com.krylov.refound.ai.exception.AiServerException;
|
||||
import com.krylov.refound.ai.exception.AiUnavailableException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ImageModerationClient {
|
||||
private final AiMultipartHttpClient client;
|
||||
|
||||
@Retryable(
|
||||
retryFor = {
|
||||
AiUnavailableException.class,
|
||||
AiServerException.class
|
||||
},
|
||||
maxAttempts = 3,
|
||||
backoff = @Backoff(
|
||||
delay = 500,
|
||||
multiplier = 2
|
||||
)
|
||||
)
|
||||
public ImageModerationResponse moderate(
|
||||
MultipartFile file
|
||||
) {
|
||||
|
||||
return client.post(
|
||||
"/api/v1/moderation/image",
|
||||
file,
|
||||
ImageModerationResponse.class
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user