Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit 8263f57

Browse files
authored
Fix potential stream hangs by ensuring completion callback (#52)
## Issue Closes langchain4j/langchain4j#2048 ## Change Ensure that the completion callback is called even if the [DONE] event is not received. ## General checklist - [X] There are no breaking changes - [ ] I have added unit and/or integration tests for my change - [ ] The tests cover both positive and negative cases - [X] I have manually run all the unit and integration tests in the module I have added/changed, and they are all green
1 parent 80f444a commit 8263f57

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/dev/ai4j/openai4j/StreamingRequestExecutor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ public void onEvent(EventSource eventSource, String id, String type, String data
167167
}
168168

169169
if ("[DONE]".equals(data)) {
170-
streamingCompletionCallback.run();
171170
return;
172171
}
173172

@@ -192,6 +191,8 @@ public void onClosed(EventSource eventSource) {
192191
if (logStreamingResponses) {
193192
log.debug("onClosed()");
194193
}
194+
195+
streamingCompletionCallback.run();
195196
}
196197

197198
@Override

0 commit comments

Comments
 (0)