Fix potential NPE using nullSafeList

This commit is contained in:
Fu Cheng
2024-06-06 09:02:30 +08:00
committed by Christian Tzolov
parent 1d479e3aab
commit 52be1bcb4c

View File

@@ -143,8 +143,7 @@ public class AzureOpenAiChatModel
ChatCompletions chatCompletions = this.callWithFunctionSupport(options);
logger.trace("Azure ChatCompletions: {}", chatCompletions);
List<Generation> generations = chatCompletions.getChoices()
.stream()
List<Generation> generations = nullSafeList(chatCompletions.getChoices()).stream()
.map(choice -> new Generation(choice.getMessage().getContent())
.withGenerationMetadata(generateChoiceMetadata(choice)))
.toList();