Skip to content

Commit 75dea3f

Browse files
authored
chore: Update deprecated models (#380)
* Update text-embedding-ada-002 to text-embedding-3-small * Update gpt-35-turbo to gpt-4o-mini * Small fix --------- Co-authored-by: Jonas Israel <[email protected]>
1 parent 719c8d1 commit 75dea3f

File tree

10 files changed

+42
-42
lines changed

10 files changed

+42
-42
lines changed

docs/blog/Introducing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Please open a [feature request](https://github.com/SAP/ai-sdk-java/issues/new/ch
9494

9595
```java
9696
var result =
97-
OpenAiClient.forModel(GPT_35_TURBO)
97+
OpenAiClient.forModel(GPT_4O_MINI)
9898
.withSystemPrompt("You are a helpful AI")
9999
.chatCompletion("Hello World! Why is this phrase so famous?");
100100

docs/guides/AI_CORE_DEPLOYMENT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ In addition to the prerequisites above, we assume you have already set up the fo
5050
"executableId": "azure-openai",
5151
"id": "12345-123-123-123-123456abcdefg",
5252
"inputArtifactBindings": [],
53-
"name": "gpt-35-turbo",
53+
"name": "gpt-4o-mini",
5454
"parameterBindings": [
5555
{
5656
"key": "modelName",
57-
"value": "gpt-35-turbo"
57+
"value": "gpt-4o-mini"
5858
},
5959
{
6060
"key": "modelVersion",

docs/guides/OPENAI_CHAT_COMPLETION.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ In addition to the prerequisites above, we assume you have already set up the fo
7171
"id": "d123456abcdefg",
7272
"deploymentUrl": "https://api.ai.region.aws.ml.hana.ondemand.com/v2/inference/deployments/d123456abcdefg",
7373
"configurationId": "12345-123-123-123-123456abcdefg",
74-
"configurationName": "gpt-35-turbo",
74+
"configurationName": "gpt-4o-mini",
7575
"scenarioId": "foundation-models",
7676
"status": "RUNNING",
7777
"statusMessage": null,
@@ -86,7 +86,7 @@ In addition to the prerequisites above, we assume you have already set up the fo
8686
"resources": {
8787
"backendDetails": {
8888
"model": {
89-
"name": "gpt-35-turbo",
89+
"name": "gpt-4o-mini",
9090
"version": "latest"
9191
}
9292
}
@@ -106,7 +106,7 @@ In addition to the prerequisites above, we assume you have already set up the fo
106106

107107
```java
108108
var result =
109-
OpenAiClient.forModel(GPT_35_TURBO)
109+
OpenAiClient.forModel(GPT_4O_MINI)
110110
.withSystemPrompt("You are a helpful AI")
111111
.chatCompletion("Hello World! Why is this phrase so famous?");
112112

@@ -146,7 +146,7 @@ var userMessage =
146146
var request =
147147
new OpenAiChatCompletionParameters().addMessages(systemMessage, userMessage);
148148

149-
var result = OpenAiClient.forModel(GPT_35_TURBO).chatCompletion(request);
149+
var result = OpenAiClient.forModel(GPT_4O_MINI).chatCompletion(request);
150150

151151
String resultMessage = result.getContent();
152152
```
@@ -162,7 +162,7 @@ To target a specific version, you can specify the model version along with the m
162162

163163
```java
164164
OpenAiChatCompletionOutput result =
165-
OpenAiClient.forModel(GPT_35_TURBO.withVersion("1106")).chatCompletion(request);
165+
OpenAiClient.forModel(GPT_4O_MINI.withVersion("1106")).chatCompletion(request);
166166
```
167167

168168
## Chat completion with Custom Model
@@ -187,7 +187,7 @@ This is a blocking example for streaming and printing directly to the console:
187187
```java
188188
String msg = "Can you give me the first 100 numbers of the Fibonacci sequence?";
189189

190-
OpenAiClient client = OpenAiClient.forModel(GPT_35_TURBO);
190+
OpenAiClient client = OpenAiClient.forModel(GPT_4O_MINI);
191191

192192
// try-with-resources on stream ensures the connection will be closed
193193
try (Stream<String> stream = client.streamChatCompletion(msg)) {
@@ -254,7 +254,7 @@ var userMessage =
254254
var requestParameters =
255255
new OpenAiChatCompletionParameters().addMessages(userMessage);
256256

257-
var client = OpenAiClient.forModel(GPT_35_TURBO);
257+
var client = OpenAiClient.forModel(GPT_4O_MINI);
258258
var totalOutput = new OpenAiChatCompletionOutput();
259259

260260
// Prepare the stream before starting the thread to handle any initialization exceptions
@@ -292,7 +292,7 @@ Get the embeddings of a text input in list of float values:
292292
```java
293293
var request = new OpenAiEmbeddingRequest(List.of("Hello World"));
294294

295-
OpenAiEmbeddingResponse response = OpenAiClient.forModel(TEXT_EMBEDDING_ADA_002).embedding(request);
295+
OpenAiEmbeddingResponse response = OpenAiClient.forModel(TEXT_EMBEDDING_3_SMALL).embedding(request);
296296
float[] embedding = embedding.getEmbeddings().get(0);
297297
```
298298

@@ -302,7 +302,7 @@ float[] embedding = embedding.getEmbeddings().get(0);
302302
```java
303303
var request = new OpenAiEmbeddingParameters().setInput("Hello World");
304304

305-
OpenAiEmbeddingOutput embedding = OpenAiClient.forModel(TEXT_EMBEDDING_ADA_002).embedding(request);
305+
OpenAiEmbeddingOutput embedding = OpenAiClient.forModel(TEXT_EMBEDDING_3_SMALL).embedding(request);
306306

307307
float[] embedding = embedding.getData().get(0).getEmbedding();
308308
```

docs/guides/SPRING_AI_INTEGRATION.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The Orchestration client is integrated in Spring AI classes:
5151

5252
```java
5353
ChatModel client = new OrchestrationChatModel();
54-
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO);
54+
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_4O_MINI);
5555
OrchestrationChatOptions opts = new OrchestrationChatOptions(config);
5656

5757
Prompt prompt = new Prompt("What is the capital of France?", opts);
@@ -66,7 +66,7 @@ Configure Orchestration modules withing Spring AI:
6666

6767
```java
6868
ChatModel client = new OrchestrationChatModel();
69-
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO);
69+
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_4O_MINI);
7070

7171
val masking =
7272
DpiMasking.anonymization()
@@ -91,7 +91,7 @@ to the frontend in real-time.
9191

9292
```java
9393
ChatModel client = new OrchestrationChatModel();
94-
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO);
94+
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_4O_MINI);
9595
OrchestrationChatOptions opts = new OrchestrationChatOptions(config);
9696

9797
Prompt prompt =
@@ -130,7 +130,7 @@ Then add your tool to the options:
130130

131131
```java
132132
ChatModel client = new OrchestrationChatModel();
133-
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO);
133+
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_4O_MINI);
134134
OrchestrationChatOptions opts = new OrchestrationChatOptions(config);
135135

