Skip to content

Commit e2d77f5

Browse files
committed
⚡ Various code comfort improvements
1 parent a271a11 commit e2d77f5

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

spring-boot-starter-replicate/src/main/java/io/graversen/replicate/common/TextToImageAspectRatio.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ public static TextToImageAspectRatio portrait() {
1616
return new TextToImageAspectRatio(1350, AspectRatios.RATIO_4_BY_5);
1717
}
1818

19+
public static TextToImageAspectRatio landscape() {
20+
return new TextToImageAspectRatio(1350, AspectRatios.RATIO_5_BY_4);
21+
}
22+
23+
public static TextToImageAspectRatio wide() {
24+
return new TextToImageAspectRatio(1350, AspectRatios.RATIO_16_BY_9);
25+
}
26+
27+
public static TextToImageAspectRatio ultraWide() {
28+
return new TextToImageAspectRatio(1350, AspectRatios.RATIO_21_BY_9);
29+
}
30+
1931
public static TextToImageAspectRatio reel() {
2032
return new TextToImageAspectRatio(1920, AspectRatios.RATIO_9_BY_16);
2133
}

spring-boot-starter-replicate/src/main/java/io/graversen/replicate/common/TextToImagePrompt.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,22 @@ public class TextToImagePrompt {
1010
@Nullable String negativePrompt;
1111
@NonNull TextToImageAspectRatio aspectRatio;
1212
@Nullable Double promptStrength;
13+
14+
public static TextToImagePrompt portrait(@NonNull String prompt) {
15+
return new TextToImagePrompt(
16+
prompt,
17+
null,
18+
TextToImageAspectRatio.portrait(),
19+
null
20+
);
21+
}
22+
23+
public static TextToImagePrompt landscape(@NonNull String prompt) {
24+
return new TextToImagePrompt(
25+
prompt,
26+
null,
27+
TextToImageAspectRatio.landscape(),
28+
null
29+
);
30+
}
1331
}

spring-boot-starter-replicate/src/main/java/io/graversen/replicate/facade/ConversationFacade.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public Conversation create(@NonNull CreateConversation createConversation, @NonN
3030
return conversation;
3131
}
3232

33+
public Function<Conversation, CompletableFuture<Conversation>> chat(@NonNull TextMessage message) {
34+
return conversation -> chat(conversation.getId(), message);
35+
}
36+
3337
public CompletableFuture<Conversation> chat(@NonNull String id, @NonNull TextMessage message) {
3438
var conversation = conversationService.appendMessage(id, message);
3539

0 commit comments

Comments
 (0)