fixed controllers
This commit is contained in:
@@ -19,29 +19,18 @@ public class TextModerationClient {
|
||||
private final AiHttpClient client;
|
||||
|
||||
@Retryable(
|
||||
retryFor = {
|
||||
AiUnavailableException.class,
|
||||
AiServerException.class
|
||||
},
|
||||
retryFor = {AiUnavailableException.class, AiServerException.class},
|
||||
maxAttempts = 3,
|
||||
backoff = @Backoff(
|
||||
delay = 500,
|
||||
multiplier = 2
|
||||
)
|
||||
backoff = @Backoff(delay = 500, multiplier = 2)
|
||||
)
|
||||
public ModerationResponse moderate(String text) {
|
||||
log.info("Calling AI service");
|
||||
return client.post(
|
||||
"/api/v1/moderation/text",
|
||||
new TextModerationRequest(text),
|
||||
ModerationResponse.class
|
||||
);
|
||||
|
||||
log.info("Calling AI TextModeration service");
|
||||
return client.post("/api/v1/moderation/text", new TextModerationRequest(text), ModerationResponse.class);
|
||||
}
|
||||
|
||||
@Recover
|
||||
public ModerationResponse recover(AiUnavailableException e, String text) {
|
||||
log.error("AI unavailable after retries", e);
|
||||
log.error("AI TextModeration unavailable after retries", e);
|
||||
|
||||
return ModerationResponse.builder()
|
||||
.approved(false)
|
||||
|
||||
Reference in New Issue
Block a user