Update OpenAiStreamFunctionCallingHelper.java

preventing the occurrence of null pointers.
This commit is contained in:
GuangxiaoLong
2024-03-18 17:48:56 +08:00
committed by Christian Tzolov
parent c5f35029f0
commit ea79a4fbba

View File

@@ -63,8 +63,8 @@ public class OpenAiStreamFunctionCallingHelper {
ChunkChoice currentChoice0 = (CollectionUtils.isEmpty(current.choices()) ? null : current.choices().get(0));
ChunkChoice choice = merge(previousChoice0, currentChoice0);
return new ChatCompletionChunk(id, List.of(choice), created, model, systemFingerprint, object);
List<ChunkChoice> chunkChoices = choice == null ? List.of() : List.of(choice);
return new ChatCompletionChunk(id, chunkChoices, created, model, systemFingerprint, object);
}
private ChunkChoice merge(ChunkChoice previous, ChunkChoice current) {
@@ -198,4 +198,4 @@ public class OpenAiStreamFunctionCallingHelper {
}
}
// ---
// ---