Skip to content

Commit

Permalink
Rename StreamChatCompletionSubscriber to ChatCompletionStreamSubscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Apr 3, 2024
1 parent 9f77cdb commit 9272bcb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ CreateChatCompletionRequest request = CreateChatCompletionRequest.newBuilder()
// with java.util.stream.Stream
chatClient.streamChatCompletion(request).forEach(System.out::println);
// with subscriber
chatClient.streamChatCompletion(request, new StreamChatCompletionSubscriber() {
chatClient.streamChatCompletion(request, new ChatCompletionStreamSubscriber() {
@Override
public void onChunk(ChatCompletionChunk chunk) {
System.out.println(chunk);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public Stream<ChatCompletionChunk> streamChatCompletion(CreateChatCompletionRequ

/**
* Same as {@link #streamChatCompletion(CreateChatCompletionRequest)} but can pass a {@link
* StreamChatCompletionSubscriber} implementation instead of using a {@link
* ChatCompletionStreamSubscriber} implementation instead of using a {@link
* Stream<ChatCompletionChunk>}
*/
public void streamChatCompletion(
CreateChatCompletionRequest request, StreamChatCompletionSubscriber subscriber) {
CreateChatCompletionRequest request, ChatCompletionStreamSubscriber subscriber) {
validateStreamRequest(request);
HttpRequest httpRequest = createPostRequest(request);
CompletableFuture.supplyAsync(() -> getStreamedResponses(httpRequest))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.stefanbratanov.jvm.openai;

/** An interface which is used to subscribe to streamed partial responses */
public interface StreamChatCompletionSubscriber {
public interface ChatCompletionStreamSubscriber {

/** Will be called when a partial response is received */
void onChunk(ChatCompletionChunk chunk);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void testChatClient() {
CompletableFuture<String> joinedContentFuture = new CompletableFuture<>();
chatClient.streamChatCompletion(
streamRequest,
new StreamChatCompletionSubscriber() {
new ChatCompletionStreamSubscriber() {
private final StringBuilder joinedContent = new StringBuilder();

@Override
Expand Down

0 comments on commit 9272bcb

Please sign in to comment.