Skip to content

Commit bf1f491

Browse files
newtorka-dbot-sdk-jsMatKuhr
authored
Drop redundant "model" method prefix (#170)
* Initial * Formatting --------- Co-authored-by: Alexander Dümont <[email protected]> Co-authored-by: SAP Cloud SDK Bot <[email protected]> Co-authored-by: Matthias Kuhr <[email protected]>
1 parent 95409ae commit bf1f491

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

docs/guides/ORCHESTRATION_CHAT_COMPLETION.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ Change your LLM configuration to add model parameters:
200200
```java
201201
OrchestrationAiModel customGPT4O =
202202
OrchestrationAiModel.GPT_4O
203-
.withModelParams(
203+
.withParams(
204204
Map.of(
205205
"max_tokens", 50,
206206
"temperature", 0.1,
207207
"frequency_penalty", 0,
208208
"presence_penalty", 0))
209-
.withModelVersion("2024-05-13");
209+
.withVersion("2024-05-13");
210210
```

orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationAiModel.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@AllArgsConstructor
1414
public class OrchestrationAiModel {
1515
/** The name of the model */
16-
String modelName;
16+
String name;
1717

1818
/**
1919
* Optional parameters on this model.
@@ -26,10 +26,10 @@ public class OrchestrationAiModel {
2626
* "presence_penalty", 0)
2727
* }</pre>
2828
*/
29-
Map<String, Object> modelParams;
29+
Map<String, Object> params;
3030

3131
/** The version of the model, defaults to "latest". */
32-
String modelVersion;
32+
String version;
3333

3434
/** IBM Granite 13B chat completions model */
3535
public static final OrchestrationAiModel IBM_GRANITE_13B_CHAT =
@@ -106,15 +106,12 @@ public class OrchestrationAiModel {
106106
public static final OrchestrationAiModel GEMINI_1_5_FLASH =
107107
new OrchestrationAiModel("gemini-1.5-flash");
108108

109-
OrchestrationAiModel(@Nonnull final String modelName) {
110-
this(modelName, Map.of(), "latest");
109+
OrchestrationAiModel(@Nonnull final String name) {
110+
this(name, Map.of(), "latest");
111111
}
112112

113113
@Nonnull
114114
LLMModuleConfig createConfig() {
115-
return new LLMModuleConfig()
116-
.modelName(modelName)
117-
.modelParams(modelParams)
118-
.modelVersion(modelVersion);
115+
return new LLMModuleConfig().modelName(name).modelParams(params).modelVersion(version);
119116
}
120117
}

orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationModuleConfigTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,16 @@ void testDpiMaskingConfig() {
6969
void testLLMConfig() {
7070
Map<String, Object> params = Map.of("foo", "bar");
7171
String version = "2024-05-13";
72-
OrchestrationAiModel aiModel = GPT_4O.withModelParams(params).withModelVersion(version);
72+
OrchestrationAiModel aiModel = GPT_4O.withParams(params).withVersion(version);
7373
var config = new OrchestrationModuleConfig().withLlmConfig(aiModel);
7474

7575
assertThat(config.getLlmConfig()).isNotNull();
76-
assertThat(config.getLlmConfig().getModelName()).isEqualTo(GPT_4O.getModelName());
76+
assertThat(config.getLlmConfig().getModelName()).isEqualTo(GPT_4O.getName());
7777
assertThat(config.getLlmConfig().getModelParams()).isEqualTo(params);
7878
assertThat(config.getLlmConfig().getModelVersion()).isEqualTo(version);
7979

80-
assertThat(GPT_4O.getModelParams())
81-
.withFailMessage("Static models should be unchanged")
82-
.isEmpty();
83-
assertThat(GPT_4O.getModelVersion())
80+
assertThat(GPT_4O.getParams()).withFailMessage("Static models should be unchanged").isEmpty();
81+
assertThat(GPT_4O.getVersion())
8482
.withFailMessage("Static models should be unchanged")
8583
.isEqualTo("latest");
8684
}

orchestration/src/test/java/com/sap/ai/sdk/orchestration/OrchestrationUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
@WireMockTest
5353
class OrchestrationUnitTest {
5454
static final OrchestrationAiModel CUSTOM_GPT_35 =
55-
GPT_35_TURBO_16K.withModelParams(
55+
GPT_35_TURBO_16K.withParams(
5656
Map.of(
5757
"max_tokens", 50,
5858
"temperature", 0.1,

0 commit comments

Comments
 (0)