136136
options.setToolCallbacks(List.of(ToolCallbacks.from(new WeatherMethod())));
@@ -150,7 +150,7 @@ Create a Spring AI `ChatClient` from our `OrchestrationChatModel` and add a chat
150150

151151
```java
152152
ChatModel client = new OrchestrationChatModel();
153-
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO);
153+
OrchestrationModuleConfig config = new OrchestrationModuleConfig().withLlmConfig(GPT_4O_MINI);
154154
OrchestrationChatOptions opts = new OrchestrationChatOptions(config);
155155

156156
val memory = new InMemoryChatMemory();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.sap.ai.sdk.app.controllers;
22

3-
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.TEXT_EMBEDDING_ADA_002;
3+
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.TEXT_EMBEDDING_3_SMALL;
44
import static java.time.LocalDate.now;
55
import static java.util.stream.Collectors.joining;
66

@@ -139,7 +139,7 @@ Object getDocumentsByCollectionId(
139139
@GetMapping("/vector/collection/create")
140140
String createCollection(
141141
@Nullable @RequestParam(value = "format", required = false) final String format) {
142-
final var embeddingConfig = EmbeddingConfig.create().modelName(TEXT_EMBEDDING_ADA_002.name());
142+
final var embeddingConfig = EmbeddingConfig.create().modelName(TEXT_EMBEDDING_3_SMALL.name());
143143
final var request =
144144
CollectionRequest.create().embeddingConfig(embeddingConfig).title(COLLECTION_TITLE);
145145
final var documents = CLIENT_VECTOR.createCollection(RESOURCE_GROUP, request);

sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OpenAiService.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.sap.ai.sdk.app.services;
22

3-
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_35_TURBO;
43
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_4O;
5-
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.TEXT_EMBEDDING_ADA_002;
4+
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_4O_MINI;
5+
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.TEXT_EMBEDDING_3_SMALL;
66
import static com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionTool.ToolType.FUNCTION;
77

88
import com.sap.ai.sdk.core.AiCoreService;
@@ -35,7 +35,7 @@ public class OpenAiService {
3535
*/
3636
@Nonnull
3737
public OpenAiChatCompletionOutput chatCompletion(@Nonnull final String prompt) {
38-
return OpenAiClient.forModel(GPT_35_TURBO).chatCompletion(prompt);
38+
return OpenAiClient.forModel(GPT_4O_MINI).chatCompletion(prompt);
3939
}
4040

4141
/**
@@ -50,7 +50,7 @@ public Stream<OpenAiChatCompletionDelta> streamChatCompletionDeltas(
5050
new OpenAiChatCompletionParameters()
5151
.addMessages(new OpenAiChatMessage.OpenAiChatUserMessage().addText(message));
5252

53-
return OpenAiClient.forModel(GPT_35_TURBO).streamChatCompletionDeltas(request);
53+
return OpenAiClient.forModel(GPT_4O_MINI).streamChatCompletionDeltas(request);
5454
}
5555

5656
/**
@@ -60,7 +60,7 @@ public Stream<OpenAiChatCompletionDelta> streamChatCompletionDeltas(
6060
*/
6161
@Nonnull
6262
public Stream<String> streamChatCompletion(@Nonnull final String message) {
63-
return OpenAiClient.forModel(GPT_35_TURBO)
63+
return OpenAiClient.forModel(GPT_4O_MINI)
6464
.withSystemPrompt("Be a good, honest AI and answer the following question:")
6565
.streamChatCompletion(message);
6666
}
@@ -109,7 +109,7 @@ public OpenAiChatCompletionOutput chatCompletionTools(final int months) {
109109
.setTools(List.of(tool))
110110
.setToolChoiceFunction("fibonacci");
111111

112-
return OpenAiClient.forModel(GPT_35_TURBO).chatCompletion(request);
112+
return OpenAiClient.forModel(GPT_4O_MINI).chatCompletion(request);
113113
}
114114

115115
/**
@@ -122,7 +122,7 @@ public OpenAiChatCompletionOutput chatCompletionTools(final int months) {
122122
public OpenAiEmbeddingOutput embedding(@Nonnull final String input) {
123123
final var request = new OpenAiEmbeddingParameters().setInput(input);
124124

125-
return OpenAiClient.forModel(TEXT_EMBEDDING_ADA_002).embedding(request);
125+
return OpenAiClient.forModel(TEXT_EMBEDDING_3_SMALL).embedding(request);
126126
}
127127

128128
/**

sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/SpringAiOrchestrationService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.sap.ai.sdk.app.services;
22

3-
import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.GPT_35_TURBO;
3+
import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.GPT_4O_MINI;
44

55
import com.sap.ai.sdk.orchestration.DpiMasking;
66
import com.sap.ai.sdk.orchestration.OrchestrationModuleConfig;
@@ -28,7 +28,7 @@
2828
public class SpringAiOrchestrationService {
2929
private final ChatModel client = new OrchestrationChatModel();
3030
private final OrchestrationModuleConfig config =
31-
new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO);
31+
new OrchestrationModuleConfig().withLlmConfig(GPT_4O_MINI);
3232
private final OrchestrationChatOptions defaultOptions = new OrchestrationChatOptions(config);
3333

3434
/**

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.sap.ai.sdk.app.controllers;
22

3-
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_35_TURBO;
3+
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_4O_MINI;
44
import static org.assertj.core.api.Assertions.assertThat;
55

66
import com.sap.ai.sdk.app.services.OpenAiService;
@@ -50,7 +50,7 @@ void streamChatCompletion() {
5050

5151
final var totalOutput = new OpenAiChatCompletionOutput();
5252
final var filledDeltaCount = new AtomicInteger(0);
53-
OpenAiClient.forModel(GPT_35_TURBO)
53+
OpenAiClient.forModel(GPT_4O_MINI)
5454
.streamChatCompletionDeltas(request)
5555
.peek(totalOutput::addDelta)
5656
// foreach consumes all elements, closing the stream at the end
@@ -88,7 +88,7 @@ void embedding() {
8888
final var embedding = service.embedding("Hello world");
8989

9090
assertThat(embedding.getData().get(0).getEmbedding()).hasSizeGreaterThan(1);
91-
assertThat(embedding.getModel()).isEqualTo("ada");
91+
assertThat(embedding.getModel()).isEqualTo("text-embedding-3-small");
9292
assertThat(embedding.getObject()).isEqualTo("list");
9393
}
9494

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.sap.ai.sdk.app.controllers;
22

3-
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_35_TURBO;
3+
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_4O_MINI;
44
import static com.sap.ai.sdk.foundationmodels.openai.generated.model.ChatCompletionResponseMessageRole.ASSISTANT;
55
import static org.assertj.core.api.Assertions.assertThat;
66

@@ -51,7 +51,7 @@ void streamChatCompletion() {
5151
final var usageRef = new AtomicReference<CompletionUsage>();
5252
final var filledDeltaCount = new AtomicInteger(0);
5353

54-
OpenAiClient.forModel(GPT_35_TURBO)
54+
OpenAiClient.forModel(GPT_4O_MINI)
5555
.streamChatCompletionDeltas(prompt)
5656
// foreach consumes all elements, closing the stream at the end
5757
.forEach(
@@ -67,7 +67,7 @@ void streamChatCompletion() {
6767
assertThat(filledDeltaCount.get()).isGreaterThan(0);
6868

6969
assertThat(usageRef.get().getTotalTokens()).isGreaterThan(0);
70-
assertThat(usageRef.get().getPromptTokens()).isEqualTo(14);
70+
assertThat(usageRef.get().getPromptTokens()).isGreaterThan(0);
7171
assertThat(usageRef.get().getCompletionTokens()).isGreaterThan(0);
7272
}
7373

@@ -90,7 +90,7 @@ void embedding() {
9090
assertThat(embedding.getEmbeddingVectors()).isInstanceOf(ArrayList.class);
9191
assertThat(embedding.getEmbeddingVectors().get(0)).isInstanceOf(float[].class);
9292

93-
assertThat(embedding.getOriginalResponse().getModel()).isEqualTo("ada");
93+
assertThat(embedding.getOriginalResponse().getModel()).isEqualTo("text-embedding-3-small");
9494
assertThat(embedding.getOriginalResponse().getObject()).isEqualTo("list");
9595
}
9696

sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/services/OpenAiServiceV2.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.sap.ai.sdk.app.services;
22

3-
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_35_TURBO;
43
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_4O;
5-
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.TEXT_EMBEDDING_ADA_002;
4+
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_4O_MINI;
5+
import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.TEXT_EMBEDDING_3_SMALL;
66
import static com.sap.ai.sdk.foundationmodels.openai.generated.model.ChatCompletionTool.TypeEnum.FUNCTION;
77

88
import com.sap.ai.sdk.core.AiCoreService;
@@ -37,7 +37,7 @@ public class OpenAiServiceV2 {
3737
*/
3838
@Nonnull
3939
public OpenAiChatCompletionResponse chatCompletion(@Nonnull final String prompt) {
40-
return OpenAiClient.forModel(GPT_35_TURBO)
40+
return OpenAiClient.forModel(GPT_4O_MINI)
4141
.chatCompletion(new OpenAiChatCompletionRequest(prompt));
4242
}
4343

@@ -51,7 +51,7 @@ public Stream<OpenAiChatCompletionDelta> streamChatCompletionDeltas(
5151
@Nonnull final String message) {
5252
final var request = new OpenAiChatCompletionRequest(OpenAiMessage.user(message));
5353

54-
return OpenAiClient.forModel(GPT_35_TURBO).streamChatCompletionDeltas(request);
54+
return OpenAiClient.forModel(GPT_4O_MINI).streamChatCompletionDeltas(request);
5555
}
5656

5757
/**
@@ -61,7 +61,7 @@ public Stream<OpenAiChatCompletionDelta> streamChatCompletionDeltas(
6161
*/
6262
@Nonnull
6363
public Stream<String> streamChatCompletion(@Nonnull final String message) {
64-
return OpenAiClient.forModel(GPT_35_TURBO)
64+
return OpenAiClient.forModel(GPT_4O_MINI)
6565
.withSystemPrompt("Be a good, honest AI and answer the following question:")
6666
.streamChatCompletion(message);
6767
}
@@ -107,7 +107,7 @@ public OpenAiChatCompletionResponse chatCompletionTools(final int months) {
107107
.withTools(List.of(tool))
108108
.withToolChoice(OpenAiToolChoice.function("fibonacci"));
109109

110-
return OpenAiClient.forModel(GPT_35_TURBO).chatCompletion(request);
110+
return OpenAiClient.forModel(GPT_4O_MINI).chatCompletion(request);
111111
}
112112

113113
/**
@@ -120,7 +120,7 @@ public OpenAiChatCompletionResponse chatCompletionTools(final int months) {
120120
public OpenAiEmbeddingResponse embedding(@Nonnull final String input) {
121121
final var request = new OpenAiEmbeddingRequest(List.of(input));
122122

123-
return OpenAiClient.forModel(TEXT_EMBEDDING_ADA_002).embedding(request);
123+
return OpenAiClient.forModel(TEXT_EMBEDDING_3_SMALL).embedding(request);
124124
}
125125

126126
/**

0 commit comments

Comments
 (0)