Skip to content

Commit 1da6c92

Browse files
chore(internal): fix custom code
1 parent 6cdb671 commit 1da6c92

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

openai-java-example/src/main/java/com/openai/example/AssistantAsyncExample.java

+9-13
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,14 @@ private static CompletableFuture<Void> listThreadMessages(OpenAIClientAsync clie
109109
.order(MessageListParams.Order.ASC)
110110
.build());
111111
return pageFuture.thenComposeAsync(page -> page.autoPager()
112-
.forEach(
113-
currentMessage -> {
114-
System.out.println(currentMessage.role().toString().toUpperCase());
115-
currentMessage.content().stream()
116-
.flatMap(content -> content.text().stream())
117-
.forEach(textBlock ->
118-
System.out.println(textBlock.text().value()));
119-
System.out.println();
120-
121-
// Keep iterating
122-
return true;
123-
},
124-
pageFuture.defaultExecutor()));
112+
.subscribe(currentMessage -> {
113+
System.out.println(currentMessage.role().toString().toUpperCase());
114+
currentMessage.content().stream()
115+
.flatMap(content -> content.text().stream())
116+
.forEach(textBlock ->
117+
System.out.println(textBlock.text().value()));
118+
System.out.println();
119+
})
120+
.onCompleteFuture());
125121
}
126122
}

openai-java-example/src/main/java/com/openai/example/ModelListAsyncExample.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,8 @@ public static void main(String[] args) {
1717
CompletableFuture<ModelListPageAsync> pageFuture = client.models().list();
1818
pageFuture
1919
.thenComposeAsync(page -> page.autoPager()
20-
.forEach(
21-
model -> {
22-
System.out.println(model.id());
23-
// Keep iterating
24-
return true;
25-
},
26-
pageFuture.defaultExecutor()))
20+
.subscribe(model -> System.out.println(model.id()))
21+
.onCompleteFuture())
2722
.join();
2823
}
2924
}

0 commit comments

Comments
 (0)