From 36a66e5da6a075b41187092b22b156592fc4c9d8 Mon Sep 17 00:00:00 2001 From: Jonas Israel Date: Thu, 2 Jan 2025 13:39:07 +0100 Subject: [PATCH 1/2] Wip --- .../ai/sdk/orchestration/OrchestrationUnitTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java index 6b553735c..9ec0ed54b 100644 --- a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java +++ b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java @@ -614,4 +614,16 @@ void streamChatCompletionDeltas() throws IOException { Mockito.verify(inputStream, times(1)).close(); } } + + @Test + void testOrchestrationError() { + stubFor( + post(urlPathEqualTo("/completion")) + .willReturn( + aResponse() + .withBodyFile("templatingResponse.json") + .withHeader("Content-Type", "application/json"))); + final var response = client.chatCompletion(prompt, config); + OrchestrationError error = new OrchestrationError(response); + } } From 7ded1f78e059a02d90c08bed1d9879af58fadb4c Mon Sep 17 00:00:00 2001 From: Jonas Israel Date: Thu, 2 Jan 2025 15:35:03 +0100 Subject: [PATCH 2/2] Increase test coverage. --- .../sdk/orchestration/OrchestrationUnitTest.java | 16 +++------------- .../test/resources/filteringLooseRequest.json | 4 +++- .../src/test/resources/maskingRequest.json | 4 +++- .../test/resources/messagesHistoryRequest.json | 4 +++- .../src/test/resources/templatingRequest.json | 4 +++- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java index 9ec0ed54b..e4774013d 100644 --- a/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java +++ b/orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java @@ -70,7 +70,9 @@ class OrchestrationUnitTest { .withParam(MAX_TOKENS, 50) .withParam(TEMPERATURE, 0.1) .withParam(FREQUENCY_PENALTY, 0) - .withParam(PRESENCE_PENALTY, 0); + .withParam(PRESENCE_PENALTY, 0) + .withParam(TOP_P, 1) + .withParam(N, 1); private final Function fileLoader = filename -> Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(filename)); @@ -614,16 +616,4 @@ void streamChatCompletionDeltas() throws IOException { Mockito.verify(inputStream, times(1)).close(); } } - - @Test - void testOrchestrationError() { - stubFor( - post(urlPathEqualTo("/completion")) - .willReturn( - aResponse() - .withBodyFile("templatingResponse.json") - .withHeader("Content-Type", "application/json"))); - final var response = client.chatCompletion(prompt, config); - OrchestrationError error = new OrchestrationError(response); - } } diff --git a/orchestration/src/test/resources/filteringLooseRequest.json b/orchestration/src/test/resources/filteringLooseRequest.json index 0ed41eb03..8b350d94f 100644 --- a/orchestration/src/test/resources/filteringLooseRequest.json +++ b/orchestration/src/test/resources/filteringLooseRequest.json @@ -7,7 +7,9 @@ "temperature": 0.1, "max_tokens": 50, "frequency_penalty": 0, - "presence_penalty": 0 + "presence_penalty": 0, + "top_p" : 1, + "n" : 1 }, "model_version": "latest" }, diff --git a/orchestration/src/test/resources/maskingRequest.json b/orchestration/src/test/resources/maskingRequest.json index e582f4206..f6356d6bd 100644 --- a/orchestration/src/test/resources/maskingRequest.json +++ b/orchestration/src/test/resources/maskingRequest.json @@ -7,7 +7,9 @@ "presence_penalty": 0, "frequency_penalty": 0, "max_tokens": 50, - "temperature": 0.1 + "temperature": 0.1, + "top_p" : 1, + "n" : 1 }, "model_version": "latest" }, diff --git a/orchestration/src/test/resources/messagesHistoryRequest.json b/orchestration/src/test/resources/messagesHistoryRequest.json index 0f61de10b..f42674a2c 100644 --- a/orchestration/src/test/resources/messagesHistoryRequest.json +++ b/orchestration/src/test/resources/messagesHistoryRequest.json @@ -7,7 +7,9 @@ "presence_penalty": 0, "frequency_penalty": 0, "max_tokens": 50, - "temperature": 0.1 + "temperature": 0.1, + "top_p" : 1, + "n" : 1 }, "model_version": "latest" }, diff --git a/orchestration/src/test/resources/templatingRequest.json b/orchestration/src/test/resources/templatingRequest.json index b4a4a7366..090e64f75 100644 --- a/orchestration/src/test/resources/templatingRequest.json +++ b/orchestration/src/test/resources/templatingRequest.json @@ -15,7 +15,9 @@ "max_tokens": 50, "temperature": 0.1, "frequency_penalty": 0, - "presence_penalty": 0 + "presence_penalty": 0, + "top_p" : 1, + "n" : 1 }, "model_version": "latest" }