Skip to content

Commit dd9e574

Browse files
ogirardotilayaperumalg
authored andcommitted
fix(spring-ai-azure-openai): last chat completions can have null deltas
Signed-off-by: ogirardot <olivier.girardot@arkhn.com>
1 parent 12729b0 commit dd9e574

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiChatModel.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,11 @@ public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousCha
353353
|| chatCompletions.getUsage() != null)
354354
.map(chatCompletions -> {
355355
if (!chatCompletions.getChoices().isEmpty()) {
356-
final var toolCalls = chatCompletions.getChoices().get(0).getDelta().getToolCalls();
356+
ChatChoice chatChoice = chatCompletions.getChoices().get(0);
357+
List<ChatCompletionsToolCall> toolCalls = null;
358+
if (chatChoice.getDelta() != null) {
359+
toolCalls = chatChoice.getDelta().getToolCalls();
360+
}
357361
isFunctionCall.set(toolCalls != null && !toolCalls.isEmpty());
358362
}
359363
return chatCompletions;

0 commit comments

Comments
 (0)