fix(spring-ai-azure-openai): last chat completions can have null deltas

Signed-off-by: ogirardot <olivier.girardot@arkhn.com>
This commit is contained in:
ogirardot
2025-02-13 21:37:47 +01:00
committed by Ilayaperumal Gopinathan
parent 12729b0900
commit dd9e574092

View File

@@ -353,7 +353,11 @@ public class AzureOpenAiChatModel extends AbstractToolCallSupport implements Cha
|| chatCompletions.getUsage() != null)
.map(chatCompletions -> {
if (!chatCompletions.getChoices().isEmpty()) {
final var toolCalls = chatCompletions.getChoices().get(0).getDelta().getToolCalls();
ChatChoice chatChoice = chatCompletions.getChoices().get(0);
List<ChatCompletionsToolCall> toolCalls = null;
if (chatChoice.getDelta() != null) {
toolCalls = chatChoice.getDelta().getToolCalls();
}
isFunctionCall.set(toolCalls != null && !toolCalls.isEmpty());
}
return chatCompletions;