Skip to content

Commit 8c0f088

Browse files
Fixed orchestrationModelAvailability
1 parent cc12f82 commit 8c0f088

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import com.sap.ai.sdk.orchestration.client.model.FilterConfig;
1515
import com.sap.ai.sdk.orchestration.client.model.FilteringModuleConfig;
1616
import com.sap.ai.sdk.orchestration.client.model.InputFilteringConfig;
17-
import com.sap.ai.sdk.orchestration.client.model.LLMModuleConfig;
1817
import com.sap.ai.sdk.orchestration.client.model.MaskingModuleConfig;
1918
import com.sap.ai.sdk.orchestration.client.model.MaskingProviderConfig;
2019
import com.sap.ai.sdk.orchestration.client.model.OutputFilteringConfig;
@@ -32,11 +31,9 @@
3231
@RestController
3332
@RequestMapping("/orchestration")
3433
class OrchestrationController {
35-
LLMModuleConfig llmConfig = GPT_35_TURBO;
3634

3735
private final OrchestrationClient client = new OrchestrationClient();
38-
private final OrchestrationModuleConfig config =
39-
new OrchestrationModuleConfig().withLlmConfig(llmConfig);
36+
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO);
4037

4138
/**
4239
* Chat request to OpenAI through the Orchestration service with a simple prompt.

sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/OrchestrationTest.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.sap.ai.sdk.orchestration.OrchestrationAiModel;
77
import com.sap.ai.sdk.orchestration.OrchestrationClientException;
8+
import com.sap.ai.sdk.orchestration.OrchestrationModuleConfig;
89
import com.sap.ai.sdk.orchestration.client.model.AzureThreshold;
910
import com.sap.ai.sdk.orchestration.client.model.CompletionPostResponse;
1011
import java.lang.reflect.Field;
@@ -38,6 +39,9 @@ void testCompletion() {
3839

3940
@Test
4041
void testTemplate() {
42+
assertThat(controller.config.getLlmConfig()).isNotNull();
43+
final var model = controller.config.getLlmConfig().getModelName();
44+
4145
final var result = controller.template();
4246

4347
assertThat(result.getRequestId()).isNotEmpty();
@@ -48,7 +52,7 @@ void testTemplate() {
4852
assertThat(llm.getId()).isNotEmpty();
4953
assertThat(llm.getObject()).isEqualTo("chat.completion");
5054
assertThat(llm.getCreated()).isGreaterThan(1);
51-
assertThat(llm.getModel()).isEqualTo(controller.llmConfig.getModelName());
55+
assertThat(llm.getModel()).isEqualTo(model);
5256
var choices = llm.getChoices();
5357
assertThat(choices.get(0).getIndex()).isZero();
5458
assertThat(choices.get(0).getMessage().getContent()).isNotEmpty();
@@ -60,8 +64,7 @@ void testTemplate() {
6064
assertThat(usage.getTotalTokens()).isGreaterThan(1);
6165
assertThat(result.getOrchestrationResult().getObject()).isEqualTo("chat.completion");
6266
assertThat(result.getOrchestrationResult().getCreated()).isGreaterThan(1);
63-
assertThat(result.getOrchestrationResult().getModel())
64-
.isEqualTo(controller.llmConfig.getModelName());
67+
assertThat(result.getOrchestrationResult().getModel()).isEqualTo(model);
6568
choices = result.getOrchestrationResult().getChoices();
6669
assertThat(choices.get(0).getIndex()).isZero();
6770
assertThat(choices.get(0).getMessage().getContent()).isNotEmpty();
@@ -161,12 +164,12 @@ void orchestrationModelAvailability() {
161164
}
162165
}
163166

164-
declaredOrchestrationModelList.parallelStream()
165-
.forEach(
166-
model -> {
167-
controller.llmConfig = model;
168-
log.info("Testing completion for model: {}", model.getModelName());
169-
assertThat(controller.completion()).isNotNull();
170-
});
167+
for (OrchestrationAiModel model : declaredOrchestrationModelList) {
168+
controller.config = new OrchestrationModuleConfig().withLlmConfig(model);
169+
log.info("Testing completion for model: {}", model.getModelName());
170+
final var completion = controller.completion();
171+
final var requestModel = completion.getOrchestrationResult().getModel();
172+
assertThat(requestModel).contains(model.getModelName());
173+
}
171174
}
172175
}

0 commit comments

Comments
 (0)