Skip to content

Commit

Permalink
Fix potential NPE using nullSafeList
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcheng1982 committed Jun 6, 2024
1 parent 64378df commit 455a997
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ public ChatResponse call(Prompt prompt) {
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();
Expand Down

0 comments on commit 455a997

Please sign in to comment.