diff --git a/e2e-test-app/src/test/java/com/sap/ai/sdk/app/controllers/OpenAiTest.java b/e2e-test-app/src/test/java/com/sap/ai/sdk/app/controllers/OpenAiTest.java index c37aff530..2973239a4 100644 --- a/e2e-test-app/src/test/java/com/sap/ai/sdk/app/controllers/OpenAiTest.java +++ b/e2e-test-app/src/test/java/com/sap/ai/sdk/app/controllers/OpenAiTest.java @@ -39,7 +39,7 @@ void streamChatCompletion() { .setMessages(List.of(new OpenAiChatUserMessage().addText("Who is the prettiest?"))); final var totalOutput = new OpenAiChatCompletionOutput(); - final var emptyDeltaCount = new AtomicInteger(0); + final var filledDeltaCount = new AtomicInteger(0); OpenAiClient.forModel(GPT_35_TURBO) .streamChatCompletionDeltas(request) .peek(totalOutput::addDelta) @@ -47,15 +47,15 @@ void streamChatCompletion() { .forEach( delta -> { final String deltaContent = delta.getDeltaContent(); - log.info("deltaContent: {}", deltaContent); - if (deltaContent.isEmpty()) { - emptyDeltaCount.incrementAndGet(); + log.info("delta: {}", delta); + if (!deltaContent.isEmpty()) { + filledDeltaCount.incrementAndGet(); } }); // the first two and the last delta don't have any content // see OpenAiChatCompletionDelta#getDeltaContent - assertThat(emptyDeltaCount.get()).isLessThanOrEqualTo(3); + assertThat(filledDeltaCount.get()).isGreaterThan(0); assertThat(totalOutput.getChoices()).isNotEmpty(); assertThat(totalOutput.getChoices().get(0).getMessage().getContent()).isNotEmpty(); diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model/StreamedDelta.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model/StreamedDelta.java index ac790901c..f426bf34f 100644 --- a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model/StreamedDelta.java +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model/StreamedDelta.java @@ -17,7 +17,7 @@ public interface StreamedDelta { * *

Note: If there are multiple choices only the first one is returned * - *

Note: The first two and the last delta do not contain any content + *

Note: Some deltas do not contain any content * * @return the message content or empty string. */