fi.evolver.ai.spring.provider.openai.OpenAiImageResponse Maven / Gradle / Ivy
package fi.evolver.ai.spring.provider.openai;
import java.util.Base64;
import java.util.List;
import java.util.stream.Collectors;
import fi.evolver.ai.spring.file.AiFile;
import fi.evolver.ai.spring.image.ImagePrompt;
import fi.evolver.ai.spring.image.ImageResponse;
import fi.evolver.ai.spring.provider.openai.response.ORateLimitHeaders;
import fi.evolver.ai.spring.provider.openai.response.images.OImageResult;
public class OpenAiImageResponse extends ImageResponse {
private final List images;
private final String created;
private final ORateLimitHeaders rateLimitHeaders;
public OpenAiImageResponse(ImagePrompt prompt, OImageResult result, ORateLimitHeaders rateLimitHeaders) {
super(prompt);
this.images = result.data().stream()
.map(OImage -> new AiFile(Base64.getDecoder().decode(OImage.b64_json()), "image/png", "image"))
.collect(Collectors.toList());
this.created = result.created();
this.rateLimitHeaders = rateLimitHeaders;
}
@Override
public AiFile getImage() {
return images.get(0);
}
@Override
public List getImages() {
return images;
}
@Override
public String getCreated() {
return created;
}
@Override
public ORateLimitHeaders getRateLimitHeaders() {
return rateLimitHeaders;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy