Skip to content

Commit 5ae0475

Browse files
author
Vincenzo Sciangola
committed
Prevent NPE when delta is null in Azure OpenAI streaming
Azure OpenAI sends streaming chunks without delta content for end-of-stream markers and content filter responses. Added null check to prevent NullPointerException in streaming handler.
1 parent 5a7b7d5 commit 5ae0475

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

model-providers/openai/azure-openai/runtime/src/main/java/io/quarkiverse/langchain4j/azure/openai/AzureOpenAiStreamingChatModel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ private static void handle(ChatCompletionResponse partialResponse,
234234
return;
235235
}
236236
Delta delta = choices.get(0).delta();
237+
if (delta == null) {
238+
return;
239+
}
237240
String content = delta.content();
238241
if (content != null) {
239242
handler.onPartialResponse(content);

0 commit comments

Comments
 (0)