From 7294193c782ea55ea3f6f41906e68e4c04054779 Mon Sep 17 00:00:00 2001 From: Matthias Kuhr <52661546+MatKuhr@users.noreply.github.com> Date: Fri, 6 Sep 2024 10:58:21 +0200 Subject: [PATCH 1/2] Fix E2E Test (#51) * Update OpenAiTest.java * Fix test --------- Co-authored-by: I538344 --- .../com/sap/ai/sdk/app/controllers/OpenAiTest.java | 10 +++++----- .../foundationmodels/openai/model/StreamedDelta.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) 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 c37aff53..2973239a 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 ac790901..f426bf34 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. */ From 712949a585a0002764626087928324b7127b1a48 Mon Sep 17 00:00:00 2001 From: Junjie Tang <33489572+jjtang1985@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:48:05 +0200 Subject: [PATCH 2/2] Use "SAP Cloud SDK for AI" in readme (#54) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9121fa2b..f0d078e4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![REUSE status](https://api.reuse.software/badge/git.fsfe.org/reuse/api)](https://api.reuse.software/info/git.fsfe.org/reuse/api) [![Fosstars security rating](https://github.com/SAP/cloud-sdk-java/blob/fosstars-report/fosstars_badge.svg)](https://github.com/SAP/cloud-sdk-java/blob/fosstars-report/fosstars_report.md) -# AI SDK for Java +# SAP Cloud SDK for AI (for Java) # ⚠️ This is a pre-alpha version of the AI SDK for Java. The APIs are subject to change ⚠️