Skip to content

Commit

Permalink
spring-projects#690 choices can be null look at OpenAiApi.java:606
Browse files Browse the repository at this point in the history
Signed-off-by: JoeHitHard <josephmeghanath@gmail.com>
  • Loading branch information
JoeHitHard authored and bmoussaud committed May 27, 2024
1 parent f3dc3fd commit a77d11c
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,13 @@ public ChatResponse call(Prompt prompt) {

RateLimit rateLimits = OpenAiResponseHeaderExtractor.extractAiResponseHeaders(completionEntity);

List<Generation> generations = chatCompletion.choices().stream().map(choice -> {
List<Choice> choices = chatCompletion.choices();
if (choices == null) {
logger.warn("No choices returned for prompt: {}", prompt);
return new ChatResponse(List.of());
}

List<Generation> generations = choices.stream().map(choice -> {
return new Generation(choice.message().content(), toMap(chatCompletion.id(), choice))
.withGenerationMetadata(ChatGenerationMetadata.from(choice.finishReason().name(), null));
}).toList();
Expand Down

0 comments on commit a77d11c

Please sign in to comment